2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-03-31 18:38:22 +00:00
Files
esiur-dotnet/Esiur/Protocol/PropertyContext.cs
2026-03-17 22:15:43 +03:00

37 lines
902 B
C#

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);
}
}