/// <summary> /// </summary> /// <returns> </returns> internal override void Validate() { base.Validate(); foreach (var member in NamedMembers) { if (BaseType != null) { StructuredType definingType; SchemaElement definingMember; string errorMessage = null; if (HowDefined.AsMember == BaseType.DefinesMemberName(member.Name, out definingType, out definingMember)) { errorMessage = Strings.DuplicateMemberName(member.Name, FQName, definingType.FQName); } if (errorMessage != null) { member.AddError(ErrorCode.AlreadyDefined, EdmSchemaErrorSeverity.Error, errorMessage); } } member.Validate(); } }
/// <summary> /// See if a name is a member in a type or any of its base types /// </summary> /// <param name="name"> name to look for </param> /// <param name="definingType"> if defined, the type that defines it </param> /// <param name="definingMember"> if defined, the member that defines it </param> /// <returns> how name was defined </returns> private HowDefined DefinesMemberName(string name, out StructuredType definingType, out SchemaElement definingMember) { if (NamedMembers.ContainsKey(name)) { definingType = this; definingMember = NamedMembers[name]; return(HowDefined.AsMember); } definingMember = NamedMembers.LookUpEquivalentKey(name); Debug.Assert(definingMember == null, "we allow the scenario that members can have same name but different cases"); if (IsTypeHierarchyRoot) { definingType = null; definingMember = null; return(HowDefined.NotDefined); } return(BaseType.DefinesMemberName(name, out definingType, out definingMember)); }