2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-05-06 11:32:59 +00:00
This commit is contained in:
Ahmed Zamil 2020-11-15 03:57:49 +03:00
parent ba084b79e6
commit 8ff832d6f1
147 changed files with 835 additions and 725 deletions

View File

@ -26,13 +26,13 @@ using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
using Esyur.Core;
using Esyur.Resource;
using Esiur.Core;
using Esiur.Resource;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Esyur.Stores.EntityCore
namespace Esiur.Stores.EntityCore
{
public class EntityResource : IResource
{

View File

@ -22,19 +22,19 @@ SOFTWARE.
*/
using Esyur.Core;
using Esyur.Data;
using Esyur.Resource;
using Esyur.Resource.Template;
using Esiur.Core;
using Esiur.Data;
using Esiur.Resource;
using Esiur.Resource.Template;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using Esyur.Proxy;
using Esiur.Proxy;
using System.Linq;
using Microsoft.EntityFrameworkCore.Metadata;
using System.Reflection;
namespace Esyur.Stores.EntityCore
namespace Esiur.Stores.EntityCore
{
public class EntityStore : IStore
{
@ -43,6 +43,7 @@ namespace Esyur.Stores.EntityCore
public event DestroyedEvent OnDestroy;
Dictionary<Type, Dictionary<object, WeakReference>> DB = new Dictionary<Type, Dictionary<object, WeakReference>>();
object DBLock = new object();
internal struct TypeInfo
{
@ -58,19 +59,27 @@ namespace Esyur.Stores.EntityCore
bool Loaded;
public async AsyncReply<IResource> Get(string path)
public AsyncReply<IResource> Get(string path)
{
var p = path.Split('/');
var ti = TypesByName[p[0]];
var id = Convert.ChangeType(p[1], ti.PrimaryKey.PropertyType);// Convert.ToInt32();
//Type.cas ti.PrimaryKey.PropertyType.
return DbContextProvider().Find(ti.Type.ClrType, id) as IResource;
var db = DbContextProvider();
var res = db.Find(ti.Type.ClrType, id);
var ent = db.Entry(res);
foreach (var rf in ent.References)
rf.Load();
return new AsyncReply<IResource>(res as IResource);
}
public async AsyncReply<bool> Put(IResource resource)
public AsyncReply<bool> Put(IResource resource)
{
if (resource is EntityStore)
return false;
return new AsyncReply<bool>(false);
var type = ResourceProxy.GetBaseType(resource);//.GetType().;
@ -78,23 +87,29 @@ namespace Esyur.Stores.EntityCore
var eid = TypesByType[type].PrimaryKey.GetValue(resource);
if (DB[type].ContainsKey(eid))
DB[type].Remove(eid);
lock (DBLock)
{
if (DB[type].ContainsKey(eid))
DB[type].Remove(eid);
DB[type].Add(eid, new WeakReference(resource));
DB[type].Add(eid, new WeakReference(resource));
}
return true;
return new AsyncReply<bool>(true);
}
public IResource GetById(Type type, object id)
{
if (!DB[type].ContainsKey(id))
return null;
lock (DBLock)
{
if (!DB[type].ContainsKey(id))
return null;
if (!DB[type][id].IsAlive)
return null;
if (!DB[type][id].IsAlive)
return null;
return DB[type][id].Target as IResource;
return DB[type][id].Target as IResource;
}
}
[Attribute]
@ -140,7 +155,7 @@ namespace Esyur.Stores.EntityCore
//throw new NotImplementedException();
}
public new bool Remove(IResource resource)
public bool Remove(IResource resource)
{
throw new NotImplementedException();
}

View File

@ -2,12 +2,13 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Esyur.Stores.EntityCore</AssemblyName>
<AssemblyName>Esiur.Stores.EntityCore</AssemblyName>
<Authors>Ahmed Kh. Zamil</Authors>
<Company>Esyur Foundation</Company>
<Description>Esyur for Entity Framework Core</Description>
<Product>Esyur Entity Framework Extension</Product>
<Company>Esiur Foundation</Company>
<Description>Esiur for Entity Framework Core</Description>
<Product>Esiur Entity Framework Extension</Product>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Esiur.Stores.EntityCore</PackageId>
</PropertyGroup>
<ItemGroup>
@ -16,7 +17,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Esyur\Esyur.csproj" />
<ProjectReference Include="..\Esiur\Esiur.csproj" />
</ItemGroup>
</Project>

View File

@ -33,11 +33,11 @@ using Microsoft.EntityFrameworkCore.Utilities;
using System.Linq;
using Microsoft.EntityFrameworkCore.Metadata;
using System.Reflection;
using Esyur.Proxy;
using Esiur.Proxy;
namespace Esyur.Stores.EntityCore
namespace Esiur.Stores.EntityCore
{
public class EsyurExtensionOptions : IDbContextOptionsExtension
public class EsiurExtensionOptions : IDbContextOptionsExtension
{
//public Dictionary<Type, PropertyInfo> Cache { get; } = new Dictionary<Type, PropertyInfo>();
@ -62,7 +62,7 @@ namespace Esyur.Stores.EntityCore
// services.AddEntityFrameworkProxies();
new EntityFrameworkServicesBuilder(services)
.TryAdd<IConventionSetPlugin, EsyurPlugin>();
.TryAdd<IConventionSetPlugin, EsiurPlugin>();
}
public void Validate(IDbContextOptions options)
@ -72,14 +72,14 @@ namespace Esyur.Stores.EntityCore
{
var scope = internalServiceProvider.CreateScope();
var conventionPlugins = scope.ServiceProvider.GetService<IEnumerable<IConventionSetPlugin>>();
if (conventionPlugins?.Any(s => s is EsyurPlugin) == false)
if (conventionPlugins?.Any(s => s is EsiurPlugin) == false)
{
throw new InvalidOperationException("");
}
}
}
public EsyurExtensionOptions(EntityStore store)
public EsiurExtensionOptions(EntityStore store)
{
_info = new ExtensionInfo(this);
_store = store;
@ -94,12 +94,12 @@ namespace Esyur.Stores.EntityCore
{
}
private new EsyurExtensionOptions Extension
=> (EsyurExtensionOptions)base.Extension;
private new EsiurExtensionOptions Extension
=> (EsiurExtensionOptions)base.Extension;
public override bool IsDatabaseProvider => false;
public override string LogFragment => "Esyur";
public override string LogFragment => "Esiur";
public override long GetServiceProviderHashCode() => 2312;

View File

@ -22,8 +22,8 @@ SOFTWARE.
*/
using Esyur.Resource;
using Esyur.Security.Permissions;
using Esiur.Resource;
using Esiur.Security.Permissions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
@ -32,9 +32,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Esyur.Stores.EntityCore
namespace Esiur.Stores.EntityCore
{
public static class EsyurExtensions
public static class EsiurExtensions
{
//public static T CreateResource<T>(this DbContext dbContext, object properties = null) where T:class,IResource
//{
@ -44,7 +44,7 @@ namespace Esyur.Stores.EntityCore
public static T AddResource<T>(this DbSet<T> dbSet, object properties = null) where T : class, IResource
{
var store = dbSet.GetInfrastructure().GetService<IDbContextOptions>().FindExtension<EsyurExtensionOptions>().Store;
var store = dbSet.GetInfrastructure().GetService<IDbContextOptions>().FindExtension<EsiurExtensionOptions>().Store;
var manager = store.Instance.Managers.FirstOrDefault();// > 0 ? store.Instance.Managers.First() : null;
//var db = dbSet.GetService<ICurrentDbContext>().Context;
@ -64,7 +64,7 @@ namespace Esyur.Stores.EntityCore
public static T CreateResource<T>(this IServiceProvider serviceProvider, object properties = null) where T : class, IResource
{
var options = serviceProvider.GetService<IDbContextOptions>().FindExtension<EsyurExtensionOptions>();
var options = serviceProvider.GetService<IDbContextOptions>().FindExtension<EsiurExtensionOptions>();
var resource = Warehouse.New<T>("", options.Store, null, null, null, properties);
@ -73,7 +73,7 @@ namespace Esyur.Stores.EntityCore
return resource;
}
public static DbContextOptionsBuilder UseEsyur(this DbContextOptionsBuilder optionsBuilder,
public static DbContextOptionsBuilder UseEsiur(this DbContextOptionsBuilder optionsBuilder,
//DbContext context,
string name = null,
IResource parent = null,
@ -81,13 +81,13 @@ namespace Esyur.Stores.EntityCore
Func<DbContext> dbContextProvider = null
)
{
var extension = optionsBuilder.Options.FindExtension<EsyurExtensionOptions>();
var extension = optionsBuilder.Options.FindExtension<EsiurExtensionOptions>();
if (extension == null)
{
var store = Warehouse.New<EntityStore>(name, null, parent, manager, new { Options = optionsBuilder, DbContextProvider = dbContextProvider });
extension = new EsyurExtensionOptions(store);
extension = new EsiurExtensionOptions(store);
//store.Options = optionsBuilder;
//store.DbContext = context;
}
@ -98,7 +98,7 @@ namespace Esyur.Stores.EntityCore
}
public static DbContextOptionsBuilder<TContext> UseEsyur<TContext>(
public static DbContextOptionsBuilder<TContext> UseEsiur<TContext>(
this DbContextOptionsBuilder<TContext> optionsBuilder,
//DbContext context,
string name = null,
@ -109,12 +109,12 @@ namespace Esyur.Stores.EntityCore
{
var extension = optionsBuilder.Options.FindExtension<EsyurExtensionOptions>();
var extension = optionsBuilder.Options.FindExtension<EsiurExtensionOptions>();
if (extension == null)
{
var store = Warehouse.New<EntityStore>(name, null, parent, manager, new { Options = optionsBuilder, DbContextProvider = dbContextProvider });
extension = new EsyurExtensionOptions(store);
extension = new EsiurExtensionOptions(store);
//store.Options = optionsBuilder;
//store.Options = extension;
//store.DbContext = context;

View File

@ -30,14 +30,14 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Esyur.Stores.EntityCore
namespace Esiur.Stores.EntityCore
{
public class EsyurPlugin : IConventionSetPlugin
public class EsiurPlugin : IConventionSetPlugin
{
private readonly IDbContextOptions _options;
private readonly ProviderConventionSetBuilderDependencies _conventionSetBuilderDependencies;
public EsyurPlugin(
public EsiurPlugin(
IDbContextOptions options,
ProviderConventionSetBuilderDependencies conventionSetBuilderDependencies)
{
@ -48,8 +48,8 @@ namespace Esyur.Stores.EntityCore
public ConventionSet ModifyConventions(ConventionSet conventionSet)
{
var extension = _options.FindExtension<EsyurExtensionOptions>();
conventionSet.ModelFinalizedConventions.Add(new EsyurProxyRewrite(
var extension = _options.FindExtension<EsiurExtensionOptions>();
conventionSet.ModelFinalizedConventions.Add(new EsiurProxyRewrite(
extension,
_conventionSetBuilderDependencies));
return conventionSet;

View File

@ -27,8 +27,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Esyur.Proxy;
using Esyur.Resource;
using Esiur.Proxy;
using Esiur.Resource;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
@ -38,12 +38,12 @@ using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
namespace Esyur.Stores.EntityCore
namespace Esiur.Stores.EntityCore
{
public class EsyurProxyRewrite : IModelFinalizedConvention
public class EsiurProxyRewrite : IModelFinalizedConvention
{
private static readonly MethodInfo _createInstance
= typeof(EsyurProxyRewrite).GetTypeInfo().GetDeclaredMethod(nameof(EsyurProxyRewrite.CreateInstance));
= typeof(EsiurProxyRewrite).GetTypeInfo().GetDeclaredMethod(nameof(EsiurProxyRewrite.CreateInstance));
private readonly ConstructorBindingConvention _directBindingConvention;
@ -67,7 +67,7 @@ namespace Esyur.Stores.EntityCore
///var id = constructorArguments.Last();
var id = properties.First();
var options = dbContextOptions.FindExtension<EsyurExtensionOptions>();
var options = dbContextOptions.FindExtension<EsiurExtensionOptions>();
var manager = options.Store.Instance.Managers.Count > 0 ? options.Store.Instance.Managers.First() : null;
var cache = options.Store.GetById(entityType.ClrType, id);
@ -87,7 +87,7 @@ namespace Esyur.Stores.EntityCore
}
public EsyurProxyRewrite(EsyurExtensionOptions ext, ProviderConventionSetBuilderDependencies conventionSetBuilderDependencies)
public EsiurProxyRewrite(EsiurExtensionOptions ext, ProviderConventionSetBuilderDependencies conventionSetBuilderDependencies)
{
_directBindingConvention = new ConstructorBindingConvention(conventionSetBuilderDependencies);
@ -100,20 +100,26 @@ namespace Esyur.Stores.EntityCore
{
var proxyType = ResourceProxy.GetProxy(entityType.ClrType);
// var ann = entityType.GetAnnotation(CoreAnnotationNames.ConstructorBinding);
// var ann = entityType.GetAnnotation(CoreAnnotationNames.ConstructorBinding);
#pragma warning disable EF1001 // Internal EF Core API usage.
var binding = (InstantiationBinding)entityType[CoreAnnotationNames.ConstructorBinding];
#pragma warning restore EF1001 // Internal EF Core API usage.
if (binding == null)
_directBindingConvention.ProcessModelFinalized(modelBuilder, context);
#pragma warning disable EF1001 // Internal EF Core API usage.
binding = (InstantiationBinding)entityType[CoreAnnotationNames.ConstructorBinding];
#pragma warning restore EF1001 // Internal EF Core API usage.
try
{
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>

View File

@ -1,6 +1,6 @@
{
"profiles": {
"Esyur.Stores.EntityCore": {
"Esiur.Stores.EntityCore": {
"commandName": "Project",
"commandLineArgs": "--migrate"
}

View File

@ -3,15 +3,16 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Authors>Ahmed Kh. Zamil</Authors>
<Company>Esyur</Company>
<Product>Esyur MongoDB Store</Product>
<Description>MongoDB Store for Esyur Library</Description>
<Company>Esiur</Company>
<Product>Esiur MongoDB Store</Product>
<Description>MongoDB Store for Esiur Library</Description>
<Copyright>Ahmed Kh. Zamil</Copyright>
<PackageLicenseUrl>https://github.com/Esyur/Esyur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>http://www.esyur.com</PackageProjectUrl>
<RepositoryUrl>https://github.com/esyur/esyur-dotnet/</RepositoryUrl>
<PackageLicenseUrl>https://github.com/Esiur/Esiur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
<RepositoryUrl>https://github.com/esiur/esiur-dotnet/</RepositoryUrl>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.4.0</Version>
<PackageId>Esiur.Stores.MongoDB</PackageId>
</PropertyGroup>
<ItemGroup>
@ -20,7 +21,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Esyur\Esyur.csproj" />
<ProjectReference Include="..\Esiur\Esiur.csproj" />
</ItemGroup>
</Project>

View File

@ -22,22 +22,22 @@ SOFTWARE.
*/
using Esyur.Resource;
using Esiur.Resource;
using System;
using Esyur.Core;
using Esiur.Core;
using MongoDB.Driver.Core;
using MongoDB.Driver;
using MongoDB.Bson;
using Esyur.Data;
using Esiur.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using Esyur.Resource.Template;
using Esiur.Resource.Template;
using System.Linq;
using Esyur.Security.Permissions;
using Esyur.Proxy;
using Esiur.Security.Permissions;
using Esiur.Proxy;
namespace Esyur.Stores.MongoDB
namespace Esiur.Stores.MongoDB
{
public class MongoDBStore : IStore
{
@ -523,7 +523,7 @@ namespace Esyur.Stores.MongoDB
{
var collectionName = Collection ?? "resources";
var dbName = Database ?? "Esyur";
var dbName = Database ?? "Esiur";
client = new MongoClient(Connection ?? "mongodb://localhost");
database = client.GetDatabase(dbName);

View File

@ -22,16 +22,16 @@ SOFTWARE.
*/
using Esyur.Core;
using Esyur.Data;
using Esyur.Proxy;
using Esyur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Proxy;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Esyur.Stores.MongoDB
namespace Esiur.Stores.MongoDB
{
public class MongoDBStore<T> : MongoDBStore where T:IResource
{

View File

@ -2,11 +2,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29324.140
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esyur", "Esyur\Esyur.csproj", "{4F74A8C1-D38F-4CC0-ACD1-24459BA0EAFC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esiur", "Esiur\Esiur.csproj", "{4F74A8C1-D38F-4CC0-ACD1-24459BA0EAFC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esyur.Stores.MongoDB", "Esyur.Stores.MongoDB\Esyur.Stores.MongoDB.csproj", "{4C90D4B3-8EA2-48AE-A2F9-2B722FCEF9C4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esiur.Stores.MongoDB", "Esiur.Stores.MongoDB\Esiur.Stores.MongoDB.csproj", "{4C90D4B3-8EA2-48AE-A2F9-2B722FCEF9C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esyur.Stores.EntityCore", "Esyur.Stores.EntityCore\Esyur.Stores.EntityCore.csproj", "{53DE5A30-CFA9-4DE7-A840-77CFF519D31B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esiur.Stores.EntityCore", "Esiur.Stores.EntityCore\Esiur.Stores.EntityCore.csproj", "{53DE5A30-CFA9-4DE7-A840-77CFF519D31B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncAwaiter : INotifyCompletion
{

View File

@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncAwaiter<T> : INotifyCompletion
{

View File

@ -28,7 +28,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncBag: AsyncReply
{

View File

@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncBagAwaiter : INotifyCompletion
{

View File

@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncBagAwaiter<T> : INotifyCompletion
{

View File

@ -28,7 +28,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncBag<T>: AsyncBag
{

View File

@ -26,7 +26,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncException : Exception
{

View File

@ -28,7 +28,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncQueue<T> : AsyncReply<T>
{

View File

@ -27,13 +27,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Esyur.Resource;
using Esiur.Resource;
using System.Reflection;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Diagnostics;
namespace Esyur.Core
namespace Esiur.Core
{
[AsyncMethodBuilder(typeof(AsyncReplyBuilder))]
public class AsyncReply

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncReplyBuilder
{

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncReplyBuilder<T>
{

View File

@ -27,13 +27,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Esyur.Resource;
using Esiur.Resource;
using System.Reflection;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Diagnostics;
namespace Esyur.Core
namespace Esiur.Core
{
[AsyncMethodBuilder(typeof(AsyncReplyBuilder<>))]
public class AsyncReply<T> : AsyncReply

View File

@ -28,7 +28,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Core
namespace Esiur.Core
{
public class AsyncReply
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Core
namespace Esiur.Core
{
public enum ErrorType
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Core
namespace Esiur.Core
{
public enum ExceptionCode : ushort
{

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace Esyur.Core
namespace Esiur.Core
{
public interface IAsyncReply<out T>//IAsyncEnumerator<T>
{

View File

@ -27,7 +27,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Core
namespace Esiur.Core
{
public delegate void DestroyedEvent(object sender);

View File

@ -29,7 +29,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Core
namespace Esiur.Core
{
public enum LogType
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Core
namespace Esiur.Core
{
public enum ProgressType
{

View File

@ -27,10 +27,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Esyur.Core;
using Esiur.Core;
using System.Reflection;
namespace Esyur.Data
namespace Esiur.Data
{
public class AutoList<T, ST> : IEnumerable<T>, ICollection, ICollection<T>
{
@ -86,7 +86,7 @@ namespace Esyur.Data
/// <returns>Array</returns>
public T[] ToArray()
{
// list.OrderBy()
// list.OrderBy()
return list.ToArray();
}
@ -112,13 +112,13 @@ namespace Esyur.Data
public AutoList(ST state, T[] values)
{
State = state;
#if NETSTANDARD
removableList = (typeof(IDestructible).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()));
#else
#if NETSTANDARD
removableList = (typeof(IDestructible).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()));
#else
removableList = (typeof(IDestructible).IsAssignableFrom(typeof(T)));
#endif
#endif
AddRange(values);
AddRange(values);
}
/// <summary>
@ -203,8 +203,8 @@ namespace Esyur.Data
public void Clear()
{
if (removableList)
foreach(IDestructible v in list)
if (v!=null)
foreach (IDestructible v in list)
if (v != null)
v.OnDestroy -= ItemDestroyed;
lock (syncRoot)
@ -217,10 +217,10 @@ namespace Esyur.Data
/// Remove an item from the list
/// <param name="value">Item to remove</param>
/// </summary>
public void Remove(T value)
public bool Remove(T value)
{
if (!list.Contains(value))
return;
return false;
if (removableList)
if (value != null)
@ -230,6 +230,8 @@ namespace Esyur.Data
list.Remove(value);
OnRemoved?.Invoke(State, value);
return true;
}
/// <summary>
@ -242,7 +244,7 @@ namespace Esyur.Data
public bool IsSynchronized => (list as ICollection).IsSynchronized;
public bool IsReadOnly => throw new NotImplementedException();
public bool IsReadOnly => false;
/// <summary>
@ -290,17 +292,20 @@ namespace Esyur.Data
public void CopyTo(Array array, int index)
{
(list as ICollection).CopyTo(array, index);
lock (syncRoot)
(list as ICollection).CopyTo(array, index);
}
public void CopyTo(T[] array, int arrayIndex)
{
list.CopyTo(array, arrayIndex);
lock (syncRoot)
list.CopyTo(array, arrayIndex);
}
bool ICollection<T>.Remove(T item)
{
return list.Remove(item);
}
//bool ICollection<T>.Remove(T item)
//{
// lock(syncRoot)
// return Remove(item);
//}
}
}

View File

@ -26,11 +26,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Misc;
using Esiur.Misc;
using System.Reflection;
using Esyur.Core;
using Esiur.Core;
namespace Esyur.Data
namespace Esiur.Data
{
/// <summary>
/// BinaryList holds a list of items to be converted to binary for storage and transmission

View File

@ -25,19 +25,19 @@ SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using Esyur.Misc;
using Esiur.Misc;
using System.ComponentModel;
using Esyur.Data;
using Esyur.Core;
using Esyur.Net.IIP;
using Esyur.Resource;
using Esiur.Data;
using Esiur.Core;
using Esiur.Net.IIP;
using Esiur.Resource;
using System.Linq;
using System.Reflection;
using Esyur.Resource.Template;
using Esiur.Resource.Template;
using System.Runtime.CompilerServices;
using System.Collections;
namespace Esyur.Data
namespace Esiur.Data
{
public static class Codec
{

View File

@ -26,18 +26,18 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Net.IIP;
using Esiur.Net.IIP;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Net;
using System.Net.NetworkInformation;
using System.Reflection;
using Esyur.Data;
using Esyur.Core;
using Esyur.Resource;
using Esiur.Data;
using Esiur.Core;
using Esiur.Resource;
namespace Esyur.Data
namespace Esiur.Data
{
public static class DC // Data Converter
{

View File

@ -28,7 +28,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Data
namespace Esiur.Data
{
public enum DataType : byte
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Data
namespace Esiur.Data
{
public interface IUserType
{

View File

@ -31,9 +31,9 @@ using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Esyur.Core;
using Esiur.Core;
namespace Esyur.Data
namespace Esiur.Data
{
public class KeyList<KT, T> : IEnumerable<KeyValuePair<KT, T>>

View File

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

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Data
namespace Esiur.Data
{
public class PropertyValue
{

View File

@ -27,10 +27,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Esyur.Core;
using Esiur.Core;
using System.Reflection;
namespace Esyur.Data
namespace Esiur.Data
{
public class ResourceList<T, ST> : IEnumerable<T>, ICollection, ICollection<T>
{

View File

@ -31,7 +31,7 @@ using System.Text;
using System.Reflection;
using System.Linq;
namespace Esyur.Data
namespace Esiur.Data
{
public class StringKeyList : IEnumerable<KeyValuePair<string, string>>

View File

@ -28,12 +28,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Esyur.Data;
using Esyur.Misc;
using Esyur.Core;
using Esiur.Data;
using Esiur.Misc;
using Esiur.Core;
using System.Reflection;
namespace Esyur.Data
namespace Esiur.Data
{
public class Structure : IEnumerable<KeyValuePair<string, object>>
{

View File

@ -4,17 +4,19 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Description>Distributed Resources Platform</Description>
<Copyright>Ahmed Kh. Zamil</Copyright>
<PackageLicenseUrl>https://github.com/Esyur/Esyur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>http://www.esyur.com</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/Esiur/Esiur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.5.0</Version>
<RepositoryUrl>https://github.com/esyur/esyur-dotnet</RepositoryUrl>
<RepositoryUrl>https://github.com/esiur/esiur-dotnet</RepositoryUrl>
<Authors>Ahmed Kh. Zamil</Authors>
<AssemblyVersion>1.3.1.0</AssemblyVersion>
<Company>Esyur Foundation</Company>
<Company>Esiur Foundation</Company>
<FileVersion>1.3.1.0</FileVersion>
<AssemblyName>Esyur</AssemblyName>
<RootNamespace>Esyur</RootNamespace>
<AssemblyName>Esiur</AssemblyName>
<RootNamespace>Esiur</RootNamespace>
<PackageId>Esiur</PackageId>
<Product>Esiur</Product>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -29,17 +29,17 @@ using System.Xml;
using System.Security.Cryptography;
using System.Text;
using System.Reflection;
using Esyur.Data;
using Esiur.Data;
using System.Collections.Generic;
//using Esyur.Net.Packets;
//using Esiur.Net.Packets;
using System.Text.RegularExpressions;
using System.Net.NetworkInformation;
using System.Linq;
using Esyur.Core;
using Esiur.Core;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Esyur.Misc
namespace Esiur.Misc
{
public static class Global
{

View File

@ -26,12 +26,12 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Core;
using Esyur.Data;
using Esyur.Net.Packets;
using Esyur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Net.Packets;
using Esiur.Resource;
namespace Esyur.Net.DataLink
namespace Esiur.Net.DataLink
{
public abstract class PacketFilter : IResource
{

View File

@ -26,13 +26,13 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Core;
using Esyur.Data;
using Esiur.Core;
using Esiur.Data;
using System.Runtime.InteropServices;
using Esyur.Net.Packets;
using Esyur.Resource;
using Esiur.Net.Packets;
using Esiur.Resource;
namespace Esyur.Net.DataLink
namespace Esiur.Net.DataLink
{
public class PacketServer:IResource
{

View File

@ -22,15 +22,15 @@ SOFTWARE.
*/
using Esyur.Net.Packets;
using Esiur.Net.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Core;
using Esyur.Resource;
using Esiur.Core;
using Esiur.Resource;
namespace Esyur.Net.DataLink
namespace Esiur.Net.DataLink
{
public abstract class PacketSource: IResource
{

View File

@ -31,14 +31,14 @@ using System.Threading;
using System.Net;
using System.Collections;
using System.Collections.Generic;
using Esyur.Net.Sockets;
using Esyur.Data;
using Esyur.Net.Packets;
using Esyur.Misc;
using Esiur.Net.Sockets;
using Esiur.Data;
using Esiur.Net.Packets;
using Esiur.Misc;
using System.Security.Cryptography;
using Esyur.Core;
using Esiur.Core;
namespace Esyur.Net.HTTP
namespace Esiur.Net.HTTP
{
public class HTTPConnection : NetworkConnection
{

View File

@ -31,11 +31,11 @@ using System.Threading;
using System.Net;
using System.Collections;
using System.Collections.Generic;
using Esyur.Data;
using Esyur.Core;
using Esyur.Resource;
using Esiur.Data;
using Esiur.Core;
using Esiur.Resource;
namespace Esyur.Net.HTTP
namespace Esiur.Net.HTTP
{
public abstract class HTTPFilter : IResource

View File

@ -31,15 +31,15 @@ using System.Threading;
using System.Net;
using System.Collections;
using System.Collections.Generic;
using Esyur.Net.Sockets;
using Esyur.Data;
using Esyur.Misc;
using Esyur.Core;
using Esyur.Net.Packets;
using Esiur.Net.Sockets;
using Esiur.Data;
using Esiur.Misc;
using Esiur.Core;
using Esiur.Net.Packets;
using System.Security.Cryptography.X509Certificates;
using Esyur.Resource;
using Esiur.Resource;
namespace Esyur.Net.HTTP
namespace Esiur.Net.HTTP
{
public class HTTPServer : NetworkServer<HTTPConnection>, IResource
{
@ -66,19 +66,19 @@ namespace Esyur.Net.HTTP
set;
}
[Attribute]
public virtual uint Timeout
{
get;
set;
}
//[Attribute]
//public virtual uint Timeout
//{
// get;
// set;
//}
[Attribute]
public virtual uint Clock
{
get;
set;
}
//[Attribute]
//public virtual uint Clock
//{
// get;
// set;
//}
[Attribute]
public virtual uint MaxPost

View File

@ -31,11 +31,11 @@ using System.Threading;
using System.Net;
using System.Collections;
using System.Collections.Generic;
using Esyur.Data;
using Esyur.Misc;
using Esyur.Core;
using Esiur.Data;
using Esiur.Misc;
using Esiur.Core;
namespace Esyur.Net.HTTP
namespace Esiur.Net.HTTP
{
public class HTTPSession : IDestructible //<T> where T : TClient
{

View File

@ -1,22 +1,22 @@
using Esyur.Core;
using Esyur.Net.IIP;
using Esyur.Net.Packets;
using Esyur.Resource;
using Esiur.Core;
using Esiur.Net.IIP;
using Esiur.Net.Packets;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Text;
namespace Esyur.Net.HTTP
namespace Esiur.Net.HTTP
{
public class IIPoHTTP : HTTPFilter
{
[Attribute]
EntryPoint EntryPoint { get; set; }
public async override AsyncReply<bool> Execute(HTTPConnection sender)
public override AsyncReply<bool> Execute(HTTPConnection sender)
{
if (sender.Request.URL != "iip")
return false;
return new AsyncReply<bool>(false);
IIPPacket.IIPPacketAction action = (IIPPacket.IIPPacketAction)Convert.ToByte(sender.Request.Query["a"]);
@ -28,7 +28,7 @@ namespace Esyur.Net.HTTP
});
}
return true;
return new AsyncReply<bool>(true);
}
public override AsyncReply<bool> Trigger(ResourceTrigger trigger)

View File

@ -27,12 +27,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Esyur.Resource;
using Esyur.Net.IIP;
using Esyur.Net.Sockets;
using Esyur.Core;
using Esiur.Resource;
using Esiur.Net.IIP;
using Esiur.Net.Sockets;
using Esiur.Core;
namespace Esyur.Net.HTTP
namespace Esiur.Net.HTTP
{
public class IIPoWS: HTTPFilter
{
@ -43,18 +43,18 @@ namespace Esyur.Net.HTTP
set;
}
public async override AsyncReply<bool> Execute(HTTPConnection sender)
public override AsyncReply<bool> Execute(HTTPConnection sender)
{
if (sender.IsWebsocketRequest())
{
if (Server == null)
return false;
return new AsyncReply<bool>(false);
var tcpSocket = sender.Unassign();
if (tcpSocket == null)
return false;
return new AsyncReply<bool>(false);
var httpServer = sender.Parent;
var wsSocket = new WSSocket(tcpSocket);
@ -66,10 +66,10 @@ namespace Esyur.Net.HTTP
iipConnection.Assign(wsSocket);
wsSocket.Begin();
return true;
return new AsyncReply<bool>(true);
}
return false;
return new AsyncReply<bool>( false);
/*
if (sender.Request.Filename.StartsWith("/iip/"))

View File

@ -28,19 +28,19 @@ using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography;
using Esyur.Net.Sockets;
using Esyur.Data;
using Esyur.Misc;
using Esyur.Core;
using Esyur.Net.Packets;
using Esyur.Resource;
using Esyur.Security.Authority;
using Esyur.Resource.Template;
using Esiur.Net.Sockets;
using Esiur.Data;
using Esiur.Misc;
using Esiur.Core;
using Esiur.Net.Packets;
using Esiur.Resource;
using Esiur.Security.Authority;
using Esiur.Resource.Template;
using System.Linq;
using System.Diagnostics;
using static Esyur.Net.Packets.IIPPacket;
using static Esiur.Net.Packets.IIPPacket;
namespace Esyur.Net.IIP
namespace Esiur.Net.IIP
{
public partial class DistributedConnection : NetworkConnection, IStore
{
@ -1058,12 +1058,12 @@ namespace Esyur.Net.IIP
/// </summary>
/// <param name="resource">Resource.</param>
/// <returns></returns>
public async AsyncReply<bool> Put(IResource resource)
public AsyncReply<bool> Put(IResource resource)
{
if (Codec.IsLocalResource(resource, this))
resources.Add((resource as DistributedResource).Id, (DistributedResource)resource);
// else ... send it to the peer
return true;
return new AsyncReply<bool>(true);
}
public bool Record(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
@ -1107,7 +1107,7 @@ namespace Esyur.Net.IIP
//if (Codec.IsLocalResource(resource, this))
// return new AsyncBag<T>((resource as DistributedResource).children.Where(x => x.GetType() == typeof(T)).Select(x => (T)x));
return null;
//return null;
}
public AsyncBag<T> Parents<T>(IResource resource, string name) where T : IResource
@ -1116,7 +1116,6 @@ namespace Esyur.Net.IIP
//if (Codec.IsLocalResource(resource, this))
// return (resource as DistributedResource).parents.Where(x => x.GetType() == typeof(T)).Select(x => (T)x);
return null;
}

View File

@ -22,13 +22,13 @@ SOFTWARE.
*/
using Esyur.Data;
using Esyur.Core;
using Esyur.Net.Packets;
using Esyur.Resource;
using Esyur.Resource.Template;
using Esyur.Security.Authority;
using Esyur.Security.Permissions;
using Esiur.Data;
using Esiur.Core;
using Esiur.Net.Packets;
using Esiur.Resource;
using Esiur.Resource.Template;
using Esiur.Security.Authority;
using Esiur.Security.Permissions;
using System;
using System.Collections.Generic;
@ -37,7 +37,7 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Net.IIP
namespace Esiur.Net.IIP
{
partial class DistributedConnection
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Net.IIP
namespace Esiur.Net.IIP
{
public class DistributedPropertyContext
{

View File

@ -29,20 +29,20 @@ using System.Reflection;
using System.IO;
using System.Collections;
using System.ComponentModel;
using Esyur.Misc;
using Esyur.Data;
using Esiur.Misc;
using Esiur.Data;
using System.Dynamic;
using System.Security.Cryptography;
using Esyur.Core;
using Esiur.Core;
using System.Runtime.CompilerServices;
using System.Reflection.Emit;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Esyur.Resource;
using Esyur.Resource.Template;
using Esiur.Resource;
using Esiur.Resource.Template;
namespace Esyur.Net.IIP
namespace Esiur.Net.IIP
{
//[System.Runtime.InteropServices.ComVisible(true)]

View File

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

View File

@ -28,7 +28,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Net.IIP
namespace Esiur.Net.IIP
{
public class DistributedResourceQueueItem
{

View File

@ -26,16 +26,16 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Net.Sockets;
using Esyur.Misc;
using Esiur.Net.Sockets;
using Esiur.Misc;
using System.Threading;
using Esyur.Data;
using Esyur.Core;
using Esiur.Data;
using Esiur.Core;
using System.Net;
using Esyur.Resource;
using Esyur.Security.Membership;
using Esiur.Resource;
using Esiur.Security.Membership;
namespace Esyur.Net.IIP
namespace Esiur.Net.IIP
{
public class DistributedServer : NetworkServer<DistributedConnection>, IResource
{

View File

@ -25,10 +25,10 @@ SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using Esyur.Net.Sockets;
using Esyur.Security.Authority;
using Esiur.Net.Sockets;
using Esiur.Security.Authority;
namespace Esyur.Net.IIP
namespace Esiur.Net.IIP
{
public class DistributedSession : NetworkSession
{

View File

@ -24,14 +24,14 @@ SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using Esyur.Core;
using Esyur.Data;
using Esyur.Resource;
using Esyur.Resource.Template;
using Esiur.Core;
using Esiur.Data;
using Esiur.Resource;
using Esiur.Resource.Template;
namespace Esyur.Net.IIP
namespace Esiur.Net.IIP
{
public abstract class EntryPoint : Esyur.Resource.Resource
public abstract class EntryPoint : Esiur.Resource.Resource
{
public abstract AsyncReply<IResource[]> Query(string path, DistributedConnection sender);

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Net
namespace Esiur.Net
{
public interface INetworkReceiver<T>
{

View File

@ -26,10 +26,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Data;
using Esyur.Misc;
using Esiur.Data;
using Esiur.Misc;
namespace Esyur.Net
namespace Esiur.Net
{
public class NetworkBuffer
{

View File

@ -30,13 +30,13 @@ using System.Threading;
using System.Net;
using System.Collections;
using System.Collections.Generic;
using Esyur.Misc;
using Esyur.Core;
using Esyur.Data;
using Esyur.Net.Sockets;
using Esyur.Resource;
using Esiur.Misc;
using Esiur.Core;
using Esiur.Data;
using Esiur.Net.Sockets;
using Esiur.Resource;
namespace Esyur.Net
namespace Esiur.Net
{
public abstract class NetworkConnection: IDestructible, INetworkReceiver<ISocket>// <TS>: IResource where TS : NetworkSession
{
@ -81,11 +81,7 @@ namespace Esyur.Net
OnDestroy = null;
}
public Sockets.ISocket Socket
public ISocket Socket
{
get
{
@ -93,7 +89,7 @@ namespace Esyur.Net
}
}
public virtual void Assign(Sockets.ISocket socket)
public virtual void Assign(ISocket socket)
{
lastAction = DateTime.Now;
sock = socket;
@ -124,7 +120,7 @@ namespace Esyur.Net
//{
//}
public Sockets.ISocket Unassign()
public ISocket Unassign()
{
if (sock != null)
{
@ -323,7 +319,7 @@ namespace Esyur.Net
return;
// Closed ?
if (sock.State == SocketState.Closed || sock.State == SocketState.Terminated) // || !connected)
if (sock.State == SocketState.Closed)// || sock.State == SocketState.Terminated) // || !connected)
return;
lastAction = DateTime.Now;

View File

@ -25,15 +25,15 @@ SOFTWARE.
using System;
using System.Threading;
using System.Collections.Generic;
using Esyur.Data;
using Esyur.Misc;
using Esyur.Core;
using Esyur.Net.Sockets;
using Esyur.Resource;
using Esiur.Data;
using Esiur.Misc;
using Esiur.Core;
using Esiur.Net.Sockets;
using Esiur.Resource;
using System.Threading.Tasks;
using System.Diagnostics;
namespace Esyur.Net
namespace Esiur.Net
{
public abstract class NetworkServer<TConnection> : IDestructible where TConnection : NetworkConnection, new()

View File

@ -31,11 +31,11 @@ using System.Threading;
using System.Net;
using System.Collections;
using System.Collections.Generic;
using Esyur.Data;
using Esyur.Misc;
using Esyur.Core;
using Esiur.Data;
using Esiur.Misc;
using Esiur.Core;
namespace Esyur.Net
namespace Esiur.Net
{
public class NetworkSession:IDestructible //<T> where T : TClient
{

View File

@ -27,11 +27,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Misc;
using Esyur.Data;
using Esiur.Misc;
using Esiur.Data;
using System.Net;
namespace Esyur.Net.Packets
namespace Esiur.Net.Packets
{
public class HTTPRequestPacket : Packet
{
@ -243,9 +243,10 @@ namespace Esyur.Net.Packets
return -(postSize - (data.Length - headerSize));
if (Headers["content-type"].StartsWith("application/x-www-form-urlencoded")
if (
Headers["content-type"] == null
|| Headers["content-type"] == ""
|| Headers["content-type"] == null)
|| Headers["content-type"].StartsWith("application/x-www-form-urlencoded"))
{
string[] PostVars = null;
PostVars = Encoding.UTF8.GetString(data, (int)headerSize, (int)postSize).Split('&');

View File

@ -25,10 +25,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Misc;
using Esyur.Data;
using Esiur.Misc;
using Esiur.Data;
namespace Esyur.Net.Packets
namespace Esiur.Net.Packets
{
public class HTTPResponsePacket : Packet
{
@ -137,7 +137,7 @@ namespace Esyur.Net.Packets
private string MakeHeader(ComposeOptions options)
{
string header = $"{Version} {(int)Number} {Text}\r\nServer: Esyur {Global.Version}\r\nDate: {DateTime.Now.ToUniversalTime().ToString("r")}\r\n";
string header = $"{Version} {(int)Number} {Text}\r\nServer: Esiur {Global.Version}\r\nDate: {DateTime.Now.ToUniversalTime().ToString("r")}\r\n";
if (options == ComposeOptions.AllCalculateLength)
Headers["Content-Length"] = Message?.Length.ToString() ?? "0";

View File

@ -22,8 +22,8 @@ SOFTWARE.
*/
using Esyur.Data;
using Esyur.Security.Authority;
using Esiur.Data;
using Esiur.Security.Authority;
using System;
using System.Collections.Generic;
using System.Linq;
@ -31,7 +31,7 @@ using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Net.Packets
namespace Esiur.Net.Packets
{
class IIPAuthPacket : Packet
{

View File

@ -22,17 +22,17 @@ SOFTWARE.
*/
using Esyur.Data;
using Esyur.Core;
using Esyur.Misc;
using Esyur.Net.Packets;
using Esiur.Data;
using Esiur.Core;
using Esiur.Misc;
using Esiur.Net.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Net.Packets
namespace Esiur.Net.Packets
{
class IIPPacket : Packet
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Net.Packets
namespace Esiur.Net.Packets
{
struct IIPPacketAttachInfo
{

View File

@ -33,12 +33,12 @@
using System;
using System.Text;
using Esyur.Misc;
using Esyur.Net.DataLink;
using Esiur.Misc;
using Esiur.Net.DataLink;
using System.Net.NetworkInformation;
using Esyur.Data;
using Esiur.Data;
namespace Esyur.Net.Packets
namespace Esiur.Net.Packets
{
internal static class Functions
{

View File

@ -26,10 +26,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Misc;
using Esyur.Data;
using Esiur.Misc;
using Esiur.Data;
namespace Esyur.Net.Packets
namespace Esiur.Net.Packets
{
public class WebsocketPacket : Packet
{

View File

@ -1,10 +1,10 @@
using Esyur.Core;
using Esyur.Data;
using Esiur.Core;
using Esiur.Data;
using System;
using System.Collections.Generic;
using System.Text;
namespace Esyur.Net
namespace Esiur.Net
{
public class SendList : BinaryList
{

View File

@ -30,13 +30,13 @@ using System.Threading;
using System.Net;
using System.Collections;
using System.Collections.Generic;
using Esyur.Data;
using Esyur.Misc;
using Esiur.Data;
using Esiur.Misc;
using System.Collections.Concurrent;
using Esyur.Resource;
using Esyur.Core;
using Esiur.Resource;
using Esiur.Core;
namespace Esyur.Net.Sockets
namespace Esiur.Net.Sockets
{
//public delegate void ISocketReceiveEvent(NetworkBuffer buffer);
//public delegate void ISocketConnectEvent();

View File

@ -28,16 +28,16 @@ using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using Esyur.Misc;
using Esyur.Core;
using Esiur.Misc;
using Esiur.Core;
using System.Threading;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using Esyur.Resource;
using Esiur.Resource;
using System.Threading.Tasks;
using Esyur.Data;
using Esiur.Data;
namespace Esyur.Net.Sockets
namespace Esiur.Net.Sockets
{
public class SSLSocket : ISocket
{
@ -94,7 +94,7 @@ namespace Esyur.Net.Sockets
}
catch (Exception ex)
{
state = SocketState.Terminated;
state = SocketState.Closed;// .Terminated;
Close();
Global.Log(ex);
}
@ -148,7 +148,7 @@ namespace Esyur.Net.Sockets
{
if (state != SocketState.Closed && !sock.Connected)
{
state = SocketState.Terminated;
//state = SocketState.Closed;//.Terminated;
Close();
}
}
@ -175,13 +175,14 @@ namespace Esyur.Net.Sockets
if (state != SocketState.Closed && !sock.Connected)
{
state = SocketState.Terminated;
//state = SocketState.Terminated;
Close();
}
}
catch (Exception ex2)
{
state = SocketState.Terminated;
//state = SocketState.Closed;// .Terminated;
Close();
}
//Global.Log("TCPSocket", LogType.Error, ex.ToString());
@ -257,7 +258,7 @@ namespace Esyur.Net.Sockets
public void Close()
{
if (state != SocketState.Closed && state != SocketState.Terminated)
if (state != SocketState.Closed)// && state != SocketState.Terminated)
{
state = SocketState.Closed;
@ -269,7 +270,7 @@ namespace Esyur.Net.Sockets
}
catch
{
state = SocketState.Terminated;
//state = SocketState.Terminated;
}
}
@ -311,7 +312,7 @@ namespace Esyur.Net.Sockets
catch
{
asyncSending = false;
state = SocketState.Terminated;
//state = SocketState.Terminated;
Close();
}
}
@ -442,7 +443,7 @@ namespace Esyur.Net.Sockets
{
if (state != SocketState.Closed && !sock.Connected)
{
state = SocketState.Terminated;
//state = SocketState.Terminated;
Close();
}
@ -473,7 +474,7 @@ namespace Esyur.Net.Sockets
}
catch
{
state = SocketState.Terminated;
state = SocketState.Closed;// Terminated;
return null;
}
}
@ -528,7 +529,7 @@ namespace Esyur.Net.Sockets
{
rt.TriggerError(ex);
asyncSending = false;
state = SocketState.Terminated;
//state = SocketState.Terminated;
Close();
}
}
@ -546,7 +547,7 @@ namespace Esyur.Net.Sockets
}
catch
{
state = SocketState.Terminated;
state = SocketState.Closed;// .Terminated;
return null;
}
}

View File

@ -28,7 +28,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Net.Sockets
namespace Esiur.Net.Sockets
{
public enum SocketState
{
@ -37,6 +37,6 @@ namespace Esyur.Net.Sockets
Connecting,
Established,
Closed,
Terminated
//Terminated
}
}

View File

@ -28,14 +28,14 @@ using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using Esyur.Misc;
using Esyur.Core;
using Esiur.Misc;
using Esiur.Core;
using System.Threading;
using Esyur.Resource;
using Esiur.Resource;
using System.Threading.Tasks;
using Esyur.Data;
using Esiur.Data;
namespace Esyur.Net.Sockets
namespace Esiur.Net.Sockets
{
public class TCPSocket : ISocket
{
@ -46,7 +46,7 @@ namespace Esyur.Net.Sockets
bool held;
ArraySegment<byte> receiveBufferSegment;
//ArraySegment<byte> receiveBufferSegment;
NetworkBuffer receiveNetworkBuffer = new NetworkBuffer();
@ -65,30 +65,80 @@ namespace Esyur.Net.Sockets
//public event ISocketCloseEvent OnClose;
public event DestroyedEvent OnDestroy;
SocketAsyncEventArgs socketArgs = new SocketAsyncEventArgs();
//SocketAsyncEventArgs socketArgs = new SocketAsyncEventArgs();
public async AsyncReply<bool> BeginAsync()
private AsyncCallback receiveCallback;
private AsyncCallback sendCallback;
public AsyncReply<bool> BeginAsync()
{
return Begin();
return new AsyncReply<bool>(Begin());
}
private AsyncReply<bool> currentReply = null;
public bool Begin()
{
if (began)
return false;
began = true;
/*
socketArgs.SetBuffer(receiveBuffer, 0, receiveBuffer.Length);
socketArgs.Completed += SocketArgs_Completed;
if (!sock.ReceiveAsync(socketArgs))
SocketArgs_Completed(null, socketArgs);
*/
receiveCallback = new AsyncCallback(ReceiveCallback);
sendCallback = new AsyncCallback(SendCallback);
sock.BeginReceive(receiveBuffer, 0, receiveBuffer.Length, SocketFlags.None, receiveCallback, this);
//sock.ReceiveAsync(receiveBufferSegment, SocketFlags.None).ContinueWith(DataReceived);
return true;
}
private static void ReceiveCallback(IAsyncResult ar)
{
var socket = ar.AsyncState as TCPSocket;
try
{
if (socket.state != SocketState.Established)
return;
var recCount = socket.sock.EndReceive(ar);
if (recCount > 0)
{
socket.receiveNetworkBuffer.Write(socket.receiveBuffer, 0, (uint)recCount);
socket.Receiver?.NetworkReceive(socket, socket.receiveNetworkBuffer);
if (socket.state == SocketState.Established)
socket.sock.BeginReceive(socket.receiveBuffer, 0, socket.receiveBuffer.Length, SocketFlags.None, socket.receiveCallback, socket);
}
else
{
socket.Close();
return;
}
}
catch (Exception ex)
{
if (socket.state != SocketState.Closed && !socket.sock.Connected)
{
//socket.state = SocketState.Terminated;
socket.Close();
}
//Global.Log("TCPSocket", LogType.Error, ex.ToString());
}
}
public AsyncReply<bool> Connect(string hostname, ushort port)
{
var rt = new AsyncReply<bool>();
@ -121,115 +171,115 @@ namespace Esyur.Net.Sockets
}
private void DataReceived(Task<int> task)
{
try
{
// SocketError err;
//private void DataReceived(Task<int> task)
//{
// try
// {
// // SocketError err;
if (state == SocketState.Closed || state == SocketState.Terminated)
return;
// if (state == SocketState.Closed || state == SocketState.Terminated)
// return;
if (task.Result <= 0)
{
Close();
return;
}
// if (task.Result <= 0)
// {
// Close();
// return;
// }
receiveNetworkBuffer.Write(receiveBuffer, 0, (uint)task.Result);
//OnReceive?.Invoke(receiveNetworkBuffer);
Receiver?.NetworkReceive(this, receiveNetworkBuffer);
if (state == SocketState.Established)
sock.ReceiveAsync(receiveBufferSegment, SocketFlags.None).ContinueWith(DataReceived);
// receiveNetworkBuffer.Write(receiveBuffer, 0, (uint)task.Result);
// //OnReceive?.Invoke(receiveNetworkBuffer);
// Receiver?.NetworkReceive(this, receiveNetworkBuffer);
// if (state == SocketState.Established)
// sock.ReceiveAsync(receiveBufferSegment, SocketFlags.None).ContinueWith(DataReceived);
}
catch (Exception ex)
{
if (state != SocketState.Closed && !sock.Connected)
{
state = SocketState.Terminated;
Close();
}
// }
// catch (Exception ex)
// {
// if (state != SocketState.Closed && !sock.Connected)
// {
// state = SocketState.Terminated;
// Close();
// }
Global.Log("TCPSocket", LogType.Error, ex.ToString());
}
}
// Global.Log("TCPSocket", LogType.Error, ex.ToString());
// }
//}
private void SocketArgs_Completed(object sender, SocketAsyncEventArgs e)
{
try
{
if (state != SocketState.Established)
return;
//private void SocketArgs_Completed(object sender, SocketAsyncEventArgs e)
//{
// try
// {
// if (state != SocketState.Established)
// return;
if (e.BytesTransferred <= 0)
{
Close();
return;
}
else if (e.SocketError != SocketError.Success)
{
Close();
return;
// if (e.BytesTransferred <= 0)
// {
// Close();
// return;
// }
// else if (e.SocketError != SocketError.Success)
// {
// Close();
// return;
}
// }
var recCount = e.BytesTransferred > e.Count ? e.Count : e.BytesTransferred;
receiveNetworkBuffer.Write(receiveBuffer, 0, (uint)recCount);
// var recCount = e.BytesTransferred > e.Count ? e.Count : e.BytesTransferred;
// receiveNetworkBuffer.Write(receiveBuffer, 0, (uint)recCount);
//OnReceive?.Invoke(receiveNetworkBuffer);
Receiver?.NetworkReceive(this, receiveNetworkBuffer);
// //OnReceive?.Invoke(receiveNetworkBuffer);
// Receiver?.NetworkReceive(this, receiveNetworkBuffer);
if (state == SocketState.Established)
while (!sock.ReceiveAsync(e))
{
if (e.SocketError != SocketError.Success)
{
Close();
return;
}
// if (state == SocketState.Established)
// while (!sock.ReceiveAsync(e))
// {
// if (e.SocketError != SocketError.Success)
// {
// Close();
// return;
// }
if (State != SocketState.Established)
return;
// if (State != SocketState.Established)
// return;
//if (e.BytesTransferred < 0)
// Console.WriteLine("BytesTransferred is less than zero");
// //if (e.BytesTransferred < 0)
// // Console.WriteLine("BytesTransferred is less than zero");
if (e.BytesTransferred <= 0)
{
Close();
return;
}
else if (e.SocketError != SocketError.Success)
{
Close();
return;
}
// if (e.BytesTransferred <= 0)
// {
// Close();
// return;
// }
// else if (e.SocketError != SocketError.Success)
// {
// Close();
// return;
// }
//if (e.BytesTransferred > 100000)
// Console.WriteLine("BytesTransferred is large " + e.BytesTransferred);
// //if (e.BytesTransferred > 100000)
// // Console.WriteLine("BytesTransferred is large " + e.BytesTransferred);
recCount = e.BytesTransferred > e.Count ? e.Count : e.BytesTransferred;
// recCount = e.BytesTransferred > e.Count ? e.Count : e.BytesTransferred;
receiveNetworkBuffer.Write(receiveBuffer, 0, (uint)recCount);
// receiveNetworkBuffer.Write(receiveBuffer, 0, (uint)recCount);
//OnReceive?.Invoke(receiveNetworkBuffer);
Receiver?.NetworkReceive(this, receiveNetworkBuffer);
}
// //OnReceive?.Invoke(receiveNetworkBuffer);
// Receiver?.NetworkReceive(this, receiveNetworkBuffer);
// }
}
catch (Exception ex)
{
if (state != SocketState.Closed && !sock.Connected)
{
state = SocketState.Terminated;
Close();
}
// }
// catch (Exception ex)
// {
// if (state != SocketState.Closed && !sock.Connected)
// {
// state = SocketState.Terminated;
// Close();
// }
Global.Log("TCPSocket", LogType.Error, ex.ToString());
}
}
// Global.Log("TCPSocket", LogType.Error, ex.ToString());
// }
//}
public IPEndPoint LocalEndPoint
{
@ -242,7 +292,7 @@ namespace Esyur.Net.Sockets
SocketType.Stream,
ProtocolType.Tcp);
receiveBuffer = new byte[sock.ReceiveBufferSize];
receiveBufferSegment = new ArraySegment<byte>(receiveBuffer);
//receiveBufferSegment = new ArraySegment<byte>(receiveBuffer);
}
@ -254,7 +304,7 @@ namespace Esyur.Net.Sockets
ProtocolType.Tcp);
receiveBuffer = new byte[sock.ReceiveBufferSize];
receiveBufferSegment = new ArraySegment<byte>(receiveBuffer);
//receiveBufferSegment = new ArraySegment<byte>(receiveBuffer);
Connect(hostname, port);
@ -336,14 +386,14 @@ namespace Esyur.Net.Sockets
{
sock = socket;
receiveBuffer = new byte[sock.ReceiveBufferSize];
receiveBufferSegment = new ArraySegment<byte>(receiveBuffer);
// receiveBufferSegment = new ArraySegment<byte>(receiveBuffer);
if (socket.Connected)
state = SocketState.Established;
}
public void Close()
{
if (state != SocketState.Closed && state != SocketState.Terminated)
if (state != SocketState.Closed)// && state != SocketState.Terminated)
{
state = SocketState.Closed;
@ -355,12 +405,19 @@ namespace Esyur.Net.Sockets
}
catch
{
state = SocketState.Terminated;
}
}
//OnClose?.Invoke();
Receiver?.NetworkClose(this);
try
{
sendBufferQueue?.Clear();
Receiver?.NetworkClose(this);
}
catch (Exception ex)
{
Global.Log(ex);
}
}
}
@ -371,13 +428,17 @@ namespace Esyur.Net.Sockets
public void Send(byte[] message, int offset, int size)
{
if (state == SocketState.Closed)// || state == SocketState.Terminated)
return;
var msg = message.Clip((uint)offset, (uint)size);
lock (sendLock)
{
if (state == SocketState.Closed)// || state == SocketState.Terminated)
return;
if (!sock.Connected)
return;
@ -390,12 +451,12 @@ namespace Esyur.Net.Sockets
asyncSending = true;
try
{
sock.BeginSend(msg, 0, msg.Length, SocketFlags.None, SendCallback, null);
sock.BeginSend(msg, 0, msg.Length, SocketFlags.None, sendCallback, this);
}
catch
{
asyncSending = false;
state = SocketState.Terminated;
//state = SocketState.Closed;//.Terminated;
Close();
}
//sock.SendAsync(new ArraySegment<byte>(msg), SocketFlags.None).ContinueWith(DataSent);
@ -404,55 +465,45 @@ namespace Esyur.Net.Sockets
}
private void SendCallback(IAsyncResult ar)
private static void Flush(TCPSocket socket)
{
if (ar != null)
lock (socket.sendLock)
{
try
{
sock.EndSend(ar);
if (ar.AsyncState != null)
((AsyncReply<bool>)ar.AsyncState).Trigger(true);
}
catch
{
if (state != SocketState.Closed && !sock.Connected)
{
state = SocketState.Terminated;
Close();
}
}
}
socket.currentReply?.Trigger(true);
socket.currentReply = null;
lock (sendLock)
{
if (sendBufferQueue.Count > 0)
if (socket.state == SocketState.Closed) //|| socket.state == SocketState.Terminated)
return;
if (socket.sendBufferQueue.Count > 0)
{
var kv = sendBufferQueue.Dequeue();
var kv = socket.sendBufferQueue.Dequeue();
try
{
sock.BeginSend(kv.Value, 0, kv.Value.Length, SocketFlags.None, SendCallback, kv.Key);
socket.currentReply = kv.Key;
socket.sock.BeginSend(kv.Value, 0, kv.Value.Length, SocketFlags.None,
socket.sendCallback, socket);
}
catch (Exception ex)
{
asyncSending = false;
socket.asyncSending = false;
try
{
if (kv.Key != null)
kv.Key.Trigger(false);
kv.Key?.Trigger(false);
if (state != SocketState.Closed && !sock.Connected)
if (socket.state != SocketState.Closed && !socket.sock.Connected)
{
state = SocketState.Terminated;
Close();
// socket.state = SocketState.Closed;// Terminated;
socket.Close();
}
}
catch (Exception ex2)
{
state = SocketState.Terminated;
socket.Close();
//socket.state = SocketState.Closed;// .Terminated;
}
Global.Log("TCPSocket", LogType.Error, ex.ToString());
@ -460,11 +511,28 @@ namespace Esyur.Net.Sockets
}
else
{
asyncSending = false;
socket.asyncSending = false;
}
}
}
private static void SendCallback(IAsyncResult ar)
{
try
{
var socket = (TCPSocket)ar.AsyncState;
socket.sock?.EndSend(ar);
Flush(socket);
}
catch (Exception ex)
{
Global.Log(ex);
}
}
public bool Trigger(ResourceTrigger trigger)
{
return true;
@ -472,16 +540,25 @@ namespace Esyur.Net.Sockets
public void Destroy()
{
Global.Counters["Sck_D_1"]++;
Close();
//OnClose = null;
//OnConnect = null;
//OnReceive = null;
Receiver = null;
receiveNetworkBuffer = null;
socketArgs.Completed -= SocketArgs_Completed;
socketArgs = null;
receiveCallback = null;
sendCallback = null;
sock = null;
receiveBuffer = null;
receiveNetworkBuffer = null;
sendBufferQueue = null;
//socketArgs.Completed -= SocketArgs_Completed;
//socketArgs.Dispose();
//socketArgs = null;
OnDestroy?.Invoke(this);
OnDestroy = null;
Global.Counters["Sck_D_2"]++;
}
public ISocket Accept()
@ -493,7 +570,7 @@ namespace Esyur.Net.Sockets
}
catch
{
state = SocketState.Terminated;
state = SocketState.Closed;// Terminated;
return null;
}
}
@ -507,7 +584,7 @@ namespace Esyur.Net.Sockets
}
catch
{
state = SocketState.Terminated;
state = SocketState.Closed;// Terminated;
return null;
}
}
@ -522,7 +599,8 @@ namespace Esyur.Net.Sockets
{
try
{
SendCallback(null);
Flush(this);
//SendCallback(null);
}
catch (Exception ex)
{
@ -537,10 +615,16 @@ namespace Esyur.Net.Sockets
public AsyncReply<bool> SendAsync(byte[] message, int offset, int length)
{
if (state == SocketState.Closed)// || state == SocketState.Terminated)
return new AsyncReply<bool>(false);
var msg = message.Clip((uint)offset, (uint)length);
lock (sendLock)
{
if (state == SocketState.Closed)// || state == SocketState.Terminated)
return new AsyncReply<bool>(false);
if (!sock.Connected)
return new AsyncReply<bool>(false);
@ -555,13 +639,14 @@ namespace Esyur.Net.Sockets
asyncSending = true;
try
{
sock.BeginSend(msg, 0, msg.Length, SocketFlags.None, SendCallback, rt);// null);
currentReply = rt;
sock.BeginSend(msg, 0, msg.Length, SocketFlags.None, sendCallback, this);// null);
}
catch (Exception ex)
{
rt.TriggerError(ex);
asyncSending = false;
state = SocketState.Terminated;
//state = SocketState.Terminated;
Close();
}
//sock.SendAsync(new ArraySegment<byte>(msg), SocketFlags.None).ContinueWith(DataSent);
@ -570,7 +655,5 @@ namespace Esyur.Net.Sockets
return rt;
}
}
}
}

View File

@ -28,15 +28,15 @@ using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using Esyur.Net.Packets;
using Esyur.Misc;
using Esiur.Net.Packets;
using Esiur.Misc;
using System.IO;
using Esyur.Core;
using Esyur.Resource;
using Esyur.Data;
using Esiur.Core;
using Esiur.Resource;
using Esiur.Data;
using System.Globalization;
namespace Esyur.Net.Sockets
namespace Esiur.Net.Sockets
{
public class WSSocket : ISocket, INetworkReceiver<ISocket>
{
@ -257,7 +257,7 @@ namespace Esyur.Net.Sockets
public void NetworkReceive(ISocket sender, NetworkBuffer buffer)
{
if (sock.State == SocketState.Closed || sock.State == SocketState.Terminated)
if (sock.State == SocketState.Closed)// || sock.State == SocketState.Terminated)
return;
if (buffer.Protected)

View File

@ -26,13 +26,13 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Net.Sockets;
using Esiur.Net.Sockets;
using System.Net;
using System.Collections;
using Esyur.Misc;
using Esyur.Data;
using Esiur.Misc;
using Esiur.Data;
namespace Esyur.Net.TCP
namespace Esiur.Net.TCP
{
public class TCPConnection:NetworkConnection {

View File

@ -27,12 +27,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Esyur.Data;
using Esyur.Net.Sockets;
using Esyur.Core;
using Esyur.Resource;
using Esiur.Data;
using Esiur.Net.Sockets;
using Esiur.Core;
using Esiur.Resource;
namespace Esyur.Net.TCP
namespace Esiur.Net.TCP
{
public abstract class TCPFilter: IResource
{

View File

@ -26,15 +26,15 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Net.Sockets;
using Esyur.Misc;
using Esiur.Net.Sockets;
using Esiur.Misc;
using System.Threading;
using Esyur.Data;
using Esyur.Core;
using Esiur.Data;
using Esiur.Core;
using System.Net;
using Esyur.Resource;
using Esiur.Resource;
namespace Esyur.Net.TCP
namespace Esiur.Net.TCP
{
public class TCPServer : NetworkServer<TCPConnection>, IResource
{
@ -51,18 +51,18 @@ namespace Esyur.Net.TCP
get;
set;
}
[Storable]
public uint Timeout
{
get;
set;
}
[Attribute]
public uint Clock
{
get;
set;
}
//[Storable]
//public uint Timeout
//{
// get;
// set;
//}
//[Attribute]
//public uint Clock
//{
// get;
// set;
//}
public Instance Instance { get; set; }
TCPFilter[] filters = null;
@ -128,7 +128,7 @@ namespace Esyur.Net.TCP
foreach (var filter in filters)
{
filter.Connected(connection);
filter.Disconnected(connection);
}
}
@ -148,7 +148,7 @@ namespace Esyur.Net.TCP
{
foreach (var filter in filters)
{
filter.Disconnected(connection);
filter.Connected(connection);
}
}

View File

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

View File

@ -28,11 +28,11 @@ using System.Linq;
using System.Text;
using System.Collections;
using System.Net;
using Esyur.Data;
using Esyur.Core;
using Esyur.Resource;
using Esiur.Data;
using Esiur.Core;
using Esiur.Resource;
namespace Esyur.Net.UDP
namespace Esiur.Net.UDP
{
public abstract class UDPFilter : IResource
{

View File

@ -28,12 +28,12 @@ using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.Collections;
using Esyur.Data;
using Esyur.Misc;
using Esyur.Resource;
using Esyur.Core;
using Esiur.Data;
using Esiur.Misc;
using Esiur.Resource;
using Esiur.Core;
namespace Esyur.Net.UDP
namespace Esiur.Net.UDP
{
/* public class IIPConnection

View File

@ -7,7 +7,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Debug</Configuration>
<TargetFramework>netstandard2.0</TargetFramework>
<PublishDir>M:\opt\Esyur</PublishDir>
<PublishDir>M:\opt\Esiur</PublishDir>
<Platform>Any CPU</Platform>
</PropertyGroup>
</Project>

View File

@ -1,4 +1,4 @@
using Esyur.Resource;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Linq;
@ -6,7 +6,7 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Text;
namespace Esyur.Proxy
namespace Esiur.Proxy
{
public static class ResourceProxy
{
@ -34,7 +34,7 @@ namespace Esyur.Proxy
else
return type;
if (type.FullName.Contains("Esyur.Proxy.T"))
if (type.FullName.Contains("Esiur.Proxy.T"))
#if NETSTANDARD
return type.GetTypeInfo().BaseType;
#else
@ -57,7 +57,7 @@ namespace Esyur.Proxy
throw new Exception("Sealed/Abastract classes can't be proxied.");
var props = from p in typeInfo.GetProperties(BindingFlags.Instance | BindingFlags.Public)
where p.CanWrite && p.SetMethod.IsVirtual &&
where p.CanWrite && p.SetMethod.IsVirtual && !p.SetMethod.IsFinal &&
p.GetCustomAttribute<PublicAttribute>(false) != null
select p;
@ -71,14 +71,14 @@ namespace Esyur.Proxy
select p;
#endif
var assemblyName = new AssemblyName("Esyur.Proxy.T." + type.Assembly.GetName().Name);// type.Namespace);
var assemblyName = new AssemblyName("Esiur.Proxy.T." + type.Assembly.GetName().Name);// type.Namespace);
assemblyName.Version = type.Assembly.GetName().Version;
assemblyName.CultureInfo = type.Assembly.GetName().CultureInfo;
//assemblyName.SetPublicKeyToken(null);
var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
var moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name);
var typeName = "Esyur.Proxy.T." + type.FullName;// Assembly.CreateQualifiedName(assemblyName.FullName, "Esyur.Proxy.T." + type.FullName);
var typeName = "Esiur.Proxy.T." + type.FullName;// Assembly.CreateQualifiedName(assemblyName.FullName, "Esiur.Proxy.T." + type.FullName);
var typeBuilder = moduleBuilder.DefineType(typeName,
TypeAttributes.Public | TypeAttributes.Class, type);
@ -186,7 +186,7 @@ namespace Esyur.Proxy
// IL_0000: ldarg.0
//IL_0001: call instance class [Esyur]Esyur.Resource.Instance [Esyur]Esyur.Resource.Resource::get_Instance()
//IL_0001: call instance class [Esiur]Esiur.Resource.Instance [Esiur]Esiur.Resource.Resource::get_Instance()
//// (no C# code)
//IL_0006: dup
//IL_0007: brtrue.s IL_000c
@ -195,7 +195,7 @@ namespace Esyur.Proxy
//IL_000a: br.s IL_0017
//// (no C# code)
//IL_000c: ldstr "Level3"
//IL_0011: call instance void [Esyur]Esyur.Resource.Instance::Modified(string)
//IL_0011: call instance void [Esiur]Esiur.Resource.Instance::Modified(string)
//IL_0016: nop
//IL_0017: ret
@ -208,9 +208,9 @@ namespace Esyur.Proxy
// IL_0000: ldarg.0
// IL_0001: call instance class [Esyur]Esyur.Resource.Instance [Esyur]Esyur.Resource.Resource::get_Instance()
// IL_0001: call instance class [Esiur]Esiur.Resource.Instance [Esiur]Esiur.Resource.Resource::get_Instance()
// IL_0006: ldstr "Level3"
//IL_000b: callvirt instance void [Esyur]Esyur.Resource.Instance::Modified(string)
//IL_000b: callvirt instance void [Esiur]Esiur.Resource.Instance::Modified(string)
//IL_0010: ret

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Resource
namespace Esiur.Resource
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Event)]

View File

@ -27,7 +27,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Resource
namespace Esiur.Resource
{
[AttributeUsage(AttributeTargets.Property)]

View File

@ -26,11 +26,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esyur.Data;
using Esyur.Core;
using Esiur.Data;
using Esiur.Core;
using System.ComponentModel;
namespace Esyur.Resource
namespace Esiur.Resource
{
public delegate bool QueryFilter<T>(T value);

View File

@ -22,18 +22,18 @@ SOFTWARE.
*/
using Esyur.Data;
using Esyur.Core;
using Esyur.Resource.Template;
using Esiur.Data;
using Esiur.Core;
using Esiur.Resource.Template;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Esyur.Security.Permissions;
using Esyur.Security.Authority;
using Esiur.Security.Permissions;
using Esiur.Security.Authority;
namespace Esyur.Resource
namespace Esiur.Resource
{
public interface IStore:IResource
{

View File

@ -3,18 +3,18 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Esyur.Data;
using Esiur.Data;
using System.Runtime.CompilerServices;
using System.Reflection;
using Esyur.Net.IIP;
using Esyur.Misc;
using Esyur.Security.Permissions;
using Esyur.Resource.Template;
using Esyur.Security.Authority;
using Esyur.Proxy;
using Esyur.Core;
using Esiur.Net.IIP;
using Esiur.Misc;
using Esiur.Security.Permissions;
using Esiur.Resource.Template;
using Esiur.Security.Authority;
using Esiur.Proxy;
using Esiur.Core;
namespace Esyur.Resource
namespace Esiur.Resource
{
public class Instance
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Resource
namespace Esiur.Resource
{
public class PrivateAttribute:Attribute
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Esyur.Resource
namespace Esiur.Resource
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Event | AttributeTargets.Class)]

View File

@ -24,9 +24,9 @@ SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using Esyur.Core;
using Esiur.Core;
namespace Esyur.Resource
namespace Esiur.Resource
{
public class Resource : IResource
{

View File

@ -27,7 +27,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Resource
namespace Esiur.Resource
{
[AttributeUsage(AttributeTargets.Event)]

View File

@ -21,17 +21,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
using Esyur.Data;
using Esyur.Core;
using Esyur.Net.IIP;
using Esyur.Security.Authority;
using Esiur.Data;
using Esiur.Core;
using Esiur.Net.IIP;
using Esiur.Security.Authority;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Resource
namespace Esiur.Resource
{
public delegate void ResourceEventHanlder(params object[] args);
// public delegate void CustomUsersEventHanlder(string[] usernames, params object[] args);

View File

@ -28,7 +28,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esyur.Resource
namespace Esiur.Resource
{
[AttributeUsage(AttributeTargets.Method)]
public class ResourceFunction : System.Attribute

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