Unfortunately many XNA sites have gone down recently, If you know any, please do list them here and I can check to see if the wayback machine has cached them, er or you could also do that and link those sitesā¦
I found this snippet below.
When trying to figure out how to do a compile time type inference on another instance and store it. When within a derived class that is inheriting from a abstract base. Which meant the former had to take a unknown generic type and hold it at compile time while still acting like a proper derivitive of the abstract base. So that it could still be a child or parent node of any other type that derived from the abstract type or act as one itself.
Crazy anyways.
This helped a lot.
// infer type without reflection.
public static class TargetTypeInferenceExtension
{
public class TargetType<T>
{
public T Target { get; set; }
public TargetType(T wrappedInstance)
{
Target = wrappedInstance;
}
}
public static TargetType<T> GetTarget<T>(this T itemInstance)
{
return Create(itemInstance);
}
private static TargetType<T> Create<T>(T itemInstance)
{
return new TargetType<T>(itemInstance);
}
}