EDITED to show real example
How can I call a generic function from a generic type passed to a function? This seems like it should be intuitive, but I can’t seem to get it to work.
For example, can I call the cache.ResetCache() function in LocalDataObjectEngine below?
The error I’m getting is ‘Type T cannot be used as a parameter’
public interface ISimpleCache<T1> { ... void ResetCache<T>() where T : T1; } internal class LocalDataObjectEngine_Cache : ISimpleCache<IBrokeredDataObject> { ISimpleCache<IBrokeredDataObject> _cache; ... public void ResetCache<T>() where T : IBrokeredDataObject { //logic here } ... } public partial class LocalDataObjectEngine : IEngine { ISimpleCache<IBrokeredDataObject> _cache = new LocalDataObjectEngine_Cache(); public void ResetCache<T>() where T : IBrokeredDataObject { _cache.ResetCache<T>(); } } }
Found it, Jon Skeet’s reference to removing IEngine pointed me in the right direction, there was a
on IEngine (IDataObject is a base if IBrokeredDataObject), that I changed to
Thanks all for tolerating my bug, +1 to you all