generated from seclerp/dotnet-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
202 changed files
with
59,156 additions
and
25 deletions.
There are no files selected for viewing
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackageId>ChromeProtocol.Core</PackageId> | ||
<IsPackable>true</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json"/> | ||
</ItemGroup> | ||
|
||
</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,4 @@ | ||
namespace ChromeProtocol.Core; | ||
|
||
public delegate Task DomainEventHandler<in TEvent>(TEvent @event) | ||
where TEvent : IEvent; |
13 changes: 13 additions & 0 deletions
13
src/ChromeProtocol.Core/Extensions/ReflectionExtensions.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,13 @@ | ||
namespace ChromeProtocol.Core.Extensions; | ||
|
||
public static class ReflectionExtensions | ||
{ | ||
public static IEnumerable<Type> BaseTypesAndSelf(this Type type) | ||
{ | ||
while (type != null) | ||
{ | ||
yield return type; | ||
type = type.BaseType; | ||
} | ||
} | ||
} |
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,10 @@ | ||
namespace ChromeProtocol.Core; | ||
|
||
public interface ICommand | ||
{ | ||
} | ||
|
||
public interface ICommand<TResponse> : ICommand | ||
where TResponse : IType | ||
{ | ||
} |
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 @@ | ||
namespace ChromeProtocol.Core; | ||
|
||
public interface IEvent | ||
{ | ||
} |
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,7 @@ | ||
namespace ChromeProtocol.Core; | ||
|
||
public interface IType | ||
{ | ||
} | ||
|
||
public record ExampleValue(string Value) : PrimitiveType<string>(Value); |
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,16 @@ | ||
/// <auto-generated> | ||
// ReSharper disable once CheckNamespace | ||
|
||
using System.ComponentModel; | ||
|
||
namespace System.Runtime.CompilerServices | ||
{ | ||
/// <summary> | ||
/// Reserved to be used by the compiler for tracking metadata. | ||
/// This class should not be used by developers in source code. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
internal static class IsExternalInit | ||
{ | ||
} | ||
} |
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,15 @@ | ||
namespace ChromeProtocol.Core; | ||
|
||
/// <summary> | ||
/// Specifies method name to be used in context of given command or event. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Class, Inherited = false)] | ||
public class MethodNameAttribute : Attribute | ||
{ | ||
public string MethodName { get; } | ||
|
||
public MethodNameAttribute(string methodName) | ||
{ | ||
MethodName = methodName; | ||
} | ||
} |
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,11 @@ | ||
namespace ChromeProtocol.Core; | ||
|
||
public interface IPrimitiveType : IType | ||
{ | ||
object? RawValue { get; } | ||
} | ||
|
||
public abstract record PrimitiveType<TValue>(TValue Value) : IPrimitiveType | ||
{ | ||
object? IPrimitiveType.RawValue => Value; | ||
} |
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,32 @@ | ||
using ChromeProtocol.Core.Extensions; | ||
using Newtonsoft.Json; | ||
|
||
namespace ChromeProtocol.Core; | ||
|
||
public class PrimitiveTypeConverter : JsonConverter | ||
{ | ||
static Type? GetValueType(Type objectType) => | ||
objectType | ||
.BaseTypesAndSelf() | ||
.Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(PrimitiveType<>)) | ||
.Select(t => t.GetGenericArguments()[0]) | ||
.FirstOrDefault(); | ||
|
||
public override bool CanConvert(Type objectType) => GetValueType(objectType) != null; | ||
|
||
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) | ||
{ | ||
if (reader.TokenType == JsonToken.Null) | ||
return Activator.CreateInstance(objectType, null); | ||
|
||
var valueType = GetValueType(objectType); | ||
var value = serializer.Deserialize(reader, valueType); | ||
|
||
return Activator.CreateInstance(objectType, value); | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) | ||
{ | ||
serializer.Serialize(writer, ((IPrimitiveType?)value)?.RawValue); | ||
} | ||
} |
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,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackageId>ChromeProtocol.Domains</PackageId> | ||
<IsPackable>true</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ChromeProtocol.Core\ChromeProtocol.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Generated\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.