атрибуты до тестирования сериализации.

аюсь разработать приложение, которое позволит пользователю указывать тип Enum в XML, и из этого приложение будет выполнять определенный метод, связанный с этим перечислением (используя словарь). Я зациклен на части Enum XML.

public class TESTCLASS
{
    private Enum _MethodType;

    [XmlElement(Order = 1, ElementName = "MethodType")]
    public Enum MethodType
    {
        get { return _MethodType; }
        set { _MethodType = value; } 
    }
    public TESTCLASS() { }

    public TESTCLASS(Enummies.BigMethods bigM)
    {
        MethodType = bigM;
    }
    public TESTCLASS(Enummies.SmallMethods smallM)
    {
        MethodType = smallM;
    }
}

public class Enummies
{
    public enum BigMethods { BIG_ONE, BIG_TWO, BIG_THREE }
    public enum SmallMethods { SMALL_ONE, SMALL_TWO, SMALL_THREE }
}

А затем попытка сериализации TESTCLASS приводит к исключению:

string p = "C:\\testclass.xml";
TESTCLASS testclass = new TESTCLASS(Enummies.BigMethods.BIG_ONE);
TestSerializer<TESTCLASS>.Serialize(p, testclass);

System.InvalidOperationException: The type Enummies+BigMethods may not be used in this context.

Мой метод сериализации выглядит так:

public class TestSerializer<T> where T: class
{
    public static void Serialize(string path, T type)
    {
        var serializer = new XmlSerializer(type.GetType());
        using (var writer = new FileStream(path, FileMode.Create))
        {
            serializer.Serialize(writer, type);
        }
    }

    public static T Deserialize(string path)
    {
        T type;
        var serializer = new XmlSerializer(typeof(T));
        using (var reader = XmlReader.Create(path))
        {
            type = serializer.Deserialize(reader) as T;
        }
        return type;
    }
}

Я попытался включить некоторые проверки / приведение в метод GetType, но это приводит к той же ошибке.

    public Enum MethodType
    {
        get 
        { 
            if (_MethodType is Enummies.BigMethods) return (Enummies.BigMethods)_MethodType; 
            if (_MethodType is Enummies.SmallMethods) return (Enummies.SmallMethods)_MethodType;
            throw new Exception("UNKNOWN ENUMMIES TYPE");
        }
        set { _MethodType = value; } 
    }

Ответы на вопрос(1)

Ваш ответ на вопрос