Using ICommand interface
I have a class that implements specific interface (IOrganicEnvironment<T, K>
)
public class Colorizator : IOrganicEnvironment<Cell<YUV>, YUV>, ICommand
{
// ..
}
And also it implements ICommand iterface
public interface ICommand
{
void Execute();
}
IOrganicEnvironment<T, K>
interface provides a bunch of methods and properties I'm mostly going to use inside ICommand Execute()
method.
But I don't need any client code to invoke that methods and properties from开发者_运维知识库 Colorizator
instance.
What can/should I do? If I implement the interface explicitly
and make it internal
will this help?
I think using composition would be better idea.
public class Colorizator : IOrganicEnvironment<Cell<YUV>, YUV>>
{
// normal code here
}
public class ColorizatorCommand : ICommand
{
private Colorizator _colorizator;
public ColorizatorCommand(Colorizator colorizator)
{
_colorizator = colorizator;
}
public void Execute()
{
//use _colorizator here;
}
}
精彩评论