mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-06-26 21:13:13 +00:00
flow
This commit is contained in:
@ -257,9 +257,9 @@ public static class Codec
|
||||
{
|
||||
|
||||
var genericType = type.GetGenericTypeDefinition();
|
||||
if (genericType == typeof(DistributedPropertyContext<>))
|
||||
if (genericType == typeof(PropertyContext<>))
|
||||
{
|
||||
valueOrSource = ((IDistributedPropertyContext)valueOrSource).GetValue(connection);
|
||||
valueOrSource = ((IPropertyContext)valueOrSource).GetValue(connection);
|
||||
}
|
||||
else if (genericType == typeof(Func<>))
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ namespace Esiur.Data
|
||||
|
||||
public UUID(byte[] data, uint offset)
|
||||
{
|
||||
if (offset + 16 < data.Length)
|
||||
if (offset + 16 > data.Length)
|
||||
throw new Exception("UUID data size must be at least 16 bytes");
|
||||
|
||||
Data = DC.Clip(data, offset, 16);
|
||||
|
@ -1909,7 +1909,7 @@ partial class DistributedConnection
|
||||
|
||||
|
||||
if (pi.PropertyType.IsGenericType && pi.PropertyType.GetGenericTypeDefinition()
|
||||
== typeof(DistributedPropertyContext<>))
|
||||
== typeof(PropertyContext<>))
|
||||
{
|
||||
value = Activator.CreateInstance(pi.PropertyType, this, value);
|
||||
//value = new DistributedPropertyContext(this, value);
|
||||
|
@ -4,30 +4,30 @@ using System.Text;
|
||||
|
||||
namespace Esiur.Net.IIP;
|
||||
|
||||
public interface IDistributedPropertyContext
|
||||
public interface IPropertyContext
|
||||
{
|
||||
object GetValue(DistributedConnection connection);
|
||||
}
|
||||
|
||||
public class DistributedPropertyContext<T> : IDistributedPropertyContext
|
||||
public class PropertyContext<T> : IPropertyContext
|
||||
{
|
||||
public T Value { get; private set; }
|
||||
public DistributedConnection Connection { get; private set; }
|
||||
public Func<DistributedConnection, T> Method { get; private set; }
|
||||
|
||||
public DistributedPropertyContext(DistributedConnection connection, T value)
|
||||
public PropertyContext(DistributedConnection connection, T value)
|
||||
{
|
||||
this.Value = value;
|
||||
this.Connection = connection;
|
||||
}
|
||||
|
||||
public DistributedPropertyContext(Func<DistributedConnection, T> method)
|
||||
public PropertyContext(Func<DistributedConnection, T> method)
|
||||
{
|
||||
this.Method = method;
|
||||
}
|
||||
|
||||
public static implicit operator DistributedPropertyContext<T>(Func<DistributedConnection, T> method)
|
||||
=> new DistributedPropertyContext<T>(method);
|
||||
public static implicit operator PropertyContext<T>(Func<DistributedConnection, T> method)
|
||||
=> new PropertyContext<T>(method);
|
||||
|
||||
public object GetValue(DistributedConnection connection)
|
||||
{
|
@ -352,7 +352,7 @@ public class Instance
|
||||
*/
|
||||
|
||||
if (pt.PropertyInfo.PropertyType.IsGenericType
|
||||
&& pt.PropertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(DistributedPropertyContext<>))
|
||||
&& pt.PropertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(PropertyContext<>))
|
||||
return false;
|
||||
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class PropertyTemplate : MemberTemplate
|
||||
{
|
||||
var genericPropType = pi.PropertyType.IsGenericType ? pi.PropertyType.GetGenericTypeDefinition() : null;
|
||||
|
||||
var propType = genericPropType == typeof(DistributedPropertyContext<>) ?
|
||||
var propType = genericPropType == typeof(PropertyContext<>) ?
|
||||
RepresentationType.FromType(pi.PropertyType.GetGenericArguments()[0]) :
|
||||
RepresentationType.FromType(pi.PropertyType);
|
||||
|
||||
@ -174,7 +174,7 @@ public class PropertyTemplate : MemberTemplate
|
||||
//var nullableAttr = pi.GetCustomAttribute<NullableAttribute>(true);
|
||||
//var flags = ((byte[]) nullableAttr?.NullableFlags ?? new byte[0]).ToList();
|
||||
|
||||
if (nullableAttrFlags.Count > 0 && genericPropType == typeof(DistributedPropertyContext<>))
|
||||
if (nullableAttrFlags.Count > 0 && genericPropType == typeof(PropertyContext<>))
|
||||
nullableAttrFlags.RemoveAt(0);
|
||||
|
||||
if (nullableContextAttrFlag == 2)
|
||||
|
@ -191,7 +191,7 @@ public class TypeTemplate
|
||||
var genericTypeArgs = type.GetGenericArguments();
|
||||
|
||||
if (genericType == typeof(List<>)
|
||||
|| genericType == typeof(DistributedPropertyContext<>))
|
||||
|| genericType == typeof(PropertyContext<>))
|
||||
{
|
||||
return GetDistributedTypes(genericTypeArgs[0]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user