示例#1
0
        public EnumOrFlagsDefinition(BinaryFormatFile file, Boolean isFlagsDefinition, NamedObjectDefinition objectDefinedIn,
                                     BinaryFormatType underlyingIntegerType, String typeName)
        {
            this.isFlagsDefinition = isFlagsDefinition;
            this.isGlobalType      = (objectDefinedIn == null);

            this.underlyingIntegerType = underlyingIntegerType;
            this.byteCount             = underlyingIntegerType.IntegerTypeByteCount();

            this.typeName = typeName;
            this.typeNameLowerInvariantCase        = typeName.ToLowerInvariant();
            this.globalReferenceNameLowerInvariant = (objectDefinedIn == null) ? typeNameLowerInvariantCase :
                                                     (objectDefinedIn.globalReferenceNameLowerInvariant + "." + typeNameLowerInvariantCase);

            //
            // Add the definition to the static flags or enum definitions list
            //
            if (isFlagsDefinition)
            {
                enumValues = null;
                flagValues = new List <FlagsValueDefinition>();
            }
            else
            {
                enumValues = new List <EnumValueDefinition>();
                flagValues = null;
            }

            //
            // Add the defintion to the object and the file
            //
            if (objectDefinedIn != null)
            {
                objectDefinedIn.AddEnumOrFlagDefinition(this);
            }
            file.AddEnumOrFlagsDefinition(this);
        }