-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support iOS, Android, windows desktop
- Loading branch information
Wayne Gu
committed
Jun 24, 2016
1 parent
e5146a2
commit e32fd72
Showing
54 changed files
with
1,652 additions
and
119 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using HttpLibrary.Common; | ||
using HttpLibrary.Http; | ||
using HttpLibrary.Requesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace HttpLibraryWin32Test | ||
{ | ||
class HtmlRequest : Request | ||
{ | ||
public HtmlRequest(string uri) : base(RequestPriority.Normal) | ||
{ | ||
Uri = uri; | ||
|
||
} | ||
|
||
protected override void Encode() | ||
{ | ||
HttpRequest = new HttpRequest(Uri, HttpConst.HttpMethod_Get); | ||
|
||
} | ||
protected override void CreateResponse() | ||
{ | ||
Response = new HtmlResponse(); | ||
} | ||
} | ||
|
||
class HtmlResponse : Response | ||
{ | ||
public string Html | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
protected override void Decode() | ||
{ | ||
ResponseStream.Seek(0, SeekOrigin.Begin); | ||
using (var reader = new StreamReader(ResponseStream, Encoding.UTF8)) | ||
{ | ||
Html = reader.ReadToEnd(); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{84364106-78F5-48EC-8060-A2D9781C2243}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>HttpLibraryWin32Test</RootNamespace> | ||
<AssemblyName>HttpLibraryWin32Test</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="HtmlRequest.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\HttpLibrary.Net\HttpLibrary.Net.csproj"> | ||
<Project>{67f9d3a8-f71e-4428-913f-c37ae82cdb24}</Project> | ||
<Name>HttpLibrary.Net</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\..\src\HttpLibrary.Platform.Win32\HttpLibrary.Platform.Win32.csproj"> | ||
<Project>{44d5400f-02be-4b8e-840e-cc4a4c112c33}</Project> | ||
<Name>HttpLibrary.Platform.Win32</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using HttpLibrary.Platform.Win32; | ||
using HttpLibrary.Requesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace HttpLibraryWin32Test | ||
{ | ||
class Program | ||
{ | ||
static RequestQueue reqQueue; | ||
static void Main(string[] args) | ||
{ | ||
reqQueue = new RequestQueue(new HttpLibraryPlatformWin32()); | ||
|
||
var task = GetWebResource(args[0]); | ||
|
||
task.Wait(); | ||
|
||
Console.WriteLine(task.Result); | ||
} | ||
|
||
private static async Task<string> GetWebResource(string uri) | ||
{ | ||
var req = new HtmlRequest(uri); | ||
|
||
await reqQueue.SendRequestAsync(req); | ||
|
||
string content; | ||
var response = req.Response as HtmlResponse; | ||
if (response.IsSucceeded) | ||
{ | ||
content = response.Html; | ||
} | ||
else | ||
{ | ||
content = response.Exception.ToString(); | ||
} | ||
|
||
return content; | ||
|
||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("HttpLibraryWin32Test")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("HttpLibraryWin32Test")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("84364106-78f5-48ec-8060-a2d9781c2243")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
43 changes: 43 additions & 0 deletions
43
examples/HttpLibraryXamarinTest/HttpLibraryXamarinTest.Droid/HttpLibrarySettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using HttpLibraryXamarinTest; | ||
using HttpLibrary.Interop; | ||
using HttpLibrary.Platform.Android; | ||
using Xamarin.Forms; | ||
using Android.Content; | ||
|
||
[assembly: Dependency(typeof(HttpLibraryXamarinTest.Droid.HttpLibrarySettings))] | ||
|
||
namespace HttpLibraryXamarinTest.Droid | ||
{ | ||
class HttpLibrarySettings : IHttpLibrarySettings | ||
{ | ||
private HttpLibraryPlatformAndroid httpLibraryPlatform = new HttpLibraryPlatformAndroid(); | ||
|
||
public HttpLibrarySettings() | ||
{ | ||
var appName = GetApplicationName(Forms.Context); | ||
if(!string.IsNullOrEmpty(appName)) | ||
{ | ||
HttpLibraryPlaform.DeviceInfo.Application = appName; | ||
} | ||
} | ||
public IHttpLibraryPlatform HttpLibraryPlaform | ||
{ | ||
get | ||
{ | ||
return httpLibraryPlatform; | ||
} | ||
} | ||
|
||
private static String GetApplicationName(Context context) | ||
{ | ||
var appName = context.GetString(Resource.String.ApplicationName); | ||
var versionName = context.PackageManager.GetPackageInfo(context.PackageName, 0).VersionName; | ||
return appName + "/" + versionName; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
examples/HttpLibraryXamarinTest/HttpLibraryXamarinTest.Droid/Properties/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.wayne.httplibrary" android:versionName="0.0.0.1" android:versionCode="1"> | ||
<uses-sdk android:minSdkVersion="15" /> | ||
<application android:label="$safeprojectname$"></application> | ||
</manifest> | ||
<application android:label="HttpLibraryXamarinText" android:icon="@drawable/icon"></application> | ||
</manifest> |
2 changes: 2 additions & 0 deletions
2
examples/HttpLibraryXamarinTest/HttpLibraryXamarinTest.Droid/Resources/Resource.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
examples/HttpLibraryXamarinTest/HttpLibraryXamarinTest.Droid/Resources/values/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<resources> | ||
<string name="Hello">Hello World!</string> | ||
<string name="ApplicationName">HttpLibraryXamarinTest</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
examples/HttpLibraryXamarinTest/HttpLibraryXamarinTest.UWP/HttpLibrarySettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using HttpLibraryXamarinTest; | ||
using HttpLibrary.Interop; | ||
using HttpLibrary.Platform.UWP; | ||
using Xamarin.Forms; | ||
|
||
[assembly: Dependency(typeof(HttpLibraryXamarinTest.UWP.HttpLibrarySettings))] | ||
|
||
namespace HttpLibraryXamarinTest.UWP | ||
{ | ||
class HttpLibrarySettings : IHttpLibrarySettings | ||
{ | ||
private HttpLibraryPlatformUWP httpLibraryPlatform = new HttpLibraryPlatformUWP(); | ||
public IHttpLibraryPlatform HttpLibraryPlaform | ||
{ | ||
get | ||
{ | ||
return httpLibraryPlatform; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.