void AddElementToSchema(XmlSchemaElement element, string elementNs, XmlSchemaSet schemaSet) { OperationDescription parentOperation = this.operation; if (parentOperation.OperationMethod != null) { XmlQualifiedName qname = new XmlQualifiedName(element.Name, elementNs); OperationElement existingElement; if (ExportedMessages.ElementTypes.TryGetValue(qname, out existingElement)) { if (existingElement.Operation.OperationMethod == parentOperation.OperationMethod) return; if (!SchemaHelper.IsMatch(element, existingElement.Element)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotHaveTwoOperationsWithTheSameElement5, parentOperation.OperationMethod.DeclaringType, parentOperation.OperationMethod.Name, qname, existingElement.Operation.OperationMethod.DeclaringType, existingElement.Operation.Name))); } return; } else { ExportedMessages.ElementTypes.Add(qname, new OperationElement(element, parentOperation)); } } SchemaHelper.AddElementToSchema(element, SchemaHelper.GetSchema(elementNs, schemaSet), schemaSet); }
internal override Exception CheckValueFacets(XmlQualifiedName value, XmlSchemaDatatype datatype) { RestrictionFacets restriction = datatype.Restriction; RestrictionFlags flags = (restriction != null) ? restriction.Flags : ((RestrictionFlags) 0); if (flags != 0) { int length = value.ToString().Length; if (((flags & RestrictionFlags.Length) != 0) && (restriction.Length != length)) { return new XmlSchemaException("Sch_LengthConstraintFailed", string.Empty); } if (((flags & RestrictionFlags.MinLength) != 0) && (length < restriction.MinLength)) { return new XmlSchemaException("Sch_MinLengthConstraintFailed", string.Empty); } if (((flags & RestrictionFlags.MaxLength) != 0) && (restriction.MaxLength < length)) { return new XmlSchemaException("Sch_MaxLengthConstraintFailed", string.Empty); } if (((flags & RestrictionFlags.Enumeration) != 0) && !this.MatchEnumeration(value, restriction.Enumeration)) { return new XmlSchemaException("Sch_EnumerationConstraintFailed", string.Empty); } } return null; }
protected SymbolEntry AddSymbol( XmlQualifiedName qname, XmlSchemaObject schemaObject, string suffix) { SymbolEntry symbol = new SymbolEntry(); symbol.xsdNamespace = qname.Namespace; symbol.clrNamespace = configSettings.GetClrNamespace(qname.Namespace); symbol.symbolName = qname.Name; string identifierName = NameGenerator.MakeValidIdentifier( symbol.symbolName, this.configSettings.NameMangler2); symbol.identifierName = identifierName; int id = 0; if(symbols.ContainsKey(symbol)) { identifierName = identifierName + suffix; symbol.identifierName = identifierName; while (symbols.ContainsKey(symbol)) { id++; symbol.identifierName = identifierName + id.ToString(CultureInfo.InvariantCulture.NumberFormat); } } if(symbol.isNameFixed()) nFixedNames++; symbols.Add(symbol, symbol); schemaNameToIdentifiers.Add(schemaObject, symbol.identifierName); //Type vs typeName return symbol; }
public QueryOutputWriterV1(XmlWriter writer, XmlWriterSettings settings) { _wrapped = writer; _systemId = settings.DocTypeSystem; _publicId = settings.DocTypePublic; if (settings.OutputMethod == XmlOutputMethod.Xml) { bool documentConformance = false; // Xml output method shouldn't output doc-type-decl if system ID is not defined (even if public ID is) // Only check for well-formed document if output method is xml if (_systemId != null) { documentConformance = true; _outputDocType = true; } // Check for well-formed document if standalone="yes" in an auto-generated xml declaration if (settings.Standalone == XmlStandalone.Yes) { documentConformance = true; _standalone = settings.Standalone; } if (documentConformance) { if (settings.Standalone == XmlStandalone.Yes) { _wrapped.WriteStartDocument(true); } else { _wrapped.WriteStartDocument(); } } if (settings.CDataSectionElements != null && settings.CDataSectionElements.Count > 0) { _bitsCData = new BitStack(); _lookupCDataElems = new Dictionary<XmlQualifiedName, XmlQualifiedName>(); _qnameCData = new XmlQualifiedName(); // Add each element name to the lookup table foreach (XmlQualifiedName name in settings.CDataSectionElements) { _lookupCDataElems[name] = null; } _bitsCData.PushBit(false); } } else if (settings.OutputMethod == XmlOutputMethod.Html) { // Html output method should output doc-type-decl if system ID or public ID is defined if (_systemId != null || _publicId != null) _outputDocType = true; } }
public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) { object obj2 = this.elements[name]; errorCode = 0; if (obj2 == null) { context.NeedValidateChildren = false; return null; } int index = (int) obj2; if (context.AllElementsSet[index]) { errorCode = -2; return null; } if (context.CurrentState.AllElementsRequired == -1) { context.CurrentState.AllElementsRequired = 0; } context.AllElementsSet.Set(index); if (this.isRequired[index]) { context.CurrentState.AllElementsRequired++; } return this.particles[index]; }
public SoapException (string message, XmlQualifiedName code, string actor, XmlNode detail) : base (message) { this.code = code; this.actor = actor; this.detail = detail; }
internal static bool IsSpecialXmlType(Type type, out XmlQualifiedName typeName, out XmlSchemaType xsdType, out bool hasRoot) { xsdType = null; hasRoot = true; if (type == Globals.TypeOfXmlElement || type == Globals.TypeOfXmlNodeArray) { string name = null; if (type == Globals.TypeOfXmlElement) { xsdType = CreateAnyElementType(); name = "XmlElement"; hasRoot = false; } else { xsdType = CreateAnyType(); name = "ArrayOfXmlNode"; hasRoot = true; } typeName = new XmlQualifiedName(name, DataContract.GetDefaultStableNamespace(type)); return true; } typeName = null; return false; }
/** * The execution of this behavior comes rather late. * Anyone that inspects the service description in the meantime, * such as for metadata generation, won't see the protection level that we want to use. * * One way of doing it is at when create HostFactory * * ServiceEndpoint endpoint = host.Description.Endpoints.Find(typeof(IService)); * OperationDescription operation = endpoint.Contract.Operations.Find("Action"); * MessageDescription message = operation.Messages.Find("http://tempuri.org/IService/ActionResponse"); * MessageHeaderDescription header = message.Headers[new XmlQualifiedName("aheader", "http://tempuri.org/")]; * header.ProtectionLevel = ProtectionLevel.Sign; * * **/ public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { ChannelProtectionRequirements requirements = bindingParameters.Find<ChannelProtectionRequirements>(); XmlQualifiedName qName = new XmlQualifiedName(header, ns); MessagePartSpecification part = new MessagePartSpecification(qName); requirements.OutgoingSignatureParts.AddParts(part, action); }
internal XmlSchemaObject AddItem(XmlSchemaObject item, XmlQualifiedName qname, XmlSchemas schemas) { if (item == null) { return null; } if ((qname == null) || qname.IsEmpty) { return null; } string str = item.GetType().Name + ":" + qname.ToString(); ArrayList list = (ArrayList) this.ObjectCache[str]; if (list == null) { list = new ArrayList(); this.ObjectCache[str] = list; } for (int i = 0; i < list.Count; i++) { XmlSchemaObject obj2 = (XmlSchemaObject) list[i]; if (obj2 == item) { return obj2; } if (this.Match(obj2, item, true)) { return obj2; } this.Warnings.Add(Res.GetString("XmlMismatchSchemaObjects", new object[] { item.GetType().Name, qname.Name, qname.Namespace })); this.Warnings.Add("DEBUG:Cached item key:\r\n" + ((string) this.looks[obj2]) + "\r\nnew item key:\r\n" + ((string) this.looks[item])); } list.Add(item); return item; }
// 1. name and public must be present // public and system must be anyURI internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) return 0; if(Name == null) error(h,"Required attribute name must be present"); else if(!XmlSchemaUtil.CheckNCName(this.name)) error(h,"attribute name must be NCName"); else qualifiedName = new XmlQualifiedName(Name, AncestorSchema.TargetNamespace); if(Public==null) error(h,"public must be present"); else if(!XmlSchemaUtil.CheckAnyUri(Public)) error(h,"public must be anyURI"); if(system != null && !XmlSchemaUtil.CheckAnyUri(system)) error(h,"system must be present and of Type anyURI"); XmlSchemaUtil.CompileID(Id,this,schema.IDCollection,h); return errorCount; }
public FaultException(string action, string reason, XmlQualifiedName code, IEnumerable<XmlQualifiedName> subcodes) { _action = action; _reason = reason; _code = code; _subcodes = subcodes.ToList(); }
public Binding () { extensions = new ServiceDescriptionFormatExtensionCollection (this); operations = new OperationBindingCollection (this); serviceDescription = null; type = XmlQualifiedName.Empty; }
private static XmlQualifiedName TranslateFaultCode(XmlQualifiedName code) { if (code.Namespace != "http://schemas.xmlsoap.org/soap/envelope/") { if (!(code.Namespace == "http://www.w3.org/2003/05/soap-envelope")) { return code; } if (code.Name == "Receiver") { return SoapException.ServerFaultCode; } if (code.Name == "Sender") { return SoapException.ClientFaultCode; } if (code.Name == "MustUnderstand") { return SoapException.MustUnderstandFaultCode; } if (code.Name == "VersionMismatch") { return SoapException.VersionMismatchFaultCode; } } return code; }
public object RemoveParam(string name, string namespaceUri) { XmlQualifiedName key = new XmlQualifiedName(name, namespaceUri); object obj2 = this.parameters[key]; this.parameters.Remove(key); return obj2; }
public static void AddToTable (XmlSchemaObjectTable table, XmlSchemaObject obj, XmlQualifiedName qname, ValidationEventHandler h) { if (table.Contains (qname)) { // FIXME: This logic unexpectedly allows // one redefining item and two or more redefining items. // FIXME: redefining item is not simple replacement, // but much more complex stuff. if (obj.isRedefineChild) { // take precedence. if (obj.redefinedObject != null) obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname)); else obj.redefinedObject = table [qname]; table.Set (qname, obj); } else if (table [qname].isRedefineChild) { if (table [qname].redefinedObject != null) obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname)); else table [qname].redefinedObject = obj; return; // never add to the table. } else if (StrictMsCompliant) { table.Set (qname, obj); } else obj.error (h, String.Format ("Named item {0} was already contained in the schema object table. {1}", qname, "Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation.")); } else table.Set (qname, obj); }
//----------------------------------------------------- // // ctors // //----------------------------------------------------- #region ctors /// <summary> /// Creates a new component /// </summary> /// <param name="type">owning component type </param> /// <param name="host">Dependency object to host IsActive and IsMouseOverAnchor DepenedencyProperties /// if host is null - set them on MarkedHighlightComponent itself</param> public MarkedHighlightComponent(XmlQualifiedName type, DependencyObject host) : base() { if (type == null) { throw new ArgumentNullException("type"); } _DPHost = host == null ? this : host; ClipToBounds = false; //create anchor highlight. The second parameter controls // if we want to render the entire anchor or only the Text content // This applies specificaly to tables, figures and floaters. // Currently implementation of GetTightBoundingGeometryForTextPointers does not // allow us to render the entire cell so we pass true (means content only). HighlightAnchor = new HighlightComponent(1, true, type); Children.Add(HighlightAnchor); //we will add the markers when the attached annotation is added //when we know the attachment level _leftMarker = null; _rightMarker = null; _state = 0; SetState(); }
public FunctionDecl(object f, XmlQualifiedName identity, FunctionParameter[] parameters) { this.f = f; this.identity = identity; this.parameters = parameters; }
public SamlAuthorityBinding(XmlQualifiedName authorityKind, string binding, string location) { this.AuthorityKind = authorityKind; this.Binding = binding; this.Location = location; this.CheckObjectValidity(); }
/// <summary> /// Instantiates the reader using the given <paramref name="rootName"/> for the virtual root node. /// </summary> /// <param name="baseReader">XML fragment reader.</param> /// <param name="rootName">Qualified name of the virtual root element.</param> public XmlFragmentReader(XmlQualifiedName rootName, XmlReader baseReader) : base(baseReader) { Guard.ArgumentNotNull(rootName, "rootName"); Initialize(rootName); }
void IContentHandler.StartElement(string uri, string localName, string qName, IAttributes atts) { XmlQualifiedName q = new XmlQualifiedName(localName, uri); XmlElement elem = m_factory.GetElement(Prefix(qName), q, m_doc); for (int i=0; i<atts.Length; i++) { XmlAttribute a = m_doc.CreateAttribute(Prefix(atts.GetQName(i)), atts.GetLocalName(i), atts.GetUri(i)); a.AppendChild(m_doc.CreateTextNode(atts.GetValue(i))); elem.SetAttributeNode(a); } if ((elem.LocalName != "stream") || (elem.NamespaceURI != URI.STREAM)) { if (m_stanza != null) m_stanza.AppendChild(elem); m_stanza = elem; } else { FireOnDocumentStart(elem); } }
public Key(XmlQualifiedName name, int matchkey, int usekey) { _name = name; _matchKey = matchkey; _useKey = usekey; _keyNodes = null; }
public XslDecimalFormat LookupDecimalFormat (QName name) { XslDecimalFormat ret = decimalFormats [name] as XslDecimalFormat; if (ret == null && name == QName.Empty) return XslDecimalFormat.Default; return ret; }
public QueryOutputWriter(XmlRawWriter writer, XmlWriterSettings settings) { this.wrapped = writer; this.systemId = settings.DocTypeSystem; this.publicId = settings.DocTypePublic; if (settings.OutputMethod == XmlOutputMethod.Xml) { if (this.systemId != null) { this.outputDocType = true; this.checkWellFormedDoc = true; } if (settings.AutoXmlDeclaration && (settings.Standalone == XmlStandalone.Yes)) { this.checkWellFormedDoc = true; } if (settings.CDataSectionElements.Count > 0) { this.bitsCData = new BitStack(); this.lookupCDataElems = new Dictionary<XmlQualifiedName, int>(); this.qnameCData = new XmlQualifiedName(); foreach (XmlQualifiedName name in settings.CDataSectionElements) { this.lookupCDataElems[name] = 0; } this.bitsCData.PushBit(false); } } else if ((settings.OutputMethod == XmlOutputMethod.Html) && ((this.systemId != null) || (this.publicId != null))) { this.outputDocType = true; } }
/// <summary> /// Initializes a new instance of the <see cref="SoapFormatMessage" /> class. /// </summary> /// <param name="soapOperation">The SOAP operation.</param> /// <param name="messageFaultSoapBuilder">The message fault SOAP builder.</param> /// <param name="ns">The WS namespace.</param> public SoapFormatMessage(SoapOperation soapOperation, IMessageFaultSoapBuilder messageFaultSoapBuilder, string ns) { this._exceptionHandler = exception => messageFaultSoapBuilder.BuildException(exception, soapOperation.ToString()); var response = soapOperation.GetResponse(); var responseElement = response.ToString(); this._xmlQualifiedName = new XmlQualifiedName(responseElement, ns); }
public MessagePart () { element = XmlQualifiedName.Empty; message = null; type = XmlQualifiedName.Empty; extensions = new ServiceDescriptionFormatExtensionCollection (this); }
/// <summary> /// Initializes the reader. /// </summary> /// <param name="iterator">The iterator to expose as a single reader.</param> /// <param name="rootName">The name to use for the enclosing root element.</param> /// <param name="ns">The namespace URI of the root element.</param> public XPathIteratorReader(XPathNodeIterator iterator, string rootName, string ns) : base(new StringReader(String.Empty)) { _iterator = iterator.Clone(); _current = new FakedRootReader(rootName, ns, XmlNodeType.Element); _rootname = new XmlQualifiedName(rootName, ns); }
internal GenericInfo(XmlQualifiedName stableName, string genericTypeName) { this.stableName = stableName; this.genericTypeName = genericTypeName; this.nestedParamCounts = new List<int>(); this.nestedParamCounts.Add(0); }
public void HashCodeTest() { QualifiedName name1 = new QualifiedName("foo", "http://foo.com", "f"); XmlQualifiedName xmlQualifiedName = new XmlQualifiedName("foo", "http://foo.com"); Assert.AreEqual(name1.GetHashCode(), xmlQualifiedName.GetHashCode()); }
public AstSchemaTypeBindingAttribute(string localName, string namespaceName) { LocalName = localName; NamespaceName = namespaceName; SchemaTypeName = String.Format(CultureInfo.InvariantCulture, "{{{0}}}{1}", namespaceName, localName); XmlQualifiedName = new XmlQualifiedName(localName, namespaceName); }
internal override bool CompileAttribute(Compiler compiler) { string name = compiler.Input.LocalName; string value = compiler.Input.Value; if (Ref.Equal(name, compiler.Atoms.Select)) { _selectKey = compiler.AddQuery(value); } else if (Ref.Equal(name, compiler.Atoms.Mode)) { Debug.Assert(_mode == null); if (compiler.AllowBuiltInMode && value == "*") { _mode = Compiler.BuiltInMode; } else { _mode = compiler.CreateXPathQName(value); } } else { return false; } return true; }
// Note that this does not handle DBNull and DateTimeOffset // (they are not included in the predefined schema) static Type GetPredefinedTypeFromQName(QName qname) { switch (qname.Namespace) { case XmlSchema.Namespace: case KnownTypeCollection.MSSimpleNamespace: return(KnownTypeCollection.GetPrimitiveTypeFromName(qname)); } throw new Exception("Should not happen"); }
private Element GetGlobalElement(QName name) { Element el = newElements [name] as Element; if (el == null) { el = schemas.GlobalElements [name] as Element; } return(el); }
private Attr CreateGlobalAttribute(QName name) { Attr attr = new Attr(); XmlSchema schema = PopulateSchema(name.Namespace); attr.Name = name.Name; schema.Items.Add(attr); newAttributes.Add(name, attr); return(attr); }
public static void AssertPolicy( PolicyAssertionCollection assertions, QName qname, TestLabel label) { var assertion = assertions.Find(qname.Name, qname.Namespace); label.EnterScope(qname.Name); Assert.That(assertion, Is.Not.Null, label.ToString()); assertions.Remove(assertion); label.LeaveScope(); }
protected override void ResolveType(QName qname, List <MessagePartDescription> parts, string ns) { /*foreach (XmlSchema xs in importer.Schemas) * if (xs.Types [qname] != null) * return resolveParameters ((XmlSchemaElement) xs.Types [qname]., msgdescr, importer); * * //FIXME: What to do here? * throw new Exception ("Could not resolve : " + qname.ToString ());*/ throw new NotImplementedException(); }
public XslDecimalFormat LookupDecimalFormat(QName name) { XslDecimalFormat ret = decimalFormats [name] as XslDecimalFormat; if (ret == null && name == QName.Empty) { return(XslDecimalFormat.Default); } return(ret); }
public void TypeCode() { for (int i = 0; i < all_types.Length; i++) { string name = all_types [i]; QName qname = new QName(name, XmlSchema.Namespace); Assert.AreEqual(type_codes [i], XmlSchemaType.GetBuiltInSimpleType(qname).TypeCode, name); } }
private Attr GetGlobalAttribute(QName name) { Attr a = newElements [name] as Attr; if (a == null) { a = schemas.GlobalAttributes [name] as Attr; } return(a); }
internal QName GetQName(Type type) { if (IsPrimitiveNotEnum(type)) { return(GetPrimitiveTypeName(type)); } SerializationMap map = FindUserMap(type); if (map != null) { // already mapped. return(map.XmlName); } if (type.IsEnum) { return(GetEnumQName(type)); } QName qname = GetContractQName(type); if (qname != null) { return(qname); } if (type.GetInterface("System.Xml.Serialization.IXmlSerializable") != null) { //FIXME: Reusing GetSerializableQName here, since we just //need name of the type.. return(GetSerializableQName(type)); } qname = GetCollectionContractQName(type); if (qname != null) { return(qname); } Type element = GetCollectionElementType(type); if (element != null) { return(GetCollectionQName(element)); } if (GetAttribute <SerializableAttribute> (type) != null) { return(GetSerializableQName(type)); } // FIXME: it needs in-depth check. return(QName.Empty); }
public static void CheckExport( WsdlExporter exporter, QName contractName, string bindingName, int countEndpoints, TestLabel label) { Assert.That(exporter.GeneratedWsdlDocuments, Is.Not.Null, label.Get()); Assert.That(exporter.GeneratedWsdlDocuments.Count, Is.EqualTo(1), label.Get()); var wsdl = exporter.GeneratedWsdlDocuments [0]; CheckExport(wsdl, contractName, bindingName, countEndpoints, label); }
//Check the <element .. > in a sequence void CheckElementReference(XmlSchemaObject obj, string name, QName schema_type, bool nillable) { XmlSchemaElement element = obj as XmlSchemaElement; Assert.IsNotNull(element, "XmlSchemaElement not found for " + schema_type.ToString()); Assert.AreEqual(name, element.Name, "#v1, Element name did not match"); //FIXME: Assert.AreEqual (0, element.MinOccurs, "#v0, MinOccurs should be 0 for element '" + name + "'"); Assert.AreEqual(schema_type, element.SchemaTypeName, "#v2, SchemaTypeName for element '" + element.Name + "' did not match."); Assert.AreEqual(nillable, element.IsNillable, "#v3, Element '" + element.Name + "', schema type = '" + schema_type + "' should have nillable = " + nillable); }
void CheckStandardQName(QName qname) { switch (qname.Namespace) { case XmlSchema.Namespace: case XmlSchema.InstanceNamespace: case MSSimpleNamespace: case MSArraysNamespace: throw new InvalidOperationException(String.Format("Namespace {0} is reserved and cannot be used for user serialization", qname.Namespace)); } }
internal SerializationMap FindUserMap(QName qname) { for (int i = 0; i < contracts.Count; i++) { if (qname == contracts [i].XmlName) { return(contracts [i]); } } return(null); }
/// <summary> /// Create a description of a constraint on a table. /// </summary> /// <param name="schema">The Schema of the entire data model.</param> /// <param name="xmlSchemaIdentityConstraint">The schema of a constraint.</param> public ConstraintSchema(DataModelSchema dataModelSchema, XmlSchemaIdentityConstraint xmlSchemaIdentityConstraint) : base(dataModelSchema, xmlSchemaIdentityConstraint) { // Initialize the object. this.Name = xmlSchemaIdentityConstraint.Name; this.QualifiedName = xmlSchemaIdentityConstraint.QualifiedName; this.Selector = GetSelector(xmlSchemaIdentityConstraint); this.Fields = GetFields(xmlSchemaIdentityConstraint); this.IsPrimaryKey = GetPrimaryKeyStatus(xmlSchemaIdentityConstraint); this.IsNullable = GetNullableStatus(); }
XslTemplate FindTemplate(QName name) { XslTemplate ret = style.Templates.FindTemplate(name); if (ret != null) { return(ret); } throw new XsltException("Could not resolve named template " + name, null, CurrentNode); }
public XmlQualifiedName GetSchemaTypeName(Type type) { QName qname = KnownTypes.GetQName(type); if (qname.Namespace == KnownTypeCollection.MSSimpleNamespace) { //primitive type, mapping to XmlSchema ns return(new QName(qname.Name, XmlSchema.Namespace)); } return(qname); }
private KeyIndexTable GetIndexTable(QName name) { KeyIndexTable table = keyIndexTables [name] as KeyIndexTable; if (table == null) { table = new KeyIndexTable(this, p.CompiledStyle.ResolveKey(name)); keyIndexTables [name] = table; } return(table); }
protected virtual object ReadClassInstance(XmlTypeMapping typeMap, bool isNullable, bool checkType) { if (isNullable && ReadNull()) { return(null); } if (checkType) { System.Xml.XmlQualifiedName t = GetXsiType(); if (t != null) { XmlTypeMapping realMap = typeMap.GetRealElementMap(t.Name, t.Namespace); if (realMap == null) { if (typeMap.TypeData.Type == typeof(object)) { return(ReadTypedPrimitive(t)); } else { throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)t); } } if (realMap != typeMap) { return(ReadObject(realMap, false, false)); } } else if (typeMap.TypeData.Type == typeof(object)) { return(ReadTypedPrimitive(AnyType)); } } object ob = Activator.CreateInstance(typeMap.TypeData.Type, true); Reader.MoveToElement(); bool isEmpty = Reader.IsEmptyElement; ReadClassInstanceMembers(typeMap, ob); if (isEmpty) { Reader.Skip(); } else { ReadEndElement(); } return(ob); }
public CollectionContractTypeMap( Type type, CollectionDataContractAttribute a, Type elementType, QName qname, KnownTypeCollection knownTypes) : base(type, elementType, qname, knownTypes) { this.a = a; IsReference = a.IsReference; if (!String.IsNullOrEmpty(a.ItemName)) { element_qname = new XmlQualifiedName(a.ItemName, a.Namespace ?? CurrentNamespace); } }
void resolveElement(QName qname, List <MessagePartDescription> parts, string ns) { XmlSchemaElement element = (XmlSchemaElement)xml_schemas.Find(qname, typeof(XmlSchemaElement)); if (element == null) { //FIXME: What to do here? throw new Exception("Could not resolve : " + qname.ToString()); } resolveParticle(schema_importer, element, parts, ns, 2); }
private void ReadRootStartElement(XmlReader reader, Type type) { SerializationMap map = known_types.FindUserMap(type); QName name = map != null ? map.XmlName : KnownTypeCollection.GetPredefinedTypeName(type); reader.MoveToContent(); reader.ReadStartElement(name.Name, name.Namespace); // FIXME: could there be any attributes to handle here? reader.Read(); }
object DeserializePrimitive(Type type, XmlReader reader, QName qname) { bool isDateTimeOffset = false; // Handle DateTimeOffset type and DateTimeOffset?. if (type == typeof(DateTimeOffset)) { isDateTimeOffset = true; } else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { isDateTimeOffset = type.GetGenericArguments() [0] == typeof(DateTimeOffset); } // It is the only exceptional type that does not serialize to string but serializes into complex element. if (isDateTimeOffset) { if (reader.IsEmptyElement) { reader.Read(); return(default(DateTimeOffset)); } reader.ReadStartElement(); reader.MoveToContent(); var date = reader.ReadElementContentAsDateTime("DateTime", KnownTypeCollection.DefaultClrNamespaceSystem); var off = TimeSpan.FromMinutes(reader.ReadElementContentAsInt("OffsetMinutes", KnownTypeCollection.DefaultClrNamespaceSystem)); reader.MoveToContent(); reader.ReadEndElement(); return(new DateTimeOffset(DateTime.SpecifyKind(date.ToUniversalTime() + off, DateTimeKind.Unspecified), off)); } string value; if (reader.IsEmptyElement) { reader.Read(); // advance if (type.IsValueType) { return(Activator.CreateInstance(type)); } else { // FIXME: Workaround for creating empty objects of the correct type. value = String.Empty; } } else { value = reader.ReadElementContentAsString(); } return(KnownTypeCollection.PredefinedTypeStringToObject(value, qname.Name, reader)); }
public static QName GetStaticQName(Type type) { if (IsPrimitiveNotEnum(type)) { return(GetPrimitiveTypeName(type)); } if (type.IsEnum) { return(GetEnumQName(type)); } QName qname = GetContractQName(type); if (qname != null) { return(qname); } if (type.GetInterface("System.Xml.Serialization.IXmlSerializable") != null) { //FIXME: Reusing GetSerializableQName here, since we just //need name of the type.. return(GetSerializableQName(type)); } qname = GetCollectionContractQName(type); if (qname != null) { return(qname); } Type element = GetCollectionElementType(type); if (element != null) { if (type.IsInterface || IsCustomCollectionType(type, element)) { return(GetCollectionQName(element)); } } if (GetAttribute <SerializableAttribute> (type) != null) { return(GetSerializableQName(type)); } // default type map - still uses GetContractQName(). return(GetContractQName(type, null, null)); }
public DataContractSerializer(Type type, IEnumerable <Type> knownTypes) { if (type == null) { throw new ArgumentNullException("type"); } this.type = type; PopulateTypes(knownTypes); known_types.Add(type); QName qname = known_types.GetQName(type); FillDictionaryString(qname.Name, qname.Namespace); }
internal static QName GetPredefinedTypeName(Type type) { QName name = GetPrimitiveTypeName(type); if (name != QName.Empty) { return(name); } if (type == typeof(DBNull)) { return(dbnull_type); } return(QName.Empty); }
// Already relaxed. private RelaxngDefine CreateGlobalElement(QName name) { RelaxngDefine def = new RelaxngDefine(); def.Name = CreateUniqueName(name.Name); RelaxngElement el = new RelaxngElement(); el.NameClass = new RelaxngName(name.Name, name.Namespace); def.Patterns.Add(el); elements.Add(name, def); grammar.Defines.Add(def); return(def); }
private RelaxngDefine CreateGlobalAttribute(QName name) { RelaxngDefine def = new RelaxngDefine(); def.Name = CreateUniqueName(name.Name + "-attr"); RelaxngAttribute attr = new RelaxngAttribute(); attr.NameClass = new RelaxngName( name.Name, name.Namespace); def.Patterns.Add(attr); attributes.Add(name, def); grammar.Defines.Add(def); return(def); }
protected XmlSchemaElement GetSchemaElement(QName qname, XmlSchemaType schemaType) { XmlSchemaElement schemaElement = new XmlSchemaElement(); schemaElement.Name = qname.Name; schemaElement.SchemaTypeName = qname; if (schemaType is XmlSchemaComplexType) { schemaElement.IsNillable = true; } return(schemaElement); }
protected DataMemberInfo CreateDataMemberInfo(DataMemberAttribute dma, MemberInfo mi, Type memberType, string ownerNamespace) { KnownTypes.Add(memberType); QName qname = KnownTypes.GetQName(memberType); if (KnownTypeCollection.GetPrimitiveTypeFromName(qname) != null) { return(new DataMemberInfo(mi, dma, ownerNamespace, null)); } else { return(new DataMemberInfo(mi, dma, ownerNamespace, qname.Namespace)); } }
Expression IStaticXsltContext.TryGetFunction(QName name, FunctionArguments args) { string ns = LookupNamespace(name.Namespace); if (ns == XslStylesheet.MSXsltNamespace && name.Name == "node-set") { return(new MSXslNodeSet(args)); } if (ns != "") { return(null); } switch (name.Name) { case "current": return(new XsltCurrent(args)); case "unparsed-entity-uri": return(new XsltUnparsedEntityUri(args)); case "element-available": return(new XsltElementAvailable(args, this)); case "system-property": return(new XsltSystemProperty(args, this)); case "function-available": return(new XsltFunctionAvailable(args, this)); case "generate-id": return(new XsltGenerateId(args)); case "format-number": return(new XsltFormatNumber(args, this)); case "key": if (KeyCompilationMode) { throw new XsltCompileException("Cannot use key() function inside key definition", null, this.Input); } return(new XsltKey(args, this)); case "document": return(new XsltDocument(args, this)); } return(null); }