mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-03-31 18:38:22 +00:00
renaming 2
This commit is contained in:
36
Esiur/Protocol/PropertyContext.cs
Normal file
36
Esiur/Protocol/PropertyContext.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Protocol;
|
||||
|
||||
public interface IPropertyContext
|
||||
{
|
||||
object GetValue(EpConnection connection);
|
||||
}
|
||||
|
||||
public class PropertyContext<T> : IPropertyContext
|
||||
{
|
||||
public T Value { get; private set; }
|
||||
public EpConnection Connection { get; private set; }
|
||||
public Func<EpConnection, T> Method { get; private set; }
|
||||
|
||||
public PropertyContext(EpConnection connection, T value)
|
||||
{
|
||||
this.Value = value;
|
||||
this.Connection = connection;
|
||||
}
|
||||
|
||||
public PropertyContext(Func<EpConnection, T> method)
|
||||
{
|
||||
this.Method = method;
|
||||
}
|
||||
|
||||
public static implicit operator PropertyContext<T>(Func<EpConnection, T> method)
|
||||
=> new PropertyContext<T>(method);
|
||||
|
||||
public object GetValue(EpConnection connection)
|
||||
{
|
||||
return Method.Invoke(connection);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user