So, first I have my command property interface
public interface ICommandProperty<T, U>
{
Func<T> CreateCommand { get; set; }
Func<T, U> ParseResponse { get; set; }
}
The idea is that I can create a simple parser that takes a string and returns an IPAddress for example.
This interface is then used in another interface:
public interface IDeviceCommand
{
Func<ICommandProperty<object, object>> SetCommand
{
get;
set;
}
Func<ICommandProperty<object, object>> GetCommand
{
get;
set;
}
string Name { get; set; }
}
I may be going about this all wrong, but this is where I have the problem. Currently I have the generic interface declared with objects because I can't figure out a way to set them generically(IDeviceCommand can't be generic for various reasons).
My concrete implementation looks like this:
public class DeviceCommand:IDeviceCommand
{
public DeviceCommand(string name,Func<ICommandProperty<object,object>> Set,Func<ICommandProperty<object,object>> Get)
{
this.Name = name;
this.SetCommand = Set;
this.GetCommand = Get;
}
#region IDeviceCommand Members
public string Name
{
get;
set;
}
public object Value
{
get;
set;
}
public Func<ICommandProperty<object, object>> SetCommand
{
get;
set;
}
public Func<ICommandProperty<object, object>> GetCommand
{
get;
set;
}
#endregion
}
I could make DeviceCommand be a generic class, and use T,U on the SetCommand and GetCommand, but then it doesn't satisfy the IDeviceCommand interface because Func<ICommandProperty<T,U>> isn't Func<ICommandProperty<object,object>>
Is there a different approach that I should be using here. In essence I'm trying to create a method pointer that I can set when I instantiate DeviceCommand.