当前位置: 首页>>代码示例>>C#>>正文


C# Serialization.ElementAccessor类代码示例

本文整理汇总了C#中System.Xml.Serialization.ElementAccessor的典型用法代码示例。如果您正苦于以下问题:C# ElementAccessor类的具体用法?C# ElementAccessor怎么用?C# ElementAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ElementAccessor类属于System.Xml.Serialization命名空间,在下文中一共展示了ElementAccessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: XmlMembersMapping

 internal XmlMembersMapping(TypeScope scope, ElementAccessor accessor) : base(scope) {
     this.accessor = accessor;
     MembersMapping mapping = (MembersMapping)accessor.Mapping;
     mappings = new XmlMemberMapping[mapping.Members.Length];
     for (int i = 0; i < mappings.Length; i++)
         mappings[i] = new XmlMemberMapping(scope, mapping.Members[i]);
 }
开发者ID:ArildF,项目名称:masters,代码行数:7,代码来源:xmlmembersmapping.cs

示例2: XmlMapping

 internal XmlMapping(TypeScope scope, ElementAccessor accessor, XmlMappingAccess access)
 {
     _scope = scope;
     _accessor = accessor;
     _access = access;
     _shallow = scope == null;
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:XmlMapping.cs

示例3: XmlMapping

 internal XmlMapping(TypeScope scope, ElementAccessor accessor, XmlMappingAccess access)
 {
     this.scope = scope;
     this.accessor = accessor;
     this.access = access;
     this.shallow = scope == null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:XmlMapping.cs

示例4: AddScopeElements

 private void AddScopeElements(INameScope scope, ElementAccessor[] elements, ref bool duplicateElements, bool allowDuplicates)
 {
     for (int i = 0; i < elements.Length; i++)
     {
         this.AddScopeElement(scope, elements[i], ref duplicateElements, allowDuplicates);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:XmlSchemaImporter.cs

示例5: IsNeedNullableMember

 private static bool IsNeedNullableMember(ElementAccessor element)
 {
     if (element.Mapping is ArrayMapping)
     {
         ArrayMapping mapping = (ArrayMapping) element.Mapping;
         return (((mapping.Elements != null) && (mapping.Elements.Length == 1)) && IsNeedNullableMember(mapping.Elements[0]));
     }
     return (element.IsNullable && element.Mapping.TypeDesc.IsValueType);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:AccessorMapping.cs

示例6: FindChoiceEnumValue

 private string FindChoiceEnumValue(ElementAccessor element, EnumMapping choiceMapping, bool useReflection)
 {
     string ident = null;
     for (int i = 0; i < choiceMapping.Constants.Length; i++)
     {
         string xmlName = choiceMapping.Constants[i].XmlName;
         if (element.Any && (element.Name.Length == 0))
         {
             if (!(xmlName == "##any:"))
             {
                 continue;
             }
             if (useReflection)
             {
                 ident = choiceMapping.Constants[i].Value.ToString(CultureInfo.InvariantCulture);
             }
             else
             {
                 ident = choiceMapping.Constants[i].Name;
             }
             break;
         }
         int length = xmlName.LastIndexOf(':');
         string str3 = (length < 0) ? choiceMapping.Namespace : xmlName.Substring(0, length);
         string str4 = (length < 0) ? xmlName : xmlName.Substring(length + 1);
         if ((element.Name == str4) && (((element.Form == XmlSchemaForm.Unqualified) && string.IsNullOrEmpty(str3)) || (element.Namespace == str3)))
         {
             if (useReflection)
             {
                 ident = choiceMapping.Constants[i].Value.ToString(CultureInfo.InvariantCulture);
             }
             else
             {
                 ident = choiceMapping.Constants[i].Name;
             }
             break;
         }
     }
     if ((ident == null) || (ident.Length == 0))
     {
         if (element.Any && (element.Name.Length == 0))
         {
             throw new InvalidOperationException(Res.GetString("XmlChoiceMissingAnyValue", new object[] { choiceMapping.TypeDesc.FullName }));
         }
         throw new InvalidOperationException(Res.GetString("XmlChoiceMissingValue", new object[] { choiceMapping.TypeDesc.FullName, element.Namespace + ":" + element.Name, element.Name, element.Namespace }));
     }
     if (!useReflection)
     {
         CodeIdentifier.CheckValidIdentifier(ident);
     }
     return ident;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:52,代码来源:XmlSerializationWriterCodeGen.cs

示例7: XmlMembersMapping

 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());
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:14,代码来源:XmlMembersMapping.cs

示例8: ImportDerivedTypeMapping

        /// <include file='doc\SoapSchemaImporter.uex' path='docs/doc[@for="SoapSchemaImporter.ImportDerivedTypeMapping"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlTypeMapping ImportDerivedTypeMapping(XmlQualifiedName name, Type baseType, bool baseTypeCanBeIndirect) {
            TypeMapping mapping = ImportType(name, false);
            if (mapping is StructMapping) {
                MakeDerived((StructMapping)mapping, baseType, baseTypeCanBeIndirect);
            }
            else if (baseType != null)
                throw new InvalidOperationException(Res.GetString(Res.XmlPrimitiveBaseType, name.Name, name.Namespace, baseType.FullName));
            ElementAccessor accessor = new ElementAccessor();
            accessor.IsSoap = true;
            accessor.Name = Accessor.EscapeName(name.Name, false);
            accessor.Namespace = name.Namespace;
            accessor.Mapping = mapping;
            accessor.IsNullable = true;
            accessor.Form = XmlSchemaForm.Qualified;

            return new XmlTypeMapping(scope, accessor);
        }
开发者ID:ArildF,项目名称:masters,代码行数:21,代码来源:soapschemaimporter.cs

示例9: ElementsMatch

 internal static bool ElementsMatch(ElementAccessor[] a, ElementAccessor[] b)
 {
     if (a == null)
     {
         return (b == null);
     }
     if (b == null)
     {
         return false;
     }
     if (a.Length != b.Length)
     {
         return false;
     }
     for (int i = 0; i < a.Length; i++)
     {
         if (((a[i].Name != b[i].Name) || (a[i].Namespace != b[i].Namespace)) || ((a[i].Form != b[i].Form) || (a[i].IsNullable != b[i].IsNullable)))
         {
             return false;
         }
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:AccessorMapping.cs

示例10: AddScopeElement

 private void AddScopeElement(INameScope scope, ElementAccessor element, ref bool duplicateElements, bool allowDuplicates)
 {
     if (scope != null)
     {
         ElementAccessor accessor = (ElementAccessor) scope[element.Name, element.Namespace];
         if (accessor != null)
         {
             if (!allowDuplicates)
             {
                 throw new InvalidOperationException(Res.GetString("XmlDuplicateElementInScope", new object[] { element.Name, element.Namespace }));
             }
             if (accessor.Mapping.TypeDesc != element.Mapping.TypeDesc)
             {
                 throw new InvalidOperationException(Res.GetString("XmlDuplicateElementInScope1", new object[] { element.Name, element.Namespace }));
             }
             duplicateElements = true;
         }
         else
         {
             scope[element.Name, element.Namespace] = element;
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:XmlSchemaImporter.cs

示例11: WriteArray

        void WriteArray(string source, string choiceSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, TypeDesc arrayTypeDesc) {
            if (elements.Length == 0 && text == null) return;
            Writer.WriteLine("{");
            Writer.Indent++;
            string arrayTypeName = arrayTypeDesc.CSharpName;
            WriteArrayLocalDecl(arrayTypeName, "a", source, arrayTypeDesc);
            if (arrayTypeDesc.IsNullable) {
                Writer.WriteLine("if (a != null) {");
                Writer.Indent++;
            }

            if (choice != null) {
                bool choiceUseReflection = choice.Mapping.TypeDesc.UseReflection;
                string choiceFullName = choice.Mapping.TypeDesc.CSharpName;
                WriteArrayLocalDecl(choiceFullName+"[]", "c", choiceSource, choice.Mapping.TypeDesc);
                // write check for the choice identifier array
                Writer.WriteLine("if (c == null || c.Length < a.Length) {");
                Writer.Indent++;
                Writer.Write("throw CreateInvalidChoiceIdentifierValueException(");
                WriteQuotedCSharpString(choice.Mapping.TypeDesc.FullName);
                Writer.Write(", ");
                WriteQuotedCSharpString(choice.MemberName);
                Writer.Write(");");
                Writer.Indent--;
                Writer.WriteLine("}");
            }

            WriteArrayItems(elements, text, choice, arrayTypeDesc, "a", "c");
            if (arrayTypeDesc.IsNullable) {
                Writer.Indent--;
                Writer.WriteLine("}");
            }
            Writer.Indent--;
            Writer.WriteLine("}");
        }
开发者ID:uQr,项目名称:referencesource,代码行数:35,代码来源:XmlSerializationWriter.cs

示例12: CreateElementAccessor

 static ElementAccessor CreateElementAccessor(TypeMapping mapping, string ns) {
     ElementAccessor element = new ElementAccessor();
     element.IsSoap = true;
     element.Name = mapping.TypeName; //XmlConvert.EncodeLocalName(name == null || name.Length == 0 ? mapping.TypeName : name);
     element.Namespace = ns;
     element.Mapping = mapping;
     return element;
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:8,代码来源:soapreflectionimporter.cs

示例13: WriteMember

 void WriteMember(string source, string choiceSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, TypeDesc memberTypeDesc, bool writeAccessors) {
     if (memberTypeDesc.IsArrayLike && 
         !(elements.Length == 1 && elements[0].Mapping is ArrayMapping))
         WriteArray(source, choiceSource, elements, text, choice, memberTypeDesc);
     else
         WriteElements(source, choiceSource, elements, text, choice, "a", writeAccessors, memberTypeDesc.IsNullable);
 }
开发者ID:uQr,项目名称:referencesource,代码行数:7,代码来源:XmlSerializationWriter.cs

示例14: ImportMembersMapping

        /// <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);
            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;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:18,代码来源:soapreflectionimporter.cs

示例15: ImportAccessorMapping

        void ImportAccessorMapping(MemberMapping accessor, FieldModel model, SoapAttributes a, string ns, XmlSchemaForm form) {
            Type accessorType = model.FieldType;
            string accessorName = model.Name;
            accessor.TypeDesc = typeScope.GetTypeDesc(accessorType);
            if (accessor.TypeDesc.IsVoid) {
                throw new InvalidOperationException(Res.GetString(Res.XmlInvalidVoid));
            }

            SoapAttributeFlags flags = a.SoapFlags;
            if ((flags & SoapAttributeFlags.Attribute) == SoapAttributeFlags.Attribute) {
                if (!accessor.TypeDesc.IsPrimitive && !accessor.TypeDesc.IsEnum)
                    throw new InvalidOperationException(Res.GetString(Res.XmlIllegalSoapAttribute, accessorName, accessor.TypeDesc.FullName));

                if ((flags & SoapAttributeFlags.Attribute) != flags)
                    throw new InvalidOperationException(Res.GetString(Res.XmlInvalidElementAttribute));
                
                AttributeAccessor attribute = new AttributeAccessor();
                attribute.Name = Accessor.EscapeQName(a.SoapAttribute == null || a.SoapAttribute.AttributeName.Length == 0 ? accessorName : a.SoapAttribute.AttributeName);
                attribute.Namespace = a.SoapAttribute == null || a.SoapAttribute.Namespace == null ? ns : a.SoapAttribute.Namespace;
                attribute.Form = XmlSchemaForm.Qualified; // attributes are always qualified since they're only used for encoded soap headers
                attribute.Mapping = ImportTypeMapping(modelScope.GetTypeModel(accessorType), (a.SoapAttribute == null ? String.Empty : a.SoapAttribute.DataType));
                attribute.Default = GetDefaultValue(model.FieldTypeDesc, a);
                accessor.Attribute = attribute;
                accessor.Elements = new ElementAccessor[0];
            }
            else {
                if ((flags & SoapAttributeFlags.Element) != flags)
                    throw new InvalidOperationException(Res.GetString(Res.XmlInvalidElementAttribute));

                ElementAccessor element = new ElementAccessor();
                element.IsSoap = true;
                element.Name = XmlConvert.EncodeLocalName(a.SoapElement == null || a.SoapElement.ElementName.Length == 0 ? accessorName : a.SoapElement.ElementName);
                element.Namespace = ns;
                element.Form = form;
                element.Mapping = ImportTypeMapping(modelScope.GetTypeModel(accessorType), (a.SoapElement == null ? String.Empty : a.SoapElement.DataType));
                if (a.SoapElement != null)
                    element.IsNullable = a.SoapElement.IsNullable;
                accessor.Elements = new ElementAccessor[] { element };
            }
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:40,代码来源:soapreflectionimporter.cs


注:本文中的System.Xml.Serialization.ElementAccessor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。