A code fragement explains all (I hope):
public class MyRegister
{
private List<IToken> tokens = new List<IToken>();
public void HasService<T>()
{
tokens.Add(new MyToken<T>());
}
public object[] UseRegisteredGenericTypes()
{
List<object> results = new List<object>();
foreach (var token in tokens)
{
results.Add(token.DoSomethingWithMyType());
}
return results.ToArray();
}
}
public class MyToken<T> : IToken
{
public object DoSomethingWithMyType()
{
// Do the stuff here like ... return myApp.DoStuff<T>();
}
}
No comments:
Post a Comment