Skip to content
Snippets Groups Projects
Commit e5a7e69e authored by Frederik Carlier's avatar Frederik Carlier
Browse files

Add support for .NET Core

parent 27d0b066
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
......@@ -35,10 +36,10 @@ namespace MasterDevs.ChromeDevTools
public async Task<string[]> GetSessions()
{
var remoteSessionUrls = new List<string>();
var webClient = new WebClient();
var webClient = new HttpClient();
var uriBuilder = new UriBuilder(RemoteDebuggingUri);
uriBuilder.Path = "/json";
var remoteSessions = await webClient.DownloadStringTaskAsync(uriBuilder.Uri);
var remoteSessions = await webClient.GetStringAsync(uriBuilder.Uri);
using (var stringReader = new StringReader(remoteSessions))
using (var jsonReader = new JsonTextReader(stringReader))
{
......
using MasterDevs.ChromeDevTools.Serialization;
#if !NETSTANDARD1_5
using MasterDevs.ChromeDevTools.Serialization;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
......@@ -250,4 +251,5 @@ namespace MasterDevs.ChromeDevTools
_openEvent.Set();
}
}
}
\ No newline at end of file
}
#endif
namespace MasterDevs.ChromeDevTools
#if !NETSTANDARD1_5
namespace MasterDevs.ChromeDevTools
{
public class ChromeSessionFactory : IChromeSessionFactory
{
......@@ -14,4 +15,5 @@
return session;
}
}
}
\ No newline at end of file
}
#endif
using System;
using System.Linq;
using System.Reflection;
namespace MasterDevs.ChromeDevTools
{
......@@ -14,18 +15,18 @@ namespace MasterDevs.ChromeDevTools
public static string GetMethod(this Type type)
{
if (null == type) return null;
var eventAttribute = type.GetCustomAttributes(typeof(EventAttribute), true)
var eventAttribute = type.GetTypeInfo().GetCustomAttributes(typeof(EventAttribute), true)
.FirstOrDefault() as EventAttribute;
if (null != eventAttribute) return eventAttribute.MethodName;
var commandAttribute = type.GetCustomAttributes(typeof(CommandAttribute), true)
var commandAttribute = type.GetTypeInfo().GetCustomAttributes(typeof(CommandAttribute), true)
.FirstOrDefault() as CommandAttribute;
if (null != commandAttribute) return commandAttribute.MethodName;
var commandResponseAttribute = type.GetCustomAttributes(typeof(CommandResponseAttribute), true)
var commandResponseAttribute = type.GetTypeInfo().GetCustomAttributes(typeof(CommandResponseAttribute), true)
.FirstOrDefault() as CommandResponseAttribute;
if (null != commandResponseAttribute) return commandResponseAttribute.MethodName;
// maybe it's generic parameter has a method
if (type.IsGenericType)
if (type.GetTypeInfo().IsGenericType)
{
return type.GenericTypeArguments
.FirstOrDefault()
......
......@@ -43,6 +43,9 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......
......@@ -23,11 +23,11 @@ namespace MasterDevs.ChromeDevTools
private void LoadMethodTypeMap(string alias)
{
var assembly = Assembly.GetExecutingAssembly();
var assembly = typeof(MethodTypeMap).GetTypeInfo().Assembly;
var assemblyTypes = assembly.GetTypes();
foreach (var type in assemblyTypes)
{
if (!type.IsClass) continue;
if (!type.GetTypeInfo().IsClass) continue;
if (!type.Namespace.StartsWith($"MasterDevs.ChromeDevTools.Protocol.{alias}")) continue;
......@@ -54,7 +54,7 @@ namespace MasterDevs.ChromeDevTools
private string GetMethodName<T>(Type type) where T : IMethodNameAttribute
{
var attribute = type.GetCustomAttributes(typeof(T))
var attribute = type.GetTypeInfo().GetCustomAttributes(typeof(T))
.FirstOrDefault();
if (null == attribute) return null;
var methodNameAttribute = attribute as IMethodNameAttribute;
......
{
"version": "1.0.3-*",
"description": "Contains the classes and utilities used to interact with the Chrome Developer Tools",
"authors": [ "MasterDevs" ],
"packOptions": {
"projectUrl": "https://github.com/MasterDevs/ChromeDevTools",
"licenseUrl": "https://github.com/MasterDevs/ChromeDevTools/blob/master/LICENSE",
"iconUrl": "http://masterdevs.com/images/FavIcon_144.png"
},
"buildOptions": {},
"dependencies": {
"Newtonsoft.Json": "9.0.1"
},
"frameworks": {
"netstandard15": {
"dependencies": {
"System.Reflection": "4.1.0",
"System.Runtime": "4.1.0",
"System.Collections.Concurrent": "4.0.12",
"System.IO.FileSystem": "4.0.1",
"System.Diagnostics.Process": "4.1.0",
"System.Runtime.InteropServices": "4.1.0",
"System.Net.Http": "4.1.0",
"System.Threading.Thread": "4.0.0"
}
},
"net45": {
"dependencies": {
"WebSocket4Net": "0.14.1"
},
"frameworkAssemblies": {
"System.Net.Http": "4.0.0.0"
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment