private IEnumerable <IEdmEnumMember> ComputeMembers() { IEdmEnumMember csdlSemanticsEnumMember; List <IEdmEnumMember> edmEnumMembers = new List <IEdmEnumMember>(); long value = (long)-1; foreach (CsdlEnumMember member in this.enumeration.Members) { long?nullable = member.Value; if (nullable.HasValue) { long?value1 = member.Value; value = value1.Value; csdlSemanticsEnumMember = new CsdlSemanticsEnumMember(this, member); csdlSemanticsEnumMember.SetIsValueExplicit(this.Model, new bool?(true)); } else { if (value >= 0x7fffffffffffffffL) { CsdlSemanticsEnumTypeDefinition csdlSemanticsEnumTypeDefinition = this; string name = member.Name; EdmError[] edmErrorArray = new EdmError[1]; EdmError[] edmError = edmErrorArray; int num = 0; EdmLocation location = member.Location; EdmLocation edmLocation = location; if (location == null) { edmLocation = base.Location; } edmError[num] = new EdmError(edmLocation, EdmErrorCode.EnumMemberValueOutOfRange, Strings.CsdlSemantics_EnumMemberValueOutOfRange); csdlSemanticsEnumMember = new BadEnumMember(csdlSemanticsEnumTypeDefinition, name, edmErrorArray); } else { long?nullable1 = new long?(value + (long)1); value = nullable1.Value; member.Value = nullable1; csdlSemanticsEnumMember = new CsdlSemanticsEnumMember(this, member); } csdlSemanticsEnumMember.SetIsValueExplicit(this.Model, new bool?(false)); } edmEnumMembers.Add(csdlSemanticsEnumMember); } return(edmEnumMembers); }
private IEnumerable <IEdmEnumMember> ComputeMembers() { var members = new List <IEdmEnumMember>(); // Walk the members and assign implicit values where needed. long previousValue = -1; foreach (CsdlEnumMember member in this.enumeration.Members) { IEdmEnumMember semanticsMember; long? implicitValue = null; if (!member.Value.HasValue) { if (previousValue < long.MaxValue) { implicitValue = previousValue + 1; previousValue = implicitValue.Value; member.Value = implicitValue; semanticsMember = new CsdlSemanticsEnumMember(this, member); } else { semanticsMember = new BadEnumMember(this, member.Name, new EdmError[] { new EdmError(member.Location ?? this.Location, EdmErrorCode.EnumMemberValueOutOfRange, Edm.Strings.CsdlSemantics_EnumMemberValueOutOfRange) }); } semanticsMember.SetIsValueExplicit(this.Model, false); } else { previousValue = member.Value.Value; semanticsMember = new CsdlSemanticsEnumMember(this, member); semanticsMember.SetIsValueExplicit(this.Model, true); } members.Add(semanticsMember); } return(members); }