Exemplo n.º 1
0
            internal EnumDataContractCriticalHelper(Type type) : base(type)
            {
                DataContractAttribute attribute;

                base.StableName = DataContract.GetStableName(type, out this.hasDataContract);
                Type underlyingType = Enum.GetUnderlyingType(type);

                this.baseContractName = GetBaseContractName(underlyingType);
                this.ImportBaseType(underlyingType);
                this.IsFlags = type.IsDefined(Globals.TypeOfFlagsAttribute, false);
                this.ImportDataMembers();
                XmlDictionary dictionary = new XmlDictionary(2 + this.Members.Count);

                base.Name              = dictionary.Add(base.StableName.Name);
                base.Namespace         = dictionary.Add(base.StableName.Namespace);
                this.childElementNames = new XmlDictionaryString[this.Members.Count];
                for (int i = 0; i < this.Members.Count; i++)
                {
                    this.childElementNames[i] = dictionary.Add(this.Members[i].Name);
                }
                if (DataContract.TryGetDCAttribute(type, out attribute) && attribute.IsReference)
                {
                    DataContract.ThrowInvalidDataContractException(System.Runtime.Serialization.SR.GetString("EnumTypeCannotHaveIsReference", new object[] { DataContract.GetClrTypeFullName(type), attribute.IsReference, false }), type);
                }
            }