public void CreateMetadataPropertyFromXmlElement_creates_annotation_containing_XElement() { var element = new XElement("SoBeautiful"); var property = SchemaElement.CreateMetadataPropertyFromXmlElement( "YourFur", "IsRed", element); Assert.Equal("YourFur:IsRed", property.Name); Assert.Same(element, property.Value); }
private bool AddOtherContent(XmlReader reader) { int lineNumber; int linePosition; SchemaElement.GetPositionInfo(reader, out lineNumber, out linePosition); MetadataProperty property; if (reader.NodeType == XmlNodeType.Element) { if (this._schema.SchemaVersion == 1.0 || this._schema.SchemaVersion == 1.1) { return(true); } if (this._schema.SchemaVersion >= 2.0 && reader.NamespaceURI == "http://schemas.microsoft.com/ado/2006/04/codegeneration") { this.AddError(ErrorCode.NoCodeGenNamespaceInStructuralAnnotation, EdmSchemaErrorSeverity.Error, lineNumber, linePosition, (object)Strings.NoCodeGenNamespaceInStructuralAnnotation((object)"http://schemas.microsoft.com/ado/2006/04/codegeneration")); return(true); } using (XmlReader xmlReader = reader.ReadSubtree()) { xmlReader.Read(); using (StringReader stringReader = new StringReader(xmlReader.ReadOuterXml())) { XElement xelement = XElement.Load((TextReader)stringReader); property = SchemaElement.CreateMetadataPropertyFromXmlElement(xelement.Name.NamespaceName, xelement.Name.LocalName, xelement); } } } else { if (reader.NamespaceURI == "http://www.w3.org/2000/xmlns/") { return(true); } property = this.CreateMetadataPropertyFromXmlAttribute(reader.NamespaceURI, reader.LocalName, reader.Value); } if (!this.OtherContent.Exists((Predicate <MetadataProperty>)(mp => mp.Identity == property.Identity))) { this.OtherContent.Add(property); } else { this.AddError(ErrorCode.AlreadyDefined, EdmSchemaErrorSeverity.Error, lineNumber, linePosition, (object)Strings.DuplicateAnnotation((object)property.Identity, (object)this.FQName)); } return(false); }