2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-05-07 12:02:59 +00:00

.Net 6 Upgrade

This commit is contained in:
Ahmed Zamil 2021-12-01 12:17:45 +03:00
parent 1166e93ba9
commit 530df018ec
164 changed files with 21247 additions and 21425 deletions

View File

@ -32,11 +32,10 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Esiur.Stores.EntityCore
{
namespace Esiur.Stores.EntityCore;
public class EntityResource : IResource
{
public class EntityResource : IResource
{
//[NotMapped]
//internal object _PrimaryId;
@ -71,5 +70,4 @@ namespace Esiur.Stores.EntityCore
}
}
}

View File

@ -34,10 +34,9 @@ using System.Linq;
using Microsoft.EntityFrameworkCore.Metadata;
using System.Reflection;
namespace Esiur.Stores.EntityCore
namespace Esiur.Stores.EntityCore;
public class EntityStore : IStore
{
public class EntityStore : IStore
{
public Instance Instance { get; set; }
public event DestroyedEvent OnDestroy;
@ -238,5 +237,4 @@ namespace Esiur.Stores.EntityCore
{
OnDestroy?.Invoke(this);
}
}
}

View File

@ -5,13 +5,12 @@ using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace Esiur.Stores.EntityCore
namespace Esiur.Stores.EntityCore;
struct EntityTypeInfo
{
struct EntityTypeInfo
{
public string Name;
public IEntityType Type;
public PropertyInfo PrimaryKey;
// public Func<DbContext> Getter;
}
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>Esiur.Stores.EntityCore</AssemblyName>
<Authors>Ahmed Kh. Zamil</Authors>
<Company>Esiur Foundation</Company>
@ -10,6 +10,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Esiur.Stores.EntityCore</PackageId>
<Version>1.2.5</Version>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
@ -21,7 +22,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="System.Collections" Version="4.3.0" />
</ItemGroup>

View File

@ -36,10 +36,10 @@ using System.Reflection;
using Esiur.Proxy;
using Microsoft.EntityFrameworkCore;
namespace Esiur.Stores.EntityCore
namespace Esiur.Stores.EntityCore;
public class EsiurExtensionOptions : IDbContextOptionsExtension
{
public class EsiurExtensionOptions : IDbContextOptionsExtension
{
//public Dictionary<Type, PropertyInfo> Cache { get; } = new Dictionary<Type, PropertyInfo>();
//public void AddType(IEntityType type)
@ -102,13 +102,17 @@ namespace Esiur.Stores.EntityCore
public override string LogFragment => "Esiur";
public override long GetServiceProviderHashCode() => 2312;
public override int GetServiceProviderHashCode() => 2312;
public override void PopulateDebugInfo(IDictionary<string, string> debugInfo)
{
}
public override bool ShouldUseSameServiceProvider(DbContextOptionsExtensionInfo other)
{
return true;
}
}
}
}

View File

@ -37,10 +37,10 @@ using System.Linq;
using System.Reflection;
using System.Text;
namespace Esiur.Stores.EntityCore
namespace Esiur.Stores.EntityCore;
public static class EsiurExtensions
{
public static class EsiurExtensions
{
//public static T CreateResource<T>(this DbContext dbContext, object properties = null) where T:class,IResource
//{
// return dbContext.GetInfrastructure().CreateResource<T>(properties);
@ -197,5 +197,4 @@ namespace Esiur.Stores.EntityCore
//}
}
}

View File

@ -30,10 +30,9 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Stores.EntityCore
namespace Esiur.Stores.EntityCore;
public class EsiurPlugin : IConventionSetPlugin
{
public class EsiurPlugin : IConventionSetPlugin
{
private readonly IDbContextOptions _options;
private readonly ProviderConventionSetBuilderDependencies _conventionSetBuilderDependencies;
@ -55,6 +54,5 @@ namespace Esiur.Stores.EntityCore
return conventionSet;
}
}
}

View File

@ -39,32 +39,20 @@ using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Esiur.Data;
namespace Esiur.Stores.EntityCore
namespace Esiur.Stores.EntityCore;
public class EsiurProxyRewrite : IModelFinalizingConvention
{
public class EsiurProxyRewrite : IModelFinalizingConvention
{
private static readonly MethodInfo _createInstance
= typeof(EsiurProxyRewrite).GetTypeInfo().GetDeclaredMethod(nameof(EsiurProxyRewrite.CreateInstance));
= typeof(EsiurProxyRewrite).GetTypeInfo().GetDeclaredMethod(nameof(EsiurProxyRewrite.CreateInstance));
private readonly ConstructorBindingConvention _directBindingConvention;
//public static object CreateInstance(IDbContextOptions dbContextOptions, IEntityType entityType,
// object[] constructorArguments, DbContext context, long id)
//{
// return CreateInstance(dbContextOptions, entityType,
// constructorArguments, context, id);
//}
public static object CreateInstance(
IDbContextOptions dbContextOptions,
public static object CreateInstance(IDbContextOptions dbContextOptions,
IEntityType entityType,
//object id
object[] properties
// ILazyLoader loader,
// object[] constructorArguments,
//DbContext context,
)
object[] properties)
{
var id = properties.First();
@ -116,15 +104,16 @@ namespace Esiur.Stores.EntityCore
// var ann = entityType.GetAnnotation(CoreAnnotationNames.ConstructorBinding);
#pragma warning disable EF1001 // Internal EF Core API usage.
var binding = (InstantiationBinding)entityType[CoreAnnotationNames.ConstructorBinding];
var binding = ((EntityType)entityType).ConstructorBinding;// (InstantiationBinding)entityType[CoreAnnotationNames.ConstructorBinding];
#pragma warning restore EF1001 // Internal EF Core API usage.
if (binding == null)
{
_directBindingConvention.ProcessModelFinalizing(modelBuilder, context);
#pragma warning disable EF1001 // Internal EF Core API usage.
binding = (InstantiationBinding)entityType[CoreAnnotationNames.ConstructorBinding];
binding = ((EntityType)entityType).ConstructorBinding; // (InstantiationBinding)entityType[CoreAnnotationNames.ConstructorBinding];
#pragma warning restore EF1001 // Internal EF Core API usage.
}
try
{
@ -133,31 +122,43 @@ namespace Esiur.Stores.EntityCore
if (key == null)
continue;
//var keys = entityType.FindPrimaryKey().Properties.Select(x=>new PropertyParameterBinding(x));
entityType.SetAnnotation(
#pragma warning disable EF1001 // Internal EF Core API usage.
CoreAnnotationNames.ConstructorBinding,
#pragma warning restore EF1001 // Internal EF Core API usage.
new FactoryMethodBinding(
_createInstance,
new List<ParameterBinding>
((EntityType)entityType).SetConstructorBinding(
UpdateConstructorBindings(key, proxyType),
ConfigurationSource.Convention);
binding = ((EntityType)entityType).ServiceOnlyConstructorBinding;
if (binding != null)
{
new DependencyInjectionParameterBinding(typeof(IDbContextOptions), typeof(IDbContextOptions)),
new EntityTypeParameterBinding(),
//new PropertyParameterBinding(key)
// constructor arguments
//new ObjectArrayParameterBinding(binding.ParameterBindings),
//new ContextParameterBinding(typeof(DbContext)),
//new ObjectArrayParameterBinding(entityType.FindPrimaryKey().Properties.Select(x=>new PropertyParameterBinding(x)).ToArray())
new ObjectArrayParameterBinding(new ParameterBinding[]{
new PropertyParameterBinding(key) })
//})
// new Microsoft.EntityFrameworkCore.Metadata.ObjectArrayParameterBinding(),
//new ObjectArrayParameterBinding()
((EntityType)entityType).SetServiceOnlyConstructorBinding(
UpdateConstructorBindings(key, proxyType),
ConfigurationSource.Convention);
}
},
proxyType));
// entityType.SetAnnotation(
//#pragma warning disable EF1001 // Internal EF Core API usage.
// CoreAnnotationNames.ConstructorBinding,
//#pragma warning restore EF1001 // Internal EF Core API usage.
// new FactoryMethodBinding(
// _createInstance,
// new List<ParameterBinding>
// {
// new DependencyInjectionParameterBinding(typeof(IDbContextOptions), typeof(IDbContextOptions)),
// new EntityTypeParameterBinding(),
// //new PropertyParameterBinding(key)
// // constructor arguments
// //new ObjectArrayParameterBinding(binding.ParameterBindings),
// //new ContextParameterBinding(typeof(DbContext)),
// //new ObjectArrayParameterBinding(entityType.FindPrimaryKey().Properties.Select(x=>new PropertyParameterBinding(x)).ToArray())
// new ObjectArrayParameterBinding(new ParameterBinding[]{
// new PropertyParameterBinding(key) })
// //})
// // new Microsoft.EntityFrameworkCore.Metadata.ObjectArrayParameterBinding(),
// //new ObjectArrayParameterBinding()
// },
// proxyType));
}
catch
@ -165,9 +166,30 @@ namespace Esiur.Stores.EntityCore
}
}
}
}
private InstantiationBinding UpdateConstructorBindings(
IConventionProperty key,
Type proxyType)
{
return new FactoryMethodBinding(
_createInstance,
new List<ParameterBinding>
{
new DependencyInjectionParameterBinding(typeof(IDbContextOptions), typeof(IDbContextOptions)),
new EntityTypeParameterBinding(),
new ObjectArrayParameterBinding(new ParameterBinding[]{
new PropertyParameterBinding((IProperty)key) })
},
proxyType);
}
}

View File

@ -13,6 +13,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.5.2</Version>
<PackageId>Esiur.Stores.MongoDB</PackageId>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -37,10 +37,10 @@ using System.Linq;
using Esiur.Security.Permissions;
using Esiur.Proxy;
namespace Esiur.Stores.MongoDB
namespace Esiur.Stores.MongoDB;
public class MongoDBStore : IStore
{
public class MongoDBStore : IStore
{
public Instance Instance { get; set; }
public event DestroyedEvent OnDestroy;
@ -271,7 +271,7 @@ namespace Esiur.Stores.MongoDB
else
{
return new AsyncReply<object>(value.RawValue);
return new AsyncReply<object>(BsonTypeMapper.MapToDotNetValue(value));
}
}
@ -407,7 +407,7 @@ namespace Esiur.Stores.MongoDB
return true;
}
catch(Exception ex)
catch (Exception ex)
{
Console.WriteLine(ex);
return false;
@ -916,5 +916,4 @@ namespace Esiur.Stores.MongoDB
{
throw new NotImplementedException();
}
}
}

View File

@ -4,10 +4,10 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncAwaiter : INotifyCompletion
{
public class AsyncAwaiter : INotifyCompletion
{
Action callback = null;
AsyncException exception = null;
@ -49,5 +49,4 @@ namespace Esiur.Core
}
}
}

View File

@ -4,10 +4,10 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncAwaiter<T> : INotifyCompletion
{
public class AsyncAwaiter<T> : INotifyCompletion
{
Action callback = null;
AsyncException exception = null;
@ -48,6 +48,4 @@ namespace Esiur.Core
}
}
}

View File

@ -28,10 +28,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncBag : AsyncReply
{
public class AsyncBag: AsyncReply
{
protected List<AsyncReply> replies = new List<AsyncReply>();
List<object> results = new List<object>();
@ -127,5 +127,4 @@ namespace Esiur.Core
}
}
}

View File

@ -4,10 +4,10 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncBagAwaiter : INotifyCompletion
{
public class AsyncBagAwaiter : INotifyCompletion
{
Action callback = null;
AsyncException exception = null;
@ -48,6 +48,4 @@ namespace Esiur.Core
}
}
}

View File

@ -4,10 +4,10 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncBagAwaiter<T> : INotifyCompletion
{
public class AsyncBagAwaiter<T> : INotifyCompletion
{
Action callback = null;
AsyncException exception = null;
@ -48,6 +48,4 @@ namespace Esiur.Core
}
}
}

View File

@ -28,13 +28,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncBag<T> : AsyncBag
{
public class AsyncBag<T>: AsyncBag
{
public AsyncBag<T> Then(Action<T[]> callback)
{
base.Then(new Action<object>((o) => callback(((object[])o).Select(x=>(T)x).ToArray())));
base.Then(new Action<object>((o) => callback(((object[])o).Select(x => (T)x).ToArray())));
return this;
}
@ -67,9 +67,8 @@ namespace Esiur.Core
}
public AsyncBag(T[] results)
: base(results.Select(x=>(object)x).ToArray())
: base(results.Select(x => (object)x).ToArray())
{
}
}
}

View File

@ -26,14 +26,14 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncException : Exception
{
public class AsyncException : Exception
{
public readonly ErrorType Type;
public readonly ExceptionCode Code;
public AsyncException(Exception exception) :base(exception.Message, exception)
public AsyncException(Exception exception) : base(exception.Message, exception)
{
Type = ErrorType.Exception;
Code = 0;
@ -53,5 +53,4 @@ namespace Esiur.Core
{
return Code.ToString() + ": " + Message;
}
}
}

View File

@ -28,10 +28,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncQueue<T> : AsyncReply<T>
{
public class AsyncQueue<T> : AsyncReply<T>
{
List<AsyncReply<T>> list = new List<AsyncReply<T>>();
//Action<T> callback;
object queueLock = new object();
@ -80,5 +80,4 @@ namespace Esiur.Core
{
}
}
}

View File

@ -33,11 +33,11 @@ using System.Threading;
using System.Runtime.CompilerServices;
using System.Diagnostics;
namespace Esiur.Core
namespace Esiur.Core;
[AsyncMethodBuilder(typeof(AsyncReplyBuilder))]
public class AsyncReply
{
[AsyncMethodBuilder(typeof(AsyncReplyBuilder))]
public class AsyncReply
{
public bool Debug = false;
protected List<Action<object>> callbacks = new List<Action<object>>();
@ -303,7 +303,7 @@ namespace Esiur.Core
}
/*
public AsyncReply<T> Then(Action<T> callback)
public AsyncReply<T> Then(Action<T> callback)
{
base.Then(new Action<object>(o => callback((T)o)));
return this;
@ -352,9 +352,8 @@ namespace Esiur.Core
}
*/
*/
}
}

View File

@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncReplyBuilder
{
public class AsyncReplyBuilder
{
AsyncReply reply;
AsyncReplyBuilder(AsyncReply reply)
@ -64,5 +64,4 @@ namespace Esiur.Core
}
}
}
}

View File

@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncReplyBuilder<T>
{
public class AsyncReplyBuilder<T>
{
AsyncReply<T> reply;
AsyncReplyBuilder(AsyncReply<T> reply)
@ -58,10 +58,10 @@ namespace Esiur.Core
public AsyncReply<T> Task
{
get {
get
{
return reply;
}
}
}
}

View File

@ -33,15 +33,15 @@ using System.Threading;
using System.Runtime.CompilerServices;
using System.Diagnostics;
namespace Esiur.Core
namespace Esiur.Core;
[AsyncMethodBuilder(typeof(AsyncReplyBuilder<>))]
public class AsyncReply<T> : AsyncReply
{
[AsyncMethodBuilder(typeof(AsyncReplyBuilder<>))]
public class AsyncReply<T> : AsyncReply
{
public AsyncReply<T> Then(Action<T> callback)
{
base.Then((x)=>callback((T)x));
base.Then((x) => callback((T)x));
return this;
}
@ -54,7 +54,7 @@ namespace Esiur.Core
public AsyncReply<T> Chunk(Action<T> callback)
{
chunkCallbacks.Add((x)=>callback((T)x));
chunkCallbacks.Add((x) => callback((T)x));
return this;
}
@ -65,7 +65,7 @@ namespace Esiur.Core
}
public AsyncReply()
:base()
: base()
{
}
@ -325,7 +325,7 @@ namespace Esiur.Core
}
/*
public AsyncReply<T> Then(Action<T> callback)
public AsyncReply<T> Then(Action<T> callback)
{
base.Then(new Action<object>(o => callback((T)o)));
return this;
@ -370,10 +370,9 @@ namespace Esiur.Core
*/
*/
}
}

View File

@ -28,10 +28,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Core
namespace Esiur.Core;
public class AsyncReply
{
public class AsyncReply
{
@ -181,5 +181,4 @@ namespace Esiur.Core
tcs.SetResult(result);
this.result = result;
}
}
}

View File

@ -2,11 +2,10 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Core
namespace Esiur.Core;
public enum ErrorType
{
public enum ErrorType
{
Management,
Exception
}
}

View File

@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Core
namespace Esiur.Core;
public enum ExceptionCode : ushort
{
public enum ExceptionCode : ushort
{
HostNotReachable,
AccessDenied,
UserOrTokenNotFound,
@ -41,5 +41,4 @@ namespace Esiur.Core
AlreadyListened,
AlreadyUnlistened,
NotListenable
}
}

View File

@ -2,13 +2,12 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Core
namespace Esiur.Core;
public enum ExceptionLevel
{
public enum ExceptionLevel
{
Code = 0x1,
Message = 0x2,
Source = 0x4,
Trace = 0x8
}
}

View File

@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace Esiur.Core
namespace Esiur.Core;
public interface IAsyncReply<out T>//IAsyncEnumerator<T>
{
public interface IAsyncReply<out T>//IAsyncEnumerator<T>
{
IAsyncReply<T> Then(Action<T> callback);
IAsyncReply<T> Error(Action<AsyncException> callback);
IAsyncReply<T> Progress(Action<ProgressType, int, int> callback);
@ -17,5 +17,4 @@ namespace Esiur.Core
void TriggerChunk(object value);
T Wait();
}
}

View File

@ -27,13 +27,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Core
{
public delegate void DestroyedEvent(object sender);
namespace Esiur.Core;
public interface IDestructible
{
public delegate void DestroyedEvent(object sender);
public interface IDestructible
{
event DestroyedEvent OnDestroy;
void Destroy();
}
}

View File

@ -29,12 +29,11 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Core
namespace Esiur.Core;
public enum LogType
{
public enum LogType
{
Debug,
Warning,
Error,
}
}

View File

@ -2,11 +2,10 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Core
namespace Esiur.Core;
public enum ProgressType
{
public enum ProgressType
{
Execution,
Network,
}
}

View File

@ -30,10 +30,10 @@ using System.Collections;
using Esiur.Core;
using System.Reflection;
namespace Esiur.Data
namespace Esiur.Data;
public class AutoList<T, ST> : IEnumerable<T>, ICollection, ICollection<T>
{
public class AutoList<T, ST> : IEnumerable<T>, ICollection, ICollection<T>
{
private readonly object syncRoot = new object();
private List<T> list = new List<T>();
@ -62,7 +62,7 @@ namespace Esiur.Data
public void Sort()
{
lock(syncRoot)
lock (syncRoot)
list.Sort();
}
@ -310,5 +310,4 @@ namespace Esiur.Data
// lock(syncRoot)
// return Remove(item);
//}
}
}

View File

@ -30,13 +30,13 @@ using Esiur.Misc;
using System.Reflection;
using Esiur.Core;
namespace Esiur.Data
namespace Esiur.Data;
/// <summary>
/// BinaryList holds a list of items to be converted to binary for storage and transmission
/// </summary>
public class BinaryList
{
/// <summary>
/// BinaryList holds a list of items to be converted to binary for storage and transmission
/// </summary>
public class BinaryList
{
private List<byte> list = new List<byte>();
/// <summary>
@ -710,5 +710,4 @@ namespace Esiur.Data
return null;
//
}
}
}

View File

@ -38,10 +38,10 @@ using System.Runtime.CompilerServices;
using System.Collections;
using System.Dynamic;
namespace Esiur.Data
namespace Esiur.Data;
public static class Codec
{
public static class Codec
{
/// <summary>
/// Check if a DataType is an array
/// </summary>
@ -415,7 +415,8 @@ namespace Esiur.Data
}
else
{
connection.GetTemplate((Guid)classId).Then(tmp => {
connection.GetTemplate((Guid)classId).Then(tmp =>
{
ParseVarArray(data, offset, length, connection).Then(ar =>
{
var record = new Record();
@ -425,7 +426,7 @@ namespace Esiur.Data
reply.Trigger(record);
});
}).Error(x=>reply.TriggerError(x));
}).Error(x => reply.TriggerError(x));
}
return reply;
@ -937,7 +938,7 @@ namespace Esiur.Data
return prependLength ? new byte[] { 0, 0, 0, 0 } : new byte[0];
foreach(var r in resources)
foreach (var r in resources)
connection.cache.Add(r, DateTime.UtcNow);
var rt = new BinaryList();
@ -956,7 +957,7 @@ namespace Esiur.Data
else
{
// typed array
rt.AddUInt8((byte)((byte)( tmp.Type == TemplateType.Resource ? ResourceArrayType.Static : ResourceArrayType.Wrapper)
rt.AddUInt8((byte)((byte)(tmp.Type == TemplateType.Resource ? ResourceArrayType.Static : ResourceArrayType.Wrapper)
| (byte)comparsion));
// add type
rt.AddGuid(tmp.ClassId);
@ -1009,7 +1010,7 @@ namespace Esiur.Data
var end = offset + length;
// Is typed array ?
var type = (ResourceArrayType) (data[offset] & 0xF0);
var type = (ResourceArrayType)(data[offset] & 0xF0);
var result = (ResourceComparisonResult)(data[offset++] & 0xF);
@ -1502,7 +1503,7 @@ namespace Esiur.Data
value = (value as DistributedPropertyContext).Method(connection);
//else
}
catch(Exception ex)
catch (Exception ex)
{
Global.Log(ex);
return (DataType.Void, null);
@ -1609,5 +1610,4 @@ namespace Esiur.Data
}
}
}

View File

@ -37,10 +37,10 @@ using Esiur.Data;
using Esiur.Core;
using Esiur.Resource;
namespace Esiur.Data
namespace Esiur.Data;
public static class DC // Data Converter
{
public static class DC // Data Converter
{
public static object CastConvert(object value, Type destinationType)
{
if (value == null)
@ -985,7 +985,6 @@ namespace Esiur.Data
{
return (uint)(date - new DateTime(1970, 1, 1)).TotalSeconds;
}
}
}

View File

@ -28,10 +28,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Data
namespace Esiur.Data;
public enum DataType : byte
{
public enum DataType : byte
{
Void = 0x0,
//Variant,
Bool,
@ -79,10 +78,10 @@ namespace Esiur.Data
RecordArray,
NotModified = 0x7f,
Unspecified = 0xff,
}
}
public static class DataTypeExpansions
{
public static class DataTypeExpansions
{
public static int Size(this DataType t)
{
switch (t)
@ -115,5 +114,4 @@ namespace Esiur.Data
return -1;
}
}
}
}

View File

@ -2,10 +2,9 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Data
{
public interface IRecord
{
namespace Esiur.Data;
public interface IRecord
{
}
}

View File

@ -2,11 +2,10 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Data
namespace Esiur.Data;
public interface IUserType
{
public interface IUserType
{
object Get();
void Set(object value);
}
}

View File

@ -33,11 +33,10 @@ using System.Linq;
using System.Linq.Expressions;
using Esiur.Core;
namespace Esiur.Data
{
namespace Esiur.Data;
public class KeyList<KT, T> : IEnumerable<KeyValuePair<KT, T>>
{
public class KeyList<KT, T> : IEnumerable<KeyValuePair<KT, T>>
{
private readonly object syncRoot = new object();
private Dictionary<KT, T> dic;
@ -227,7 +226,7 @@ namespace Esiur.Data
public KeyList(object owner = null)
{
#if NETSTANDARD
#if NETSTANDARD
removableList = (typeof(IDestructible).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()));
#else
removableList = (typeof(IDestructible).IsAssignableFrom(typeof(T)));
@ -240,5 +239,4 @@ namespace Esiur.Data
else
dic = new Dictionary<KT, T>();
}
}
}

View File

@ -28,10 +28,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Data
namespace Esiur.Data;
public class NotModified
{
public class NotModified
{
}
}

View File

@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Data
namespace Esiur.Data;
public class PropertyValue
{
public class PropertyValue
{
/// <summary>
/// Get or set the value.
/// </summary>
@ -31,5 +31,4 @@ namespace Esiur.Data
Age = age;
Date = date;
}
}
}

View File

@ -2,10 +2,8 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Data
namespace Esiur.Data;
public class Record : KeyList<string, object>, IRecord
{
public class Record: KeyList<string, object>, IRecord
{
}
}

View File

@ -2,13 +2,12 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Data
namespace Esiur.Data;
public enum RecordComparisonResult : byte
{
public enum RecordComparisonResult : byte
{
Null,
Record,
RecordSameType,
Same
}
}

View File

@ -2,12 +2,11 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Data
namespace Esiur.Data;
public enum ResourceArrayType
{
public enum ResourceArrayType
{
Dynamic = 0x0,
Static = 0x10,
Wrapper = 0x20,
}
}

View File

@ -2,13 +2,12 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Data
namespace Esiur.Data;
public enum ResourceComparisonResult
{
public enum ResourceComparisonResult
{
Null, // null
Distributed, // resource is distributed
Local, // resource is local
Same, // Same as previous
}
}

View File

@ -1,5 +1,4 @@
using Esiur.Net.IIP;
using Esiur.Resource;

/*
Copyright (c) 2017-2021 Ahmed Kh. Zamil
@ -24,22 +23,24 @@ SOFTWARE.
*/
using Esiur.Net.IIP;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Esiur.Data
namespace Esiur.Data;
class ResourceJsonConverter : JsonConverter<IResource>
{
class ResourceJsonConverter : JsonConverter<IResource>
{
public override IResource Read(
ref Utf8JsonReader reader,
Type typeToConvert,
JsonSerializerOptions options)
{
return (IResource)JsonSerializer.Deserialize(ref reader,typeof(IResource), options);
return (IResource)JsonSerializer.Deserialize(ref reader, typeof(IResource), options);
}
@ -60,7 +61,7 @@ namespace Esiur.Data
writer.WritePropertyName(options.PropertyNamingPolicy?.ConvertName(pt.Name) ?? pt.Name);
if (rt is IResource)
JsonSerializer.Serialize(writer, (IResource) rt, options);
JsonSerializer.Serialize(writer, (IResource)rt, options);
else
JsonSerializer.Serialize(writer, rt, options);
}
@ -68,11 +69,11 @@ namespace Esiur.Data
writer.WriteEndObject();
}
}
}
public class DoubleJsonConverter : JsonConverter<double>
{
public class DoubleJsonConverter : JsonConverter<double>
{
public override double Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.String && reader.GetString() == "NaN")
@ -94,6 +95,5 @@ namespace Esiur.Data
writer.WriteNumberValue(value);
}
}
}
}

View File

@ -30,10 +30,10 @@ using System.Collections;
using Esiur.Core;
using System.Reflection;
namespace Esiur.Data
namespace Esiur.Data;
public class ResourceList<T, ST> : IEnumerable<T>, ICollection, ICollection<T>
{
public class ResourceList<T, ST> : IEnumerable<T>, ICollection, ICollection<T>
{
private readonly object syncRoot = new object();
private List<T> list = new List<T>();
@ -270,5 +270,4 @@ namespace Esiur.Data
{
return list.Remove(item);
}
}
}

View File

@ -31,11 +31,11 @@ using System.Text;
using System.Reflection;
using System.Linq;
namespace Esiur.Data
{
namespace Esiur.Data;
public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
{
public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
{
//private List<string> m_keys = new List<string>();
//private List<string> m_values = new List<string>();
@ -61,7 +61,7 @@ namespace Esiur.Data
if (!allowMultiple)
{
foreach(var kv in m_Variables)
foreach (var kv in m_Variables)
{
if (kv.Key.ToLower() == key)
{
@ -158,14 +158,14 @@ namespace Esiur.Data
public void RemoveAll(string Key)
{
while (Remove(Key)){}
while (Remove(Key)) { }
}
public bool Remove(string Key)
{
var key = Key.ToLower();
foreach(var kv in m_Variables)
foreach (var kv in m_Variables)
{
if (kv.Key.ToLower() == key)
{
@ -216,5 +216,4 @@ namespace Esiur.Data
// m_Server = Server;
//}
}
}

View File

@ -34,10 +34,10 @@ using Esiur.Core;
using System.Reflection;
using System.Dynamic;
namespace Esiur.Data
namespace Esiur.Data;
public class Structure : IEnumerable<KeyValuePair<string, object>>
{
public class Structure : IEnumerable<KeyValuePair<string, object>>
{
public struct StructureMetadata
{
@ -106,7 +106,7 @@ namespace Esiur.Data
{
var st = new Structure();
var pi = type.GetTypeInfo().GetProperties().Where(x=>x.CanRead);
var pi = type.GetTypeInfo().GetProperties().Where(x => x.CanRead);
foreach (var p in pi)
st[p.Name] = p.GetValue(obj);
@ -177,5 +177,4 @@ namespace Esiur.Data
}
}
}
}

View File

@ -2,14 +2,13 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Data
namespace Esiur.Data;
public enum StructureComparisonResult : byte
{
public enum StructureComparisonResult : byte
{
Null,
Structure,
StructureSameKeys,
StructureSameTypes,
Same
}
}

View File

@ -4,20 +4,20 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Description>Distributed Resources Platform</Description>
<Copyright>Ahmed Kh. Zamil</Copyright>
<PackageLicenseUrl>https://github.com/Esiur/Esiur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.8.8</Version>
<Version>2.0.0-alpha</Version>
<RepositoryUrl>https://github.com/esiur/esiur-dotnet</RepositoryUrl>
<Authors>Ahmed Kh. Zamil</Authors>
<AssemblyVersion>1.8.8.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<Company>Esiur Foundation</Company>
<FileVersion>1.8.8.0</FileVersion>
<FileVersion>2.0.0.0</FileVersion>
<AssemblyName>Esiur</AssemblyName>
<RootNamespace>Esiur</RootNamespace>
<PackageId>Esiur</PackageId>
<Product>Esiur</Product>
<LangVersion>9.0</LangVersion>
<LangVersion>latest</LangVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -79,10 +79,13 @@
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<!-- Package the Newtonsoft.Json dependency alongside the generator assembly -->
<None Include="$(PkgSystem_Text_Json)\lib\netstandard2.0\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="Tools/*" Pack="true" PackagePath="tools/" />
</ItemGroup>
<ItemGroup>
<None Include="LICENSE" Pack="true" PackagePath="">
</None>
</ItemGroup>
</Project>

21
Esiur/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017-2021 Esiur Foundation, Ahmed Kh. Zamil.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -42,10 +42,9 @@ using System.Text.Json;
using Esiur.Resource;
using System.Text.Json.Serialization;
namespace Esiur.Misc
namespace Esiur.Misc;
public static class Global
{
public static class Global
{
private static KeyList<string, object> variables = new KeyList<string, object>();
// private static Hashtable m_Cached = new Hashtable();
//internal static bool SystemIsWorking = false;
@ -66,7 +65,8 @@ namespace Esiur.Misc
try
{
return JsonSerializer.Serialize(resource, Global.SerializeOptions);
}catch (Exception ex)
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return "{}";
@ -86,7 +86,7 @@ namespace Esiur.Misc
public static string Version { get; }= FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
public static string Version { get; } = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
//FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
// string version = fvi.FileVersion;
@ -184,16 +184,16 @@ namespace Esiur.Misc
Console.WriteLine(k + ":" + Counters[k]);
}
}
// Encoding ANSI = Encoding.GetEncoding(1252);
// Encoding ANSI = Encoding.GetEncoding(1252);
/*
public static Hashtable Cached
{
public static Hashtable Cached
{
get
{
return m_Cached;
}
}*/
}*/
/*
public static string ByteArrayToMAC(byte[] array)
@ -486,5 +486,4 @@ namespace Esiur.Misc
//{
// Expression.IndexOf(
//}
}
}

View File

@ -31,10 +31,9 @@ using Esiur.Data;
using Esiur.Net.Packets;
using Esiur.Resource;
namespace Esiur.Net.DataLink
namespace Esiur.Net.DataLink;
public abstract class PacketFilter : IResource
{
public abstract class PacketFilter : IResource
{
public Instance Instance
{
@ -52,5 +51,4 @@ namespace Esiur.Net.DataLink
{
OnDestroy?.Invoke(this);
}
}
}

View File

@ -32,10 +32,9 @@ using System.Runtime.InteropServices;
using Esiur.Net.Packets;
using Esiur.Resource;
namespace Esiur.Net.DataLink
namespace Esiur.Net.DataLink;
public class PacketServer : IResource
{
public class PacketServer:IResource
{
List<PacketSource> sources = new List<PacketSource>();
List<PacketFilter> filters = new List<PacketFilter>();
@ -106,7 +105,7 @@ namespace Esiur.Net.DataLink
}
}
return new AsyncReply<bool>( true);
return new AsyncReply<bool>(true);
}
void PacketReceived(Packet Packet)
@ -119,5 +118,4 @@ namespace Esiur.Net.DataLink
}
}
}
}
}

View File

@ -30,10 +30,9 @@ using System.Text;
using Esiur.Core;
using Esiur.Resource;
namespace Esiur.Net.DataLink
namespace Esiur.Net.DataLink;
public abstract class PacketSource : IResource
{
public abstract class PacketSource: IResource
{
public delegate void NewPacket(Packet Packet);
public abstract event NewPacket OnNewPacket;
public event DestroyedEvent OnDestroy;
@ -91,5 +90,4 @@ namespace Esiur.Net.DataLink
{
get;
}
}
}

View File

@ -38,10 +38,9 @@ using Esiur.Misc;
using System.Security.Cryptography;
using Esiur.Core;
namespace Esiur.Net.HTTP
namespace Esiur.Net.HTTP;
public class HTTPConnection : NetworkConnection
{
public class HTTPConnection : NetworkConnection
{
@ -416,7 +415,8 @@ namespace Esiur.Net.HTTP
{
Close();
}
finally {
finally
{
}
@ -433,5 +433,4 @@ namespace Esiur.Net.HTTP
{
// do nothing
}
}
}

View File

@ -35,11 +35,10 @@ using Esiur.Data;
using Esiur.Core;
using Esiur.Resource;
namespace Esiur.Net.HTTP
{
namespace Esiur.Net.HTTP;
public abstract class HTTPFilter : IResource
{
public abstract class HTTPFilter : IResource
{
public Instance Instance
{
get;
@ -78,5 +77,4 @@ namespace Esiur.Net.HTTP
{
OnDestroy?.Invoke(this);
}
}
}

View File

@ -39,11 +39,10 @@ using Esiur.Net.Packets;
using System.Security.Cryptography.X509Certificates;
using Esiur.Resource;
namespace Esiur.Net.HTTP
namespace Esiur.Net.HTTP;
public class HTTPServer : NetworkServer<HTTPConnection>, IResource
{
public class HTTPServer : NetworkServer<HTTPConnection>, IResource
{
Dictionary<string, HTTPSession> sessions= new Dictionary<string, HTTPSession>();
Dictionary<string, HTTPSession> sessions = new Dictionary<string, HTTPSession>();
HTTPFilter[] filters = new HTTPFilter[0];
public Instance Instance
@ -296,5 +295,4 @@ namespace Esiur.Net.HTTP
//{
// cServer.StopServer();
//}
}
}

View File

@ -35,10 +35,9 @@ using Esiur.Data;
using Esiur.Misc;
using Esiur.Core;
namespace Esiur.Net.HTTP
namespace Esiur.Net.HTTP;
public class HTTPSession : IDestructible //<T> where T : TClient
{
public class HTTPSession : IDestructible //<T> where T : TClient
{
public delegate void SessionModifiedEvent(HTTPSession session, string key, object oldValue, object newValue);
public delegate void SessionEndedEvent(HTTPSession session);
@ -125,6 +124,5 @@ namespace Esiur.Net.HTTP
{
get { return lastAction; }
}
}
}

View File

@ -6,10 +6,9 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.HTTP
namespace Esiur.Net.HTTP;
public class IIPoHTTP : HTTPFilter
{
public class IIPoHTTP : HTTPFilter
{
[Attribute]
EntryPoint EntryPoint { get; set; }
@ -35,5 +34,4 @@ namespace Esiur.Net.HTTP
{
return new AsyncReply<bool>(true);
}
}
}

View File

@ -32,10 +32,9 @@ using Esiur.Net.IIP;
using Esiur.Net.Sockets;
using Esiur.Core;
namespace Esiur.Net.HTTP
namespace Esiur.Net.HTTP;
public class IIPoWS : HTTPFilter
{
public class IIPoWS: HTTPFilter
{
[Attribute]
public DistributedServer Server
{
@ -69,7 +68,7 @@ namespace Esiur.Net.HTTP
return new AsyncReply<bool>(true);
}
return new AsyncReply<bool>( false);
return new AsyncReply<bool>(false);
/*
if (sender.Request.Filename.StartsWith("/iip/"))
@ -93,9 +92,9 @@ namespace Esiur.Net.HTTP
//httpServer.Connections.Remove(sender);
var iipConnection = new DistributedConnection();
// iipConnection.OnReady += IipConnection_OnReady;
// iipConnection.OnReady += IipConnection_OnReady;
// iipConnection.Server = iipServer;
// iipConnection.Assign(wsSocket);
// iipConnection.Assign(wsSocket);
iipServer.AddConnection(iipConnection);
iipConnection.Assign(wsSocket);
@ -119,7 +118,5 @@ namespace Esiur.Net.HTTP
{
return new AsyncReply<bool>(true);
}
}
}

View File

@ -40,10 +40,9 @@ using System.Linq;
using System.Diagnostics;
using static Esiur.Net.Packets.IIPPacket;
namespace Esiur.Net.IIP
namespace Esiur.Net.IIP;
public partial class DistributedConnection : NetworkConnection, IStore
{
public partial class DistributedConnection : NetworkConnection, IStore
{
public delegate void ReadyEvent(DistributedConnection sender);
public delegate void ErrorEvent(DistributedConnection sender, byte errorCode, string errorMessage);
@ -1050,7 +1049,7 @@ namespace Esiur.Net.IIP
var host = Instance.Name.Split(':');
var address = host[0];
var port = host.Length > 1 ? ushort.Parse(host[1]) : (ushort) 10518;
var port = host.Length > 1 ? ushort.Parse(host[1]) : (ushort)10518;
// assign domain from hostname if not provided
var domain = Domain != null ? Domain : address;
@ -1277,5 +1276,4 @@ namespace Esiur.Net.IIP
}
*/
}
}

View File

@ -38,10 +38,10 @@ using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography.X509Certificates;
namespace Esiur.Net.IIP
namespace Esiur.Net.IIP;
partial class DistributedConnection
{
partial class DistributedConnection
{
KeyList<uint, DistributedResource> resources = new KeyList<uint, DistributedResource>();
KeyList<uint, AsyncReply<DistributedResource>> resourceRequests = new KeyList<uint, AsyncReply<DistributedResource>>();
KeyList<Guid, AsyncReply<TypeTemplate>> templateRequests = new KeyList<Guid, AsyncReply<TypeTemplate>>();
@ -2623,5 +2623,4 @@ namespace Esiur.Net.IIP
.AddUInt8Array(Codec.Compose(args, this, true))
.Done();
}
}
}

View File

@ -2,10 +2,9 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.IIP
namespace Esiur.Net.IIP;
public class DistributedPropertyContext
{
public class DistributedPropertyContext
{
public object Value { get; private set; }
public DistributedConnection Connection { get; private set; }
public Func<DistributedConnection, object> Method { get; private set; }
@ -23,5 +22,4 @@ namespace Esiur.Net.IIP
public static implicit operator DistributedPropertyContext(Func<DistributedConnection, object> method)
=> new DistributedPropertyContext(method);
}
}

View File

@ -42,12 +42,11 @@ using System.Threading.Tasks;
using Esiur.Resource;
using Esiur.Resource.Template;
namespace Esiur.Net.IIP
{
namespace Esiur.Net.IIP;
//[System.Runtime.InteropServices.ComVisible(true)]
public class DistributedResource : DynamicObject, IResource
{
//[System.Runtime.InteropServices.ComVisible(true)]
public class DistributedResource : DynamicObject, IResource
{
/// <summary>
/// Raised when the distributed resource is destroyed.
@ -502,5 +501,4 @@ namespace Esiur.Net.IIP
// do nothing.
return new AsyncReply<bool>(true);
}
}
}

View File

@ -28,7 +28,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Net.IIP
{
public delegate void DistributedResourceEvent(DistributedResource sender, object argument);
}
namespace Esiur.Net.IIP;
public delegate void DistributedResourceEvent(DistributedResource sender, object argument);

View File

@ -28,10 +28,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Net.IIP
namespace Esiur.Net.IIP;
public class DistributedResourceQueueItem
{
public class DistributedResourceQueueItem
{
public enum DistributedResourceQueueItemType
{
Propery,
@ -69,5 +68,4 @@ namespace Esiur.Net.IIP
{
get { return value; }
}
}
}

View File

@ -35,10 +35,9 @@ using System.Net;
using Esiur.Resource;
using Esiur.Security.Membership;
namespace Esiur.Net.IIP
namespace Esiur.Net.IIP;
public class DistributedServer : NetworkServer<DistributedConnection>, IResource
{
public class DistributedServer : NetworkServer<DistributedConnection>, IResource
{
[Attribute]
public string IP
{
@ -173,5 +172,4 @@ namespace Esiur.Net.IIP
}
}
}

View File

@ -28,11 +28,9 @@ using System.Text;
using Esiur.Net.Sockets;
using Esiur.Security.Authority;
namespace Esiur.Net.IIP
namespace Esiur.Net.IIP;
public class DistributedSession : NetworkSession
{
public class DistributedSession : NetworkSession
{
public Source Source { get; set; }
public Authentication Authentication { get; set; }
}
}

View File

@ -29,12 +29,11 @@ using Esiur.Data;
using Esiur.Resource;
using Esiur.Resource.Template;
namespace Esiur.Net.IIP
namespace Esiur.Net.IIP;
public abstract class EntryPoint : Esiur.Resource.Resource
{
public abstract class EntryPoint : Esiur.Resource.Resource
{
public abstract AsyncReply<IResource[]> Query(string path, DistributedConnection sender);
protected abstract override bool Create();
}
}

View File

@ -2,14 +2,13 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net
namespace Esiur.Net;
public interface INetworkReceiver<T>
{
public interface INetworkReceiver<T>
{
void NetworkClose(T sender);
void NetworkReceive(T sender, NetworkBuffer buffer);
//void NetworkError(T sender);
void NetworkConnect(T sender);
}
}

View File

@ -29,10 +29,9 @@ using System.Text;
using Esiur.Data;
using Esiur.Misc;
namespace Esiur.Net
namespace Esiur.Net;
public class NetworkBuffer
{
public class NetworkBuffer
{
byte[] data;
uint neededDataLength = 0;
@ -141,7 +140,7 @@ namespace Esiur.Net
//if (data.Length > 0)
// Console.WriteLine();
lock(syncLock)
lock (syncLock)
DC.Append(ref data, src, offset, length);
}
@ -204,5 +203,4 @@ namespace Esiur.Net
return rt;
}
}
}
}

View File

@ -36,10 +36,9 @@ using Esiur.Data;
using Esiur.Net.Sockets;
using Esiur.Resource;
namespace Esiur.Net
namespace Esiur.Net;
public abstract class NetworkConnection : IDestructible, INetworkReceiver<ISocket>// <TS>: IResource where TS : NetworkSession
{
public abstract class NetworkConnection: IDestructible, INetworkReceiver<ISocket>// <TS>: IResource where TS : NetworkSession
{
private Sockets.ISocket sock;
// private bool connected;
@ -363,5 +362,4 @@ namespace Esiur.Net
// Receiver?.NetworkConnect(this);
//throw new NotImplementedException();
//}
}
}

View File

@ -33,14 +33,13 @@ using Esiur.Resource;
using System.Threading.Tasks;
using System.Diagnostics;
namespace Esiur.Net
{
namespace Esiur.Net;
public abstract class NetworkServer<TConnection> : IDestructible where TConnection : NetworkConnection, new()
{
public abstract class NetworkServer<TConnection> : IDestructible where TConnection : NetworkConnection, new()
{
//private bool isRunning;
private Sockets.ISocket listener;
public AutoList<TConnection, NetworkServer<TConnection>> Connections { get; private set; }
public AutoList<TConnection, NetworkServer<TConnection>> Connections { get; internal set; }
private Thread thread;
@ -306,6 +305,5 @@ namespace Esiur.Net
Stop();
listener = null;
}
}
}

View File

@ -35,10 +35,9 @@ using Esiur.Data;
using Esiur.Misc;
using Esiur.Core;
namespace Esiur.Net
namespace Esiur.Net;
public class NetworkSession : IDestructible //<T> where T : TClient
{
public class NetworkSession:IDestructible //<T> where T : TClient
{
public delegate void SessionModifiedEvent(NetworkSession session, string key, object oldValue, object newValue);
public delegate void SessionEndedEvent(NetworkSession session);
@ -66,7 +65,7 @@ namespace Esiur.Net
creation = DateTime.Now;
}
internal void Set(string id, int timeout )
internal void Set(string id, int timeout)
{
//modified = sessionModifiedEvent;
//ended = sessionEndEvent;
@ -125,6 +124,5 @@ namespace Esiur.Net
{
get { return lastAction; }
}
}
}

View File

@ -32,12 +32,11 @@ using Esiur.Data;
using System.Net;
using System.Text.Json.Serialization;
namespace Esiur.Net.Packets
namespace Esiur.Net.Packets;
public class HTTPRequestPacket : Packet
{
public class HTTPRequestPacket : Packet
{
public enum HTTPMethod:byte
public enum HTTPMethod : byte
{
GET,
POST,
@ -111,7 +110,7 @@ namespace Esiur.Net.Packets
if (data[i] == '\r' && data[i + 1] == '\n'
&& data[i + 2] == '\r' && data[i + 3] == '\n')
{
sLines = Encoding.ASCII.GetString(data, (int)offset,(int)( i - offset)).Split(new string[] { "\r\n" },
sLines = Encoding.ASCII.GetString(data, (int)offset, (int)(i - offset)).Split(new string[] { "\r\n" },
StringSplitOptions.None);
headerSize = i + 4;
@ -313,6 +312,4 @@ namespace Esiur.Net.Packets
return headerSize;
}
}
}

View File

@ -28,10 +28,9 @@ using System.Text;
using Esiur.Misc;
using Esiur.Data;
namespace Esiur.Net.Packets
namespace Esiur.Net.Packets;
public class HTTPResponsePacket : Packet
{
public class HTTPResponsePacket : Packet
{
public enum ComposeOptions : int
{
@ -43,7 +42,7 @@ namespace Esiur.Net.Packets
public enum ResponseCode : int
{
Switching= 101,
Switching = 101,
OK = 200,
Created = 201,
Accepted = 202,
@ -300,5 +299,4 @@ namespace Esiur.Net.Packets
return 0;
}
}
}
}

View File

@ -31,10 +31,9 @@ using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Net.Packets
namespace Esiur.Net.Packets;
class IIPAuthPacket : Packet
{
class IIPAuthPacket : Packet
{
public enum IIPAuthPacketCommand : byte
{
Action = 0,
@ -411,5 +410,5 @@ namespace Esiur.Net.Packets
}
}
}

View File

@ -32,10 +32,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Net.Packets
namespace Esiur.Net.Packets;
class IIPPacket : Packet
{
class IIPPacket : Packet
{
public override string ToString()
{
@ -826,5 +825,4 @@ namespace Esiur.Net.Packets
return offset - originalOffset;
}
}
}

View File

@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.Packets
namespace Esiur.Net.Packets;
struct IIPPacketAttachInfo
{
struct IIPPacketAttachInfo
{
public string Link;
public ulong Age;
public byte[] Content;
@ -18,5 +18,4 @@ namespace Esiur.Net.Packets
Content = content;
Link = link;
}
}
}

View File

@ -38,10 +38,9 @@ using Esiur.Net.DataLink;
using System.Net.NetworkInformation;
using Esiur.Data;
namespace Esiur.Net.Packets
namespace Esiur.Net.Packets;
internal static class Functions
{
internal static class Functions
{
public static void AddData(ref byte[] dest, byte[] src)
{
int I = 0;
@ -173,10 +172,10 @@ namespace Esiur.Net.Packets
//BRight = (I << 24) >> 24;
}
}
}
public class PosixTime
{
public class PosixTime
{
ulong seconds;
ulong microseconds;
@ -190,10 +189,10 @@ namespace Esiur.Net.Packets
{
return seconds + "." + microseconds;
}
}
}
public class Packet
{
public class Packet
{
//public EtherServer2.EthernetSource Source;
public PacketSource Source;
@ -361,9 +360,8 @@ namespace Esiur.Net.Packets
return leaf;
}
}
}
}
/************************************ EOF *************************************/

View File

@ -29,10 +29,9 @@ using System.Text;
using Esiur.Misc;
using Esiur.Data;
namespace Esiur.Net.Packets
namespace Esiur.Net.Packets;
public class WebsocketPacket : Packet
{
public class WebsocketPacket : Packet
{
public enum WSOpcode : byte
{
ContinuationFrame = 0x0, // %x0 denotes a continuation frame
@ -146,7 +145,7 @@ namespace Esiur.Net.Packets
//Console.WriteLine("stage 2 " + needed);
return length - needed;
}
PayloadLength = data.GetUInt16( offset);
PayloadLength = data.GetUInt16(offset);
offset += 2;
}
else if (PayloadLength == 127)
@ -213,5 +212,4 @@ namespace Esiur.Net.Packets
throw ex;
}
}
}
}

View File

@ -4,10 +4,10 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net
namespace Esiur.Net;
public class SendList : BinaryList
{
public class SendList : BinaryList
{
NetworkConnection connection;
AsyncReply<object[]> reply;
@ -22,5 +22,4 @@ namespace Esiur.Net
connection.Send(this.ToArray());
return reply;
}
}
}

View File

@ -36,14 +36,13 @@ using System.Collections.Concurrent;
using Esiur.Resource;
using Esiur.Core;
namespace Esiur.Net.Sockets
{
//public delegate void ISocketReceiveEvent(NetworkBuffer buffer);
//public delegate void ISocketConnectEvent();
//public delegate void ISocketCloseEvent();
namespace Esiur.Net.Sockets;
//public delegate void ISocketReceiveEvent(NetworkBuffer buffer);
//public delegate void ISocketConnectEvent();
//public delegate void ISocketCloseEvent();
public interface ISocket : IDestructible
{
public interface ISocket : IDestructible
{
SocketState State { get; }
//event ISocketReceiveEvent OnReceive;
@ -70,5 +69,4 @@ namespace Esiur.Net.Sockets
void Hold();
void Unhold();
}
}

View File

@ -37,10 +37,9 @@ using Esiur.Resource;
using System.Threading.Tasks;
using Esiur.Data;
namespace Esiur.Net.Sockets
namespace Esiur.Net.Sockets;
public class SSLSocket : ISocket
{
public class SSLSocket : ISocket
{
public INetworkReceiver<ISocket> Receiver { get; set; }
@ -551,5 +550,5 @@ namespace Esiur.Net.Sockets
return null;
}
}
}
}

View File

@ -28,15 +28,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Net.Sockets
namespace Esiur.Net.Sockets;
public enum SocketState
{
public enum SocketState
{
Initial,
Listening,
Connecting,
Established,
Closed,
//Terminated
}
}

View File

@ -35,10 +35,9 @@ using Esiur.Resource;
using System.Threading.Tasks;
using Esiur.Data;
namespace Esiur.Net.Sockets
namespace Esiur.Net.Sockets;
public class TCPSocket : ISocket
{
public class TCPSocket : ISocket
{
public INetworkReceiver<ISocket> Receiver { get; set; }
Socket sock;
@ -655,5 +654,4 @@ namespace Esiur.Net.Sockets
return rt;
}
}
}
}

View File

@ -36,10 +36,9 @@ using Esiur.Resource;
using Esiur.Data;
using System.Globalization;
namespace Esiur.Net.Sockets
namespace Esiur.Net.Sockets;
public class WSocket : ISocket, INetworkReceiver<ISocket>
{
public class WSocket : ISocket, INetworkReceiver<ISocket>
{
WebsocketPacket pkt_receive = new WebsocketPacket();
WebsocketPacket pkt_send = new WebsocketPacket();
@ -357,5 +356,4 @@ namespace Esiur.Net.Sockets
{
Receiver?.NetworkConnect(this);
}
}
}

View File

@ -32,9 +32,9 @@ using System.Collections;
using Esiur.Misc;
using Esiur.Data;
namespace Esiur.Net.TCP
namespace Esiur.Net.TCP;
public class TCPConnection : NetworkConnection
{
public class TCPConnection:NetworkConnection {
private KeyList<string, object> variables = new KeyList<string, object>();
@ -62,5 +62,4 @@ namespace Esiur.Net.TCP
{
// do nothing
}
}
}

View File

@ -32,10 +32,10 @@ using Esiur.Net.Sockets;
using Esiur.Core;
using Esiur.Resource;
namespace Esiur.Net.TCP
namespace Esiur.Net.TCP;
public abstract class TCPFilter : IResource
{
public abstract class TCPFilter: IResource
{
public Instance Instance
{
get;
@ -62,5 +62,4 @@ namespace Esiur.Net.TCP
{
OnDestroy?.Invoke(this);
}
}
}

View File

@ -34,10 +34,9 @@ using Esiur.Core;
using System.Net;
using Esiur.Resource;
namespace Esiur.Net.TCP
namespace Esiur.Net.TCP;
public class TCPServer : NetworkServer<TCPConnection>, IResource
{
public class TCPServer : NetworkServer<TCPConnection>, IResource
{
[Attribute]
public string IP
@ -152,5 +151,4 @@ namespace Esiur.Net.TCP
}
}
}
}

View File

@ -28,10 +28,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Net.TCP
namespace Esiur.Net.TCP;
public class TCPSession : NetworkSession
{
public class TCPSession : NetworkSession
{
}
}

View File

@ -32,10 +32,9 @@ using Esiur.Data;
using Esiur.Core;
using Esiur.Resource;
namespace Esiur.Net.UDP
namespace Esiur.Net.UDP;
public abstract class UDPFilter : IResource
{
public abstract class UDPFilter : IResource
{
public Instance Instance
{
get;
@ -53,5 +52,4 @@ namespace Esiur.Net.UDP
{
OnDestroy?.Invoke(this);
}
}
}

View File

@ -33,16 +33,15 @@ using Esiur.Misc;
using Esiur.Resource;
using Esiur.Core;
namespace Esiur.Net.UDP
{
namespace Esiur.Net.UDP;
/* public class IIPConnection
{
/* public class IIPConnection
{
public EndPoint SenderPoint;
public
}*/
public class UDPServer : IResource
{
}*/
public class UDPServer : IResource
{
Thread receiver;
UdpClient udp;
UDPFilter[] filters = new UDPFilter[0];
@ -200,5 +199,4 @@ namespace Esiur.Net.UDP
return true;
}
}
}

View File

@ -14,11 +14,11 @@ using Esiur.Data;
using System.IO;
using Esiur.Core;
namespace Esiur.Proxy
namespace Esiur.Proxy;
[Generator]
public class ResourceGenerator : ISourceGenerator
{
[Generator]
public class ResourceGenerator : ISourceGenerator
{
private KeyList<string, TypeTemplate[]> cache = new();
// private List<string> inProgress = new();
@ -163,7 +163,7 @@ public virtual void Destroy() {{ OnDestroy?.Invoke(this); }}
foreach (var f in ci.Fields)
{
var givenName = f.GetAttributes().Where(x=>x.AttributeClass.Name == "PublicAttribute").FirstOrDefault()?.ConstructorArguments.FirstOrDefault().Value;
var givenName = f.GetAttributes().Where(x => x.AttributeClass.Name == "PublicAttribute").FirstOrDefault()?.ConstructorArguments.FirstOrDefault().Value;
var fn = f.Name;
var pn = givenName ?? fn.Substring(0, 1).ToUpper() + fn.Substring(1);
@ -181,11 +181,10 @@ public virtual void Destroy() {{ OnDestroy?.Invoke(this); }}
context.AddSource(ci.Name + ".Generated.cs", code);
}
catch (Exception ex)
catch //(Exception ex)
{
//System.IO.File.AppendAllText("c:\\gen\\error.log", ci.Name + " " + ex.ToString() + "\r\n");
}
}
}
}
}

View File

@ -4,10 +4,9 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Proxy
namespace Esiur.Proxy;
public struct ResourceGeneratorClassInfo
{
public struct ResourceGeneratorClassInfo
{
public string Name { get; set; }
public bool HasInterface { get; set; }
@ -17,5 +16,4 @@ namespace Esiur.Proxy
public ClassDeclarationSyntax ClassDeclaration { get; set; }
}
}

View File

@ -3,11 +3,9 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Proxy
namespace Esiur.Proxy;
public struct ResourceGeneratorFieldInfo
{
public struct ResourceGeneratorFieldInfo
{
public IFieldSymbol FieldSymbol { get; set; }
public string[] Attributes { get; set; }
}
}

View File

@ -6,14 +6,13 @@ using System.Diagnostics;
using System.Linq;
using System.Text;
namespace Esiur.Proxy
namespace Esiur.Proxy;
public class ResourceGeneratorReceiver : ISyntaxContextReceiver
{
public class ResourceGeneratorReceiver : ISyntaxContextReceiver
{
public Dictionary<string, ResourceGeneratorClassInfo> Classes { get; } = new();
public List<string> Imports { get; } = new ();
public List<string> Imports { get; } = new();
public void OnVisitSyntaxNode(GeneratorSyntaxContext context)
{
@ -74,7 +73,8 @@ namespace Esiur.Proxy
c.HasInterface = cls.Interfaces.Any(x => x.ToDisplayString() == "Esiur.Resource.IResource");
if (!c.HasTrigger)
c.HasTrigger = hasTrigger;
} else
}
else
{
Classes.Add(fullName, new ResourceGeneratorClassInfo()
{
@ -92,6 +92,5 @@ namespace Esiur.Proxy
}
}
}
}
}

View File

@ -7,10 +7,9 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Text;
namespace Esiur.Proxy
namespace Esiur.Proxy;
public static class ResourceProxy
{
public static class ResourceProxy
{
static Dictionary<Type, Type> cache = new Dictionary<Type, Type>();
#if NETSTANDARD
@ -34,14 +33,14 @@ namespace Esiur.Proxy
else
return type;
// if (type.FullName.Contains("Esiur.Proxy.T"))
//#if NETSTANDARD
// return type.GetTypeInfo().BaseType;
//#else
// return type.BaseType;
//#endif
// else
// return type;
// if (type.FullName.Contains("Esiur.Proxy.T"))
//#if NETSTANDARD
// return type.GetTypeInfo().BaseType;
//#else
// return type.BaseType;
//#endif
// else
// return type;
}
public static Type GetProxy(Type type)
@ -251,5 +250,4 @@ namespace Esiur.Proxy
*/
}
}
}

View File

@ -10,10 +10,9 @@ using Esiur.Resource;
using Esiur.Net.IIP;
using System.Diagnostics;
namespace Esiur.Proxy
namespace Esiur.Proxy;
public static class TemplateGenerator
{
public static class TemplateGenerator
{
internal static Regex urlRegex = new Regex(@"^(?:([\S]*)://([^/]*)/?)");
internal static string GenerateRecord(TypeTemplate template, TypeTemplate[] templates)
@ -46,9 +45,9 @@ namespace Esiur.Proxy
{
if (templateDataType.Type == DataType.Resource)
return templates.First(x => x.ClassId == templateDataType.TypeGuid && (x.Type == TemplateType.Resource || x.Type == TemplateType.Wrapper )).ClassName;
return templates.First(x => x.ClassId == templateDataType.TypeGuid && (x.Type == TemplateType.Resource || x.Type == TemplateType.Wrapper)).ClassName;
else if (templateDataType.Type == DataType.ResourceArray)
return templates.First(x => x.ClassId == templateDataType.TypeGuid && (x.Type == TemplateType.Resource || x.Type == TemplateType.Wrapper )).ClassName + "[]";
return templates.First(x => x.ClassId == templateDataType.TypeGuid && (x.Type == TemplateType.Resource || x.Type == TemplateType.Wrapper)).ClassName + "[]";
else if (templateDataType.Type == DataType.Record)
return templates.First(x => x.ClassId == templateDataType.TypeGuid && x.Type == TemplateType.Record).ClassName;
else if (templateDataType.Type == DataType.RecordArray)
@ -96,7 +95,7 @@ namespace Esiur.Proxy
return name;
}
public static string GetTemplate(string url, string dir = null, string username= null, string password = null)
public static string GetTemplate(string url, string dir = null, string username = null, string password = null)
{
try
{
@ -106,7 +105,7 @@ namespace Esiur.Proxy
var path = urlRegex.Split(url);
var con = Warehouse.Get<DistributedConnection>(path[1] + "://" + path[2],
!string.IsNullOrEmpty( username) && !string.IsNullOrEmpty( password) ? new { Username = username, Password = password } : null
!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) ? new { Username = username, Password = password } : null
).Wait(20000);
if (con == null)
@ -162,7 +161,7 @@ namespace Esiur.Proxy
return tempDir.FullName;
}
catch(Exception ex)
catch (Exception ex)
{
//File.WriteAllText("C:\\gen\\gettemplate.err", ex.ToString());
throw ex;
@ -234,5 +233,4 @@ namespace Esiur.Proxy
return rt.ToString();
}
}
}

Some files were not shown because too many files have changed in this diff Show More