Ejemplo n.º 1
0
    private Dictionary <NodeDescription.Type, List <System.Type> > GetNodeTypes()
    {
        Dictionary <NodeDescription.Type, List <System.Type> > types = new Dictionary <NodeDescription.Type, List <System.Type> >();

        List <System.Type> marrowTypes = new List <System.Type>();

        System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly(typeof(MarrowNode));
        foreach (System.Type type in assembly.GetTypes())
        {
            if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(MarrowNode)))
            {
                marrowTypes.Add(type);
            }
        }

        foreach (var v in System.Enum.GetValues(typeof(NodeDescription.Type)))
        {
            NodeDescription.Type t = (NodeDescription.Type)v;
            types.Add(t, new List <System.Type>());
        }

        foreach (System.Type type in marrowTypes)
        {
            NodeDescription attr = (NodeDescription)System.Attribute.GetCustomAttribute(type, typeof(NodeDescription));
            types[attr.GetNodeType()].Add(type);
        }

        return(types);
    }