internal ElementAccessor Clone() { ElementAccessor newAccessor = new ElementAccessor(); newAccessor._nullable = _nullable; newAccessor.IsTopLevelInSchema = this.IsTopLevelInSchema; newAccessor.Form = this.Form; newAccessor._isSoap = _isSoap; newAccessor.Name = this.Name; newAccessor.Default = this.Default; newAccessor.Namespace = this.Namespace; newAccessor.Mapping = this.Mapping; newAccessor.Any = this.Any; return(newAccessor); }
/// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="SoapReflectionImporter.ImportMembersMapping3"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public XmlMembersMapping ImportMembersMapping(string elementName, string ns, XmlReflectionMember[] members, bool hasWrapperElement, bool writeAccessors, bool validate, XmlMappingAccess access) { ElementAccessor element = new ElementAccessor(); element.IsSoap = true; element.Name = elementName == null || elementName.Length == 0 ? elementName : XmlConvert.EncodeLocalName(elementName); element.Mapping = ImportMembersMapping(members, ns, hasWrapperElement, writeAccessors, validate, new RecursionLimiter()); element.Mapping.TypeName = elementName; element.Namespace = element.Mapping.Namespace == null ? ns : element.Mapping.Namespace; element.Form = XmlSchemaForm.Qualified; XmlMembersMapping xmlMapping = new XmlMembersMapping(_typeScope, element, access); xmlMapping.IsSoap = true; xmlMapping.GenerateSerializer = true; return(xmlMapping); }
internal XmlMembersMapping(TypeScope scope, ElementAccessor accessor, XmlMappingAccess access) : base(scope, accessor, access) { MembersMapping mapping = (MembersMapping)accessor.Mapping; StringBuilder key = new StringBuilder(); key.Append(":"); _mappings = new XmlMemberMapping[mapping.Members.Length]; for (int i = 0; i < _mappings.Length; i++) { if (mapping.Members[i].TypeDesc.Type != null) { key.Append(GenerateKey(mapping.Members[i].TypeDesc.Type, null, null)); key.Append(":"); } _mappings[i] = new XmlMemberMapping(mapping.Members[i]); } SetKeyInternal(key.ToString()); }
/// <summary> /// Selects the first class available from the Class Picker in toolbar /// </summary> /// <returns></returns> public string SelectFirstClassFromQuickLink() { var quickLinkClassPicker = WebContext.WebDriver.FindElement(By.CssSelector("[data-automation-id='QuickLinkClassPicker']")); quickLinkClassPicker.Click(); string selectedClass = ""; var list = WebContext.WebDriver.FindElement(By.CssSelector(".mega-menu-list")); IList <IWebElement> classLabels = list.FindElements(By.CssSelector(".mega-menu-list-item")); if (classLabels.Count > 0) { selectedClass = classLabels[0].GetText(); classLabels[0].Click(); ElementAccessor.WaitForAjaxReady(By.CssSelector(".locking-mask-loading")); } return(selectedClass); }
private void GenerateTypeElement(object o, XmlTypeMapping xmlMapping) { ElementAccessor element = xmlMapping.Accessor; TypeMapping mapping = element.Mapping; WriteStartDocument(); if (o == null) { if (element.IsNullable) { if (mapping.IsSoap) { throw new PlatformNotSupportedException(); } else { WriteNullTagLiteral(element.Name, (element.Form == XmlSchemaForm.Qualified ? element.Namespace : "")); } } else { WriteEmptyTag(element.Name, (element.Form == XmlSchemaForm.Qualified ? element.Namespace : "")); } return; } if (!mapping.TypeDesc.IsValueType && !mapping.TypeDesc.Type.IsPrimitive) { TopLevelElement(); } WriteMember(o, null, new ElementAccessor[] { element }, null, null, mapping.TypeDesc, !element.IsSoap, xmlMapping); if (mapping.IsSoap) { WriteReferencedElements(); } }
internal XmlTypeMapping(TypeScope scope, ElementAccessor accessor) : base(scope, accessor) { }
internal XmlMapping(TypeScope scope, ElementAccessor accessor) : this(scope, accessor, XmlMappingAccess.Read | XmlMappingAccess.Write) { }
private void WriteElement(object o, ElementAccessor element, string arrayName, bool writeAccessor, XmlMapping parentMapping = null) { string name = writeAccessor ? element.Name : element.Mapping.TypeName; string ns = element.Any && element.Name.Length == 0 ? null : (element.Form == XmlSchemaForm.Qualified ? (writeAccessor ? element.Namespace : element.Mapping.Namespace) : ""); if (element.Mapping is NullableMapping) { if (o != null) { ElementAccessor e = element.Clone(); e.Mapping = ((NullableMapping)element.Mapping).BaseMapping; WriteElement(o, e, arrayName, writeAccessor); } else if (element.IsNullable) { WriteNullTagLiteral(element.Name, ns); } } else if (element.Mapping is ArrayMapping) { var mapping = (ArrayMapping)element.Mapping; if (element.IsNullable && o == null) { WriteNullTagLiteral(element.Name, element.Form == XmlSchemaForm.Qualified ? element.Namespace : ""); } else if (mapping.IsSoap) { if (mapping.Elements == null || mapping.Elements.Length != 1) { throw new InvalidOperationException(SR.XmlInternalError); } var itemElement = mapping.Elements[0]; var itemMapping = itemElement.Mapping as StructMapping; var itemName = writeAccessor ? itemElement.Name : itemMapping.TypeName; var itemNamespace = itemElement.Any && itemElement.Name.Length == 0 ? null : (itemElement.Form == XmlSchemaForm.Qualified ? (writeAccessor ? itemElement.Namespace : itemMapping.Namespace) : ""); if (!writeAccessor) { WritePotentiallyReferencingElement(name, ns, o, mapping.TypeDesc.Type, true, element.IsNullable); } else { WritePotentiallyReferencingElement(name, ns, o, null, false, element.IsNullable); } } else if (element.IsUnbounded) { TypeDesc arrayTypeDesc = mapping.TypeDesc.CreateArrayTypeDesc(); var enumerable = (IEnumerable)o; foreach (var e in enumerable) { element.IsUnbounded = false; WriteElement(e, element, arrayName, writeAccessor); element.IsUnbounded = true; } } else { if (o != null) { WriteStartElement(name, ns, false); WriteArrayItems(mapping.ElementsSortedByDerivation, null, null, mapping.TypeDesc, o); WriteEndElement(); } } } else if (element.Mapping is EnumMapping) { if (element.Mapping.IsSoap) { Writer.WriteStartElement(name, ns); WriteEnumMethod((EnumMapping)element.Mapping, o); WriteEndElement(); } else { WritePrimitive(WritePrimitiveMethodRequirement.WriteElementString, name, ns, element.Default, o, element.Mapping, false, true, element.IsNullable); } } else if (element.Mapping is PrimitiveMapping) { PrimitiveMapping mapping = (PrimitiveMapping)element.Mapping; if (mapping.TypeDesc == QnameTypeDesc) { WriteQualifiedNameElement(name, ns, element.Default, (XmlQualifiedName)o, element.IsNullable, mapping.IsSoap, mapping); } else { WritePrimitiveMethodRequirement suffixNullable = mapping.IsSoap ? WritePrimitiveMethodRequirement.Encoded : WritePrimitiveMethodRequirement.None; WritePrimitiveMethodRequirement suffixRaw = mapping.TypeDesc.XmlEncodingNotRequired ? WritePrimitiveMethodRequirement.Raw : WritePrimitiveMethodRequirement.None; WritePrimitive(element.IsNullable ? WritePrimitiveMethodRequirement.WriteNullableStringLiteral | suffixNullable | suffixRaw : WritePrimitiveMethodRequirement.WriteElementString | suffixRaw, name, ns, element.Default, o, mapping, mapping.IsSoap, true, element.IsNullable); } } else if (element.Mapping is StructMapping) { var mapping = (StructMapping)element.Mapping; if (mapping.IsSoap) { WritePotentiallyReferencingElement(name, ns, o, !writeAccessor ? mapping.TypeDesc.Type : null, !writeAccessor, element.IsNullable); } else { WriteStructMethod(mapping, name, ns, o, element.IsNullable, needType: false, parentMapping: parentMapping); } } else if (element.Mapping is SpecialMapping) { if (element.Mapping is SerializableMapping) { WriteSerializable((IXmlSerializable)o, name, ns, element.IsNullable, !element.Any); } else { // XmlNode, XmlElement var node = o as XmlNode; if (node != null) { WriteElementLiteral(node, name, ns, element.IsNullable, element.Any); } else { throw CreateInvalidAnyTypeException(o); } } } else { throw new InvalidOperationException(SR.XmlInternalError); } }
private void WriteElements(object o, object enumSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, string arrayName, bool writeAccessors, bool isNullable, XmlMapping parentMapping = null) { if (elements.Length == 0 && text == null) { return; } if (elements.Length == 1 && text == null) { WriteElement(o, elements[0], arrayName, writeAccessors, parentMapping); } else { if (isNullable && choice == null && o == null) { return; } int anyCount = 0; var namedAnys = new List <ElementAccessor>(); ElementAccessor unnamedAny = null; // can only have one string enumTypeName = choice == null ? null : choice.Mapping.TypeDesc.FullName; for (int i = 0; i < elements.Length; i++) { ElementAccessor element = elements[i]; if (element.Any) { anyCount++; if (element.Name != null && element.Name.Length > 0) { namedAnys.Add(element); } else if (unnamedAny == null) { unnamedAny = element; } } else if (choice != null) { if (o != null && o.GetType() == element.Mapping.TypeDesc.Type) { WriteElement(o, element, arrayName, writeAccessors); return; } } else { TypeDesc td = element.IsUnbounded ? element.Mapping.TypeDesc.CreateArrayTypeDesc() : element.Mapping.TypeDesc; if (o.GetType() == td.Type) { WriteElement(o, element, arrayName, writeAccessors); return; } } } if (anyCount > 0) { var elem = o as XmlElement; if (elem != null) { foreach (ElementAccessor element in namedAnys) { if (element.Name == elem.Name && element.Namespace == elem.NamespaceURI) { WriteElement(elem, element, arrayName, writeAccessors); return; } } if (choice != null) { throw CreateChoiceIdentifierValueException(choice.Mapping.TypeDesc.FullName, choice.MemberName, elem.Name, elem.NamespaceURI); } if (unnamedAny != null) { WriteElement(elem, unnamedAny, arrayName, writeAccessors); return; } throw CreateUnknownAnyElementException(elem.Name, elem.NamespaceURI); } } if (text != null) { bool useReflection = text.Mapping.TypeDesc.UseReflection; string fullTypeName = text.Mapping.TypeDesc.CSharpName; WriteText(o, text); return; } if (elements.Length > 0 && o != null) { throw CreateUnknownTypeException(o); } } }