I've just thrown this small sample together which demonstrates how to fetch the static fields from an abstract generic class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace AbstractGeneric
{
class Program
{
static void Main(string[] args)
{
Type myAbstractGenericType = typeof(AbstractGeneric<>);
Type[] types = { typeof(int) };
Type constructed = myAbstractGenericType.MakeGenericType(types);
FieldInfo[] fieldInfos = constructed.GetFields(
BindingFlags.NonPublic |
BindingFlags.Public |
BindingFlags.Static);
foreach (FieldInfo fi in fieldInfos)
{
Console.WriteLine("Name: {0} Value: {1}", fi.Name, fi.GetValue(null));
}
Console.ReadLine();
}
}
public abstract class AbstractGeneric<T>
{
private static int anInt = 12345;
private static String aString = "XXYYZZ";
public abstract T WhatEver { get; set; }
}
}
I hope this will help you. If you have any questions regarding this, feel free to add a comment below.
Best Regards,
—MRB