mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
WebClient folder renamed to net and WebClient renamed to HttpClient
This commit is contained in:
18
BCL.csproj
18
BCL.csproj
@ -128,16 +128,16 @@
|
|||||||
</TypeScriptCompile>
|
</TypeScriptCompile>
|
||||||
<TypeScriptCompile Include="Utils\utils_android.ts" />
|
<TypeScriptCompile Include="Utils\utils_android.ts" />
|
||||||
<TypeScriptCompile Include="Utils\utils_ios.ts" />
|
<TypeScriptCompile Include="Utils\utils_ios.ts" />
|
||||||
<TypeScriptCompile Include="WebClient\web_client.android.ts">
|
<TypeScriptCompile Include="net\http_client.android.ts">
|
||||||
<DependentUpon>web_client.d.ts</DependentUpon>
|
<DependentUpon>http_client.d.ts</DependentUpon>
|
||||||
</TypeScriptCompile>
|
</TypeScriptCompile>
|
||||||
<TypeScriptCompile Include="WebClient\web_client.ios.ts">
|
<TypeScriptCompile Include="net\http_client.ios.ts">
|
||||||
<DependentUpon>web_client.d.ts</DependentUpon>
|
<DependentUpon>http_client.d.ts</DependentUpon>
|
||||||
</TypeScriptCompile>
|
</TypeScriptCompile>
|
||||||
<TypeScriptCompile Include="WebClient\web_client.d.ts" />
|
<TypeScriptCompile Include="net\http_client.d.ts" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<TypeScriptCompile Include="WebClient\index.ts" />
|
<TypeScriptCompile Include="net\index.ts" />
|
||||||
<TypeScriptCompile Include="UserPreferences\index.ts" />
|
<TypeScriptCompile Include="UserPreferences\index.ts" />
|
||||||
<TypeScriptCompile Include="Location\index.ts" />
|
<TypeScriptCompile Include="Location\index.ts" />
|
||||||
<TypeScriptCompile Include="Image\index.ts" />
|
<TypeScriptCompile Include="Image\index.ts" />
|
||||||
@ -146,8 +146,8 @@
|
|||||||
<TypeScriptCompile Include="Camera\index.ts" />
|
<TypeScriptCompile Include="Camera\index.ts" />
|
||||||
<TypeScriptCompile Include="Application\index.ts" />
|
<TypeScriptCompile Include="Application\index.ts" />
|
||||||
<TypeScriptCompile Include="android17.d.ts" />
|
<TypeScriptCompile Include="android17.d.ts" />
|
||||||
<TypeScriptCompile Include="Promises\promises.ts" />
|
<TypeScriptCompile Include="promises\promises.ts" />
|
||||||
<TypeScriptCompile Include="Promises\index.ts" />
|
<TypeScriptCompile Include="promises\index.ts" />
|
||||||
<Content Include="_references.ts" />
|
<Content Include="_references.ts" />
|
||||||
<TypeScriptCompile Include="Console\console.android.ts">
|
<TypeScriptCompile Include="Console\console.android.ts">
|
||||||
<DependentUpon>console.d.ts</DependentUpon>
|
<DependentUpon>console.d.ts</DependentUpon>
|
||||||
@ -166,7 +166,7 @@
|
|||||||
<Content Include="UserPreferences\Readme.md" />
|
<Content Include="UserPreferences\Readme.md" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="WebClient\Readme.md" />
|
<Content Include="net\Readme.md" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Readme.md" />
|
<Content Include="Readme.md" />
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
declare var module, require;
|
declare var module, require;
|
||||||
module.exports = require("Promises/promises");
|
module.exports = require("promises/promises");
|
@ -1,2 +0,0 @@
|
|||||||
declare var module, require;
|
|
||||||
module.exports = require("WebClient/web_client");
|
|
@ -5,7 +5,7 @@
|
|||||||
import image_module = require("Image/image");
|
import image_module = require("Image/image");
|
||||||
import app_module = require("Application/application");
|
import app_module = require("Application/application");
|
||||||
|
|
||||||
export class Client {
|
export class HttpClient {
|
||||||
/**
|
/**
|
||||||
* Downloads string from url.
|
* Downloads string from url.
|
||||||
*/
|
*/
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import image_module = require("Image/image");
|
import image_module = require("Image/image");
|
||||||
|
|
||||||
export declare class Client {
|
export declare class HttpClient {
|
||||||
private static get(url: string, successCallback?: (result: any) => void, errorCallback?: (e: Error) => void)
|
private static get(url: string, successCallback?: (result: any) => void, errorCallback?: (e: Error) => void)
|
||||||
getString(url: string, successCallback?: (result: string) => void, errorCallback?: (e: Error) => void)
|
getString(url: string, successCallback?: (result: string) => void, errorCallback?: (e: Error) => void)
|
||||||
getJSON(url: string, successCallback?: (result: Object) => void, errorCallback?: (e: Error) => void)
|
getJSON(url: string, successCallback?: (result: Object) => void, errorCallback?: (e: Error) => void)
|
@ -3,15 +3,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import image_module = require("Image/image");
|
import image_module = require("Image/image");
|
||||||
import promises_module = require("Promises/promises");
|
import promises_module = require("promises/promises");
|
||||||
|
|
||||||
export class Client {
|
export class HttpClient {
|
||||||
/**
|
/**
|
||||||
* Downloads string from url.
|
* Downloads string from url.
|
||||||
*/
|
*/
|
||||||
public getString(url: string, successCallback: (result: string) => void, errorCallback?: (e: Error) => void) {
|
public getString(url: string, successCallback: (result: string) => void, errorCallback?: (e: Error) => void) {
|
||||||
try {
|
try {
|
||||||
Client.get(url, function (data) {
|
HttpClient.get(url, function (data) {
|
||||||
if (successCallback) {
|
if (successCallback) {
|
||||||
successCallback(Foundation.NSString.initWithDataEncoding(data, 4).toString());
|
successCallback(Foundation.NSString.initWithDataEncoding(data, 4).toString());
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ export class Client {
|
|||||||
|
|
||||||
public static getString(url : string) {
|
public static getString(url : string) {
|
||||||
var d = new promises_module.Promises.Deferred();
|
var d = new promises_module.Promises.Deferred();
|
||||||
new Client().getString(url, r => d.resolve(r), e => d.reject(e));
|
new HttpClient().getString(url, r => d.resolve(r), e => d.reject(e));
|
||||||
return d.promise();
|
return d.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ export class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getImage(url: string, successCallback: (result: image_module.Image) => void, errorCallback?: (e: Error) => void) {
|
public getImage(url: string, successCallback: (result: image_module.Image) => void, errorCallback?: (e: Error) => void) {
|
||||||
Client.get(url, function (data) {
|
HttpClient.get(url, function (data) {
|
||||||
if (successCallback) {
|
if (successCallback) {
|
||||||
var image = new image_module.Image();
|
var image = new image_module.Image();
|
||||||
image.loadFromData(data);
|
image.loadFromData(data);
|
||||||
@ -57,11 +57,11 @@ export class Client {
|
|||||||
if (!successCallback && !errorCallback)
|
if (!successCallback && !errorCallback)
|
||||||
{
|
{
|
||||||
var d = new promises_module.Promises.Deferred();
|
var d = new promises_module.Promises.Deferred();
|
||||||
Client.getUrl(url, r => d.resolve(r), e => d.reject(e));
|
HttpClient.getUrl(url, r => d.resolve(r), e => d.reject(e));
|
||||||
return d.promise();
|
return d.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
Client.getUrl(url, successCallback, errorCallback);
|
HttpClient.getUrl(url, successCallback, errorCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static getUrl(url: string, successCallback: (result: any) => void, errorCallback?: (e: Error) => void) {
|
private static getUrl(url: string, successCallback: (result: any) => void, errorCallback?: (e: Error) => void) {
|
2
net/index.ts
Normal file
2
net/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
declare var module, require;
|
||||||
|
module.exports = require("net/http_client");
|
Reference in New Issue
Block a user