internal virtual bool TryGetEnumMember(EnumType type, String memberName, bool ignoreCase, out EnumMember outMember)
 {
     //Contract.Requires(type != null);
     EntityUtil.CheckStringArgument(memberName, "memberName");
     outMember = null;
     return type.Members.TryGetValue(memberName, ignoreCase, out outMember);
 }
Beispiel #2
0
 internal bool TryGetEnumMember(EnumType type, String memberName, bool ignoreCase, out EnumMember outMember)
 {
     EntityUtil.CheckArgumentNull(type, "type");
     EntityUtil.CheckStringArgument(memberName, "memberName");
     outMember = null;
     return type.Members.TryGetValue(memberName, ignoreCase, out outMember);
 }
 internal MetadataEnumMember(string name, TypeUsage enumType, EnumMember enumMember)
     : base(MetadataMemberClass.EnumMember, name)
 {
     Debug.Assert(enumType != null, "enumType must not be null");
     Debug.Assert(enumMember != null, "enumMember must not be null");
     EnumType = enumType;
     EnumMember = enumMember;
 }
        /// <summary>
        /// Adds the specified member to the member collection
        /// </summary>
        /// <param name="enumMember">Enumeration member to add to the member collection.</param>
        internal void AddMember(EnumMember enumMember)
        {
            Debug.Assert(enumMember != null, "enumMember != null");
            Debug.Assert(Helper.IsEnumMemberValueInRange(UnderlyingType.PrimitiveTypeKind, Convert.ToInt64(enumMember.Value, CultureInfo.InvariantCulture)));
            Debug.Assert(enumMember.Value.GetType() == UnderlyingType.ClrEquivalentType);

            this.Members.Source.Add(enumMember);
        }
        /// <summary>
        /// Converts SchemaEnumType instance to Metadata EnumType.
        /// </summary>
        /// <param name="somEnumType">SchemaEnumType to be covnerted.</param>
        /// <param name="newGlobalItems">Global item objects where newly created Metadata EnumType will be added.</param>
        /// <returns></returns>
        private static EnumType ConvertToEnumType(Som.SchemaEnumType somEnumType, Dictionary<Som.SchemaElement, GlobalItem> newGlobalItems)
        {
            Debug.Assert(somEnumType != null, "somEnumType != null");
            Debug.Assert(newGlobalItems != null, "newGlobalItems != null");
            Debug.Assert(somEnumType.UnderlyingType is Som.ScalarType, "At this point the underlying type should have already been validated and should be ScalarType");

            Som.ScalarType enumUnderlyingType = (Som.ScalarType)somEnumType.UnderlyingType;

            // note that enums don't live in SSpace so there is no need to GetDataSpace() for it.
            EnumType enumType = new EnumType(somEnumType.Name,
                                             somEnumType.Namespace,
                                             enumUnderlyingType.Type,
                                             somEnumType.IsFlags,
                                             DataSpace.CSpace);

            Type clrEnumUnderlyingType = enumUnderlyingType.Type.ClrEquivalentType;

            foreach (var somEnumMember in somEnumType.EnumMembers)
            {
                Debug.Assert(somEnumMember.Value != null, "value must not be null at this point");
                var enumMember = new EnumMember(somEnumMember.Name, Convert.ChangeType(somEnumMember.Value, clrEnumUnderlyingType, CultureInfo.InvariantCulture));

                if (somEnumMember.Documentation != null)
                {
                    enumMember.Documentation = ConvertToDocumentation(somEnumMember.Documentation);
                }

                AddOtherContent(somEnumMember, enumMember);
                enumType.AddMember(enumMember);
            }

            if (somEnumType.Documentation != null)
            {
                enumType.Documentation = ConvertToDocumentation(somEnumType.Documentation);
            }
            AddOtherContent(somEnumType, enumType);

            newGlobalItems.Add(somEnumType, enumType);
            return enumType;
        }
        protected override void Visit(EnumMember enumMember)
        {
            int index;
            if (!this.AddObjectToSeenListAndHashBuilder(enumMember, out index))
            {
                return;
            }

            this.AddObjectStartDumpToHashBuilder(enumMember, index);

            this.AddObjectContentToHashBuilder(enumMember.Name);
            this.AddObjectContentToHashBuilder(enumMember.Value);

            base.Visit(enumMember);

            this.AddObjectEndDumpToHashBuilder();
        }
 protected virtual void Visit(EnumMember enumMember)
 {
 }
 internal bool TryGetEnumMember(EnumType type, String memberName, bool ignoreCase, out EnumMember outMember)
 {
     EntityUtil.CheckArgumentNull(type, "type");
     EntityUtil.CheckStringArgument(memberName, "memberName");
     outMember = null;
     return(type.Members.TryGetValue(memberName, ignoreCase, out outMember));
 }