I have custom control and I have interface this control exposes to it’s users.
public interface ILookupDataProvider
{
void GetDataAsync(string parameters, Action<IEnumerable<object>> onSuccess, Action<Exception> onError);
}
Need to implement it like so:
public class LookupDataProvider<T> : ILookupDataProvider
{
public void GetDataAsync(string parameters, Action<IEnumerable<T>> onSuccess, Action<Exception> onError)
{
var query = new EntityQuery<T>();
this.entityManager.ExecuteQueryAsync(
query,
op =>
{
if (op.CompletedSuccessfully)
{
onSuccess(op.Results);
}
else if (op.HasError)
{
onError(op.Error);
}
});
}
}
So, how do I tell that this generic method is really implementation of interface?
If you can change the class to be a generic method you could do this:
Edit
In regards to Kirk’s comment you need to move the type parameter on the method. While you could leave it on the class as well that can lead to interesting things. Run this code for example:
This actually is a warning (and I’m surprised it’s not considered an exception)