mirror of
				https://github.com/esiur/esiur-dotnet.git
				synced 2025-10-30 23:51:34 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			964 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			964 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Text;
 | |
| 
 | |
| namespace Esiur.Net.IIP;
 | |
| 
 | |
| public interface IPropertyContext
 | |
| {
 | |
|     object GetValue(DistributedConnection connection);
 | |
| }
 | |
| 
 | |
| 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 PropertyContext(DistributedConnection connection, T value)
 | |
|     {
 | |
|         this.Value = value;
 | |
|         this.Connection = connection;
 | |
|     }
 | |
| 
 | |
|     public PropertyContext(Func<DistributedConnection, T> method)
 | |
|     {
 | |
|         this.Method = method;
 | |
|     }
 | |
| 
 | |
|     public static implicit operator PropertyContext<T>(Func<DistributedConnection, T> method)
 | |
|                                     => new PropertyContext<T>(method);
 | |
| 
 | |
|     public object GetValue(DistributedConnection connection)
 | |
|     {
 | |
|         return Method.Invoke(connection);
 | |
|     }
 | |
| }
 |