mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-06-27 21:43:13 +00:00
2.2
This commit is contained in:
@ -3,23 +3,34 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Net.IIP;
|
||||
public class DistributedPropertyContext
|
||||
{
|
||||
public object Value { get; private set; }
|
||||
public DistributedConnection Connection { get; private set; }
|
||||
public Func<DistributedConnection, object> Method { get; private set; }
|
||||
|
||||
public DistributedPropertyContext(DistributedConnection connection, object value)
|
||||
public interface IDistributedPropertyContext
|
||||
{
|
||||
object GetValue(DistributedConnection connection);
|
||||
}
|
||||
|
||||
public class DistributedPropertyContext<T> : IDistributedPropertyContext
|
||||
{
|
||||
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)
|
||||
{
|
||||
this.Value = value;
|
||||
this.Connection = connection;
|
||||
}
|
||||
|
||||
public DistributedPropertyContext(Func<DistributedConnection, object> method)
|
||||
public DistributedPropertyContext(Func<DistributedConnection, T> method)
|
||||
{
|
||||
this.Method = method;
|
||||
}
|
||||
|
||||
public static implicit operator DistributedPropertyContext(Func<DistributedConnection, object> method)
|
||||
=> new DistributedPropertyContext(method);
|
||||
public static implicit operator DistributedPropertyContext<T>(Func<DistributedConnection, T> method)
|
||||
=> new DistributedPropertyContext<T>(method);
|
||||
|
||||
public object GetValue(DistributedConnection connection)
|
||||
{
|
||||
return Method.Invoke(connection);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user