I have a special need that I cannot understand. I did some research on this, but cannot find an acceptable solution.
I have a base class:
public abstract class BaseProvider<T> {}
this class, in turn, is inherited by two different provider classes:
public sealed class MonkeyProvider<T>
: BaseProvider<MonkeyProvider<T>>
where T
: IAnimalProvider
Inside the IAnimalProvider interface, I set one property that all implementations should output. Now MonkeyProvider, and possibly DonkeyProvider or something similar, should know what the assigned value for the property is for the root instance:
public class JoburgZoo
: IAnimalProvider
{
#region IAnimalProvider members
public string Id{ get; set; }
#endregion
}
public static void Main(string[] args)
{
JoburgZoo zoo = new JoburgZoo();
zoo.Id = "Mammals";
**
MonkeyProvider<JoburgZoo> mp = new MonkeyProvider<JoburgZoo>();
mp.CheckMonkeys(zoo);
}
Now, here is my question:
BaseProvider, , . "Id" , , , (, , ).
:
Type type = typeof(T);
var generic = type.GetGenericTypeDefinition();
T, , . , BaseProvider.
.
//.
. MonkeyProvider<T> JoburgZoo, ProviderBase<T> :
ProviderBase<MonkeyProvider<JoburgZoo>>
, JoburgZoo , BaseProvider<T> MonkeyProvider<T>.
, .