예제 #1
0
        // A bit clumsy but better than full-blown reflection use or an open set of Create* methods for each
        // type we support now or in the future
        protected virtual T CreateHierarchyElement <T> (HierarchyBase parent) where T : HierarchyElement
        {
            Type          type = typeof(T);
            HierarchyBase ret  = null;

            if (type == typeof(HierarchyNamespace))
            {
                ret = new HierarchyNamespace(Context, parent as Hierarchy);
            }
            else if (type == typeof(HierarchyClass))
            {
                ret = new HierarchyClass(Context, parent as HierarchyNamespace);
            }
            else if (type == typeof(HierarchyImplements))
            {
                ret = new HierarchyImplements(Context, parent as HierarchyObject);
            }
            else if (type == typeof(HierarchyMethod))
            {
                ret = new HierarchyMethod(Context, parent as HierarchyObject);
            }
            else if (type == typeof(HierarchyConstructor))
            {
                ret = new HierarchyConstructor(Context, parent as HierarchyObject);
            }
            else if (type == typeof(HierarchyException))
            {
                ret = new HierarchyException(Context, parent as HierarchyMethod);
            }
            else if (type == typeof(HierarchyTypeParameter))
            {
                ret = new HierarchyTypeParameter(Context, parent as HierarchyElement);
            }
            else if (type == typeof(HierarchyTypeParameterGenericConstraint))
            {
                ret = new HierarchyTypeParameterGenericConstraint(Context, parent as HierarchyTypeParameter);
            }
            else if (type == typeof(HierarchyMethodParameter))
            {
                ret = new HierarchyMethodParameter(Context, parent as HierarchyMethod);
            }
            else if (type == typeof(HierarchyField))
            {
                ret = new HierarchyField(Context, parent as HierarchyObject);
            }
            else if (type == typeof(HierarchyInterface))
            {
                ret = new HierarchyInterface(Context, parent as HierarchyNamespace);
            }
            else if (type == typeof(HierarchyEnum))
            {
                ret = new HierarchyEnum(Context, parent as Hierarchy);
            }
            else
            {
                throw new InvalidOperationException($"Unsupported hierarchy element type {type}");
            }

            return(ret as T);
        }
예제 #2
0
 protected abstract EnumCodeGenerator GetEnumGenerator(HierarchyEnum enm);
예제 #3
0
 public abstract void AddMember(HierarchyEnum enm);