/// <summary> /// Verify Metadata.Core.4498 /// </summary> /// <param name="context">Service context</param> /// <param name="info">out parameter to return violation information when rule fail</param> /// <returns>true if rule passes; false otherwise</returns> public override bool?Verify(ServiceContext context, out ExtensionRuleViolationInfo info) { if (context == null) { throw new ArgumentNullException("context"); } bool?passed = null; info = null; // Load MetadataDocument into XMLDOM XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(context.MetadataDocument); XmlNodeList propertyValueNodeList = xmlDoc.SelectNodes("//*[local-name()='Record']/*[local-name()='PropertyValue']"); foreach (XmlNode propValue in propertyValueNodeList) { if (VerificationHelper.IsSimpleIdentifier(propValue.Attributes["Property"].Value)) { passed = true; } else { passed = false; info = new ExtensionRuleViolationInfo(this.ErrorMessage, context.Destination, context.ResponsePayload); } } return(passed); }
/// <summary> /// Verify Metadata.Core.4201 /// </summary> /// <param name="context">Service context</param> /// <param name="info">out parameter to return violation information when rule fail</param> /// <returns>true if rule passes; false otherwise</returns> public override bool?Verify(ServiceContext context, out ExtensionRuleViolationInfo info) { if (context == null) { throw new ArgumentNullException("context"); } bool?passed = null; info = null; // Load MetadataDocument into XMLDOM XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(context.MetadataDocument); string xpath = "//*[local-name()='ComplexType']"; XmlNodeList complexTypeNodeList = xmlDoc.SelectNodes(xpath); foreach (XmlNode complexTypeNode in complexTypeNodeList) { if (complexTypeNode.Attributes["Name"] != null && VerificationHelper.IsSimpleIdentifier(complexTypeNode.Attributes["Name"].Value)) { passed = true; } else { passed = false; info = new ExtensionRuleViolationInfo(this.ErrorMessage, context.Destination, context.ResponsePayload); break; } } return(passed); }
/// <summary> /// Verify Metadata.Core.4559 /// </summary> /// <param name="context">Service context</param> /// <param name="info">out parameter to return violation information when rule fail</param> /// <returns>true if rule passes; false otherwise</returns> public override bool?Verify(ServiceContext context, out ExtensionRuleViolationInfo info) { if (context == null) { throw new ArgumentNullException("context"); } bool?passed = null; info = null; // Load MetadataDocument into XMLDOM XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(context.MetadataDocument); XmlNodeList schemaList = xmlDoc.SelectNodes("//*[local-name()='Schema']"); foreach (XmlNode schema in schemaList) { if (schema.HasChildNodes) { foreach (XmlNode node in schema.ChildNodes) { if (node.Attributes == null) { continue; // The comment nodes do not contain Attributes collection. } if (node.Attributes["Name"] == null) { continue; // The node without a name is out of scope. } if (VerificationHelper.IsSimpleIdentifier(node.Attributes["Name"].Value)) { passed = true; } else { passed = false; info = new ExtensionRuleViolationInfo(this.ErrorMessage, context.Destination, context.ResponsePayload); break; } } } if (passed == false) { break; } } return(passed); }
/// <summary> /// Verify Metadata.Core.4447 /// </summary> /// <param name="context">Service context</param> /// <param name="info">out parameter to return violation information when rule fail</param> /// <returns>true if rule passes; false otherwise</returns> public override bool?Verify(ServiceContext context, out ExtensionRuleViolationInfo info) { if (context == null) { throw new ArgumentNullException("context"); } bool?passed = null; info = null; // Load MetadataDocument into XMLDOM XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(context.MetadataDocument); XmlNodeList schemaList = xmlDoc.SelectNodes("//*[local-name()='LabeledElement']/ancestor::*[local-name()='Schema']"); foreach (XmlNode schema in schemaList) { if (schema.HasChildNodes) { // Check if there's any duplicate name for nomimal types and elements within a namespace defined by a Schema. HashSet <string> nominalTypeElementSet = new HashSet <string>(StringComparer.Ordinal); foreach (XmlNode node in schema.ChildNodes) { if (node.Attributes == null) { continue; // the comment nodes do not contain Attributes collection. } if (node.Attributes["Name"] == null) { continue; // The node without a name is out of scope. } nominalTypeElementSet.Add(node.Attributes["Name"].Value); } XmlNodeList labeledElementList = schema.SelectNodes("//*[local-name()='LabeledElement']"); foreach (XmlNode node in labeledElementList) { if (node.Attributes == null) { continue; // the comment nodes do not contain Attributes collection. } if (node.Attributes["Name"] == null) { continue; // The node without a name is out of scope. } if (nominalTypeElementSet.Add(node.Attributes["Name"].Value) && VerificationHelper.IsSimpleIdentifier(node.Attributes["Name"].Value)) { passed = true; } else { passed = false; info = new ExtensionRuleViolationInfo(this.ErrorMessage, context.Destination, context.ResponsePayload); break; } } } if (passed == false) { break; } } return(passed); }