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


C# CodeIdentifiers.Add方法代码示例

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


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

示例1: IgnoreCase

		public void IgnoreCase ()
		{
			CodeIdentifiers c = new CodeIdentifiers (false);
			c.Add ("test", "x");
			c.Add ("Test", "y");
			Assert.IsTrue ("test" != c.AddUnique ("Test", "z"), "#1");
			Assert.IsTrue (c.IsInUse ("tEsT"), "#2");
			Assert.AreEqual ("camelCase", c.MakeRightCase ("CAMELCASE"), "#3");
		}
开发者ID:nobled,项目名称:mono,代码行数:9,代码来源:CodeIdentifiersTests.cs

示例2: ImportChoiceGroup

        private MemberMapping ImportChoiceGroup(XmlSchemaGroupBase group, string identifier, CodeIdentifiers members, CodeIdentifiers membersScope, INameScope elementsScope, string ns, bool groupRepeats, ref bool needExplicitOrder, bool allowDuplicates)
        {
            NameTable choiceElements = new NameTable();
            if (GatherGroupChoices(group, choiceElements, identifier, ns, ref needExplicitOrder, allowDuplicates))
                groupRepeats = true;
            MemberMapping member = new MemberMapping();
            member.Elements = (ElementAccessor[])choiceElements.ToArray(typeof(ElementAccessor));
            Array.Sort(member.Elements, new ElementComparer());

            AddScopeElements(elementsScope, member.Elements, ref needExplicitOrder, allowDuplicates);
            bool duplicateTypes = false;
            bool nullableMismatch = false;
            Hashtable uniqueTypeDescs = new Hashtable(member.Elements.Length);

            for (int i = 0; i < member.Elements.Length; i++)
            {
                ElementAccessor element = member.Elements[i];
                string tdFullName = element.Mapping.TypeDesc.FullName;
                object val = uniqueTypeDescs[tdFullName];
                if (val != null)
                {
                    duplicateTypes = true;
                    ElementAccessor existingElement = (ElementAccessor)val;
                    if (!nullableMismatch && existingElement.IsNullable != element.IsNullable)
                        nullableMismatch = true;
                }
                else
                {
                    uniqueTypeDescs.Add(tdFullName, element);
                }

                ArrayMapping arrayMapping = element.Mapping as ArrayMapping;
                if (arrayMapping != null)
                {
                    if (IsNeedXmlSerializationAttributes(arrayMapping))
                    {
                        // we cannot use ArrayMapping in choice if additional custom 
                        // serialization attributes are needed to serialize it
                        element.Mapping = arrayMapping.TopLevelMapping;
                        element.Mapping.ReferencedByTopLevelElement = false;
                        element.Mapping.ReferencedByElement = true;
                    }
                }
            }
            if (nullableMismatch)
                member.TypeDesc = Scope.GetTypeDesc(typeof(object));
            else
            {
                TypeDesc[] typeDescs = new TypeDesc[uniqueTypeDescs.Count];
                IEnumerator enumerator = uniqueTypeDescs.Values.GetEnumerator();
                for (int i = 0; i < typeDescs.Length; i++)
                {
                    if (!enumerator.MoveNext())
                        break;
                    typeDescs[i] = ((ElementAccessor)enumerator.Current).Mapping.TypeDesc;
                }
                member.TypeDesc = TypeDesc.FindCommonBaseTypeDesc(typeDescs);
                if (member.TypeDesc == null) member.TypeDesc = Scope.GetTypeDesc(typeof(object));
            }

            if (groupRepeats)
                member.TypeDesc = member.TypeDesc.CreateArrayTypeDesc();

            if (membersScope != null)
            {
                member.Name = membersScope.AddUnique(groupRepeats ? "Items" : "Item", member);
                if (members != null)
                {
                    members.Add(member.Name, member);
                }
            }

            if (duplicateTypes)
            {
                member.ChoiceIdentifier = new ChoiceIdentifierAccessor();
                member.ChoiceIdentifier.MemberName = member.Name + "ElementName";
                // we need to create the EnumMapping to store all of the element names
                member.ChoiceIdentifier.Mapping = ImportEnumeratedChoice(member.Elements, ns, member.Name + "ChoiceType");
                member.ChoiceIdentifier.MemberIds = new string[member.Elements.Length];
                ConstantMapping[] constants = ((EnumMapping)member.ChoiceIdentifier.Mapping).Constants;
                for (int i = 0; i < member.Elements.Length; i++)
                {
                    member.ChoiceIdentifier.MemberIds[i] = constants[i].Name;
                }
                MemberMapping choiceIdentifier = new MemberMapping();
                choiceIdentifier.Ignore = true;
                choiceIdentifier.Name = member.ChoiceIdentifier.MemberName;
                if (groupRepeats)
                {
                    choiceIdentifier.TypeDesc = member.ChoiceIdentifier.Mapping.TypeDesc.CreateArrayTypeDesc();
                }
                else
                {
                    choiceIdentifier.TypeDesc = member.ChoiceIdentifier.Mapping.TypeDesc;
                }

                // create element accessor for the choiceIdentifier

                ElementAccessor choiceAccessor = new ElementAccessor();
                choiceAccessor.Name = choiceIdentifier.Name;
//.........这里部分代码省略.........
开发者ID:geoffkizer,项目名称:corefx,代码行数:101,代码来源:XmlSchemaImporter.cs

示例3: ImportAnyAttributeMember

        private void ImportAnyAttributeMember(XmlSchemaAnyAttribute any, CodeIdentifiers members, CodeIdentifiers membersScope)
        {
            SpecialMapping mapping = new SpecialMapping();
            mapping.TypeDesc = Scope.GetTypeDesc(typeof(XmlAttribute));
            mapping.TypeName = mapping.TypeDesc.Name;

            AttributeAccessor accessor = new AttributeAccessor();
            accessor.Any = true;
            accessor.Mapping = mapping;

            MemberMapping member = new MemberMapping();
            member.Elements = new ElementAccessor[0];
            member.Attribute = accessor;
            member.Name = membersScope.MakeRightCase("AnyAttr");
            member.Name = membersScope.AddUnique(member.Name, member);
            members.Add(member.Name, member);
            member.TypeDesc = ((TypeMapping)accessor.Mapping).TypeDesc;
            member.TypeDesc = member.TypeDesc.CreateArrayTypeDesc();
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:19,代码来源:XmlSchemaImporter.cs

示例4: ImportXmlnsDeclarationsMember

        private void ImportXmlnsDeclarationsMember(XmlSchemaType type, CodeIdentifiers members, CodeIdentifiers membersScope)
        {
            string xmlnsMemberName;
            if (!KeepXmlnsDeclarations(type, out xmlnsMemberName))
                return;
            TypeDesc xmlnsTypeDesc = Scope.GetTypeDesc(typeof(XmlSerializerNamespaces));
            StructMapping xmlnsMapping = new StructMapping();

            xmlnsMapping.TypeDesc = xmlnsTypeDesc;
            xmlnsMapping.TypeName = xmlnsMapping.TypeDesc.Name;
            xmlnsMapping.Members = new MemberMapping[0];
            xmlnsMapping.IncludeInSchema = false;
            xmlnsMapping.ReferencedByTopLevelElement = true;

            ElementAccessor xmlns = new ElementAccessor();
            xmlns.Mapping = xmlnsMapping;

            MemberMapping member = new MemberMapping();
            member.Elements = new ElementAccessor[] { xmlns };
            member.Name = CodeIdentifier.MakeValid(xmlnsMemberName == null ? "Namespaces" : xmlnsMemberName);
            member.Name = membersScope.AddUnique(member.Name, member);
            members.Add(member.Name, member);
            member.TypeDesc = xmlnsTypeDesc;
            member.Xmlns = new XmlnsAccessor();
            member.Ignore = true;
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:26,代码来源:XmlSchemaImporter.cs

示例5: ImportElementMember

        private void ImportElementMember(XmlSchemaElement element, string identifier, CodeIdentifiers members, CodeIdentifiers membersScope, INameScope elementsScope, string ns, bool repeats, ref bool needExplicitOrder, bool allowDuplicates, bool allowUnboundedElements)
        {
            repeats = repeats | element.IsMultipleOccurrence;
            XmlSchemaElement headElement = GetTopLevelElement(element);
            if (headElement != null && ImportSubstitutionGroupMember(headElement, identifier, members, membersScope, ns, repeats, ref needExplicitOrder, allowDuplicates))
            {
                return;
            }
            ElementAccessor accessor;
            if ((accessor = ImportArray(element, identifier, ns, repeats)) == null)
            {
                accessor = ImportElement(element, identifier, typeof(TypeMapping), null, ns, false);
            }

            MemberMapping member = new MemberMapping();
            string name = CodeIdentifier.MakeValid(Accessor.UnescapeName(accessor.Name));
            member.Name = membersScope.AddUnique(name, member);

            if (member.Name.EndsWith("Specified", StringComparison.Ordinal))
            {
                name = member.Name;
                member.Name = membersScope.AddUnique(member.Name, member);
                membersScope.Remove(name);
            }
            members.Add(member.Name, member);
            // we do not support lists for elements
            if (accessor.Mapping.IsList)
            {
                accessor.Mapping = GetDefaultMapping(TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue);
                member.TypeDesc = accessor.Mapping.TypeDesc;
            }
            else
            {
                member.TypeDesc = accessor.Mapping.TypeDesc;
            }

            AddScopeElement(elementsScope, accessor, ref needExplicitOrder, allowDuplicates);
            member.Elements = new ElementAccessor[] { accessor };

            if (element.IsMultipleOccurrence || repeats)
            {
                if (!allowUnboundedElements && accessor.Mapping is ArrayMapping)
                {
                    accessor.Mapping = ((ArrayMapping)accessor.Mapping).TopLevelMapping;
                    accessor.Mapping.ReferencedByTopLevelElement = false;
                    accessor.Mapping.ReferencedByElement = true;
                }
                member.TypeDesc = accessor.Mapping.TypeDesc.CreateArrayTypeDesc();
            }

            if (element.MinOccurs == 0 && member.TypeDesc.IsValueType && !element.HasDefault && !member.TypeDesc.HasIsEmpty)
            {
                member.CheckSpecified = SpecifiedAccessor.ReadWrite;
            }
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:55,代码来源:XmlSchemaImporter.cs

示例6: ImportAttributeMember

        private void ImportAttributeMember(XmlSchemaAttribute attribute, string identifier, CodeIdentifiers members, CodeIdentifiers membersScope, string ns)
        {
            AttributeAccessor accessor = ImportAttribute(attribute, identifier, ns, attribute);
            if (accessor == null) return;
            MemberMapping member = new MemberMapping();
            member.Elements = new ElementAccessor[0];
            member.Attribute = accessor;
            member.Name = CodeIdentifier.MakeValid(Accessor.UnescapeName(accessor.Name));
            member.Name = membersScope.AddUnique(member.Name, member);
            if (member.Name.EndsWith("Specified", StringComparison.Ordinal))
            {
                string name = member.Name;
                member.Name = membersScope.AddUnique(member.Name, member);
                membersScope.Remove(name);
            }
            members.Add(member.Name, member);
            member.TypeDesc = accessor.IsList ? accessor.Mapping.TypeDesc.CreateArrayTypeDesc() : accessor.Mapping.TypeDesc;

            if ((attribute.Use == XmlSchemaUse.Optional || attribute.Use == XmlSchemaUse.None) && member.TypeDesc.IsValueType && !attribute.HasDefault && !member.TypeDesc.HasIsEmpty)
            {
                member.CheckSpecified = SpecifiedAccessor.ReadWrite;
            }
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:23,代码来源:XmlSchemaImporter.cs

示例7: ImportTextMember

        private void ImportTextMember(CodeIdentifiers members, CodeIdentifiers membersScope, XmlQualifiedName simpleContentType)
        {
            TypeMapping mapping;
            bool isMixed = false;

            if (simpleContentType != null)
            {
                // allow to use all primitive types
                mapping = ImportType(simpleContentType, typeof(TypeMapping), null, TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue, false);
                if (!(mapping is PrimitiveMapping || mapping.TypeDesc.CanBeTextValue))
                {
                    return;
                }
            }
            else
            {
                // this is a case of the mixed content type, just generate string typeDesc
                isMixed = true;
                mapping = GetDefaultMapping(TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue);
            }

            TextAccessor accessor = new TextAccessor();
            accessor.Mapping = mapping;

            MemberMapping member = new MemberMapping();
            member.Elements = new ElementAccessor[0];
            member.Text = accessor;
            if (isMixed)
            {
                // just generate code for the standard mixed case (string[] text)
                member.TypeDesc = accessor.Mapping.TypeDesc.CreateArrayTypeDesc();
                member.Name = members.MakeRightCase("Text");
            }
            else
            {
                // import mapping for the simpleContent
                PrimitiveMapping pm = (PrimitiveMapping)accessor.Mapping;
                if (pm.IsList)
                {
                    member.TypeDesc = accessor.Mapping.TypeDesc.CreateArrayTypeDesc();
                    member.Name = members.MakeRightCase("Text");
                }
                else
                {
                    member.TypeDesc = accessor.Mapping.TypeDesc;
                    member.Name = members.MakeRightCase("Value");
                }
            }
            member.Name = membersScope.AddUnique(member.Name, member);
            members.Add(member.Name, member);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:51,代码来源:XmlSchemaImporter.cs

示例8: ImportAnyMember

        private MemberMapping ImportAnyMember(XmlSchemaAny any, string identifier, CodeIdentifiers members, CodeIdentifiers membersScope, INameScope elementsScope, string ns, ref bool mixed, ref bool needExplicitOrder, bool allowDuplicates)
        {
            ElementAccessor[] accessors = ImportAny(any, !mixed, ns);
            AddScopeElements(elementsScope, accessors, ref needExplicitOrder, allowDuplicates);
            MemberMapping member = new MemberMapping();
            member.Elements = accessors;
            member.Name = membersScope.MakeRightCase("Any");
            member.Name = membersScope.AddUnique(member.Name, member);
            members.Add(member.Name, member);
            member.TypeDesc = ((TypeMapping)accessors[0].Mapping).TypeDesc;

            bool repeats = any.IsMultipleOccurrence;

            if (mixed)
            {
                SpecialMapping textMapping = new SpecialMapping();
                textMapping.TypeDesc = Scope.GetTypeDesc(typeof(XmlNode));
                textMapping.TypeName = textMapping.TypeDesc.Name;
                member.TypeDesc = textMapping.TypeDesc;
                TextAccessor text = new TextAccessor();
                text.Mapping = textMapping;
                member.Text = text;
                repeats = true;
                mixed = false;
            }

            if (repeats)
            {
                member.TypeDesc = member.TypeDesc.CreateArrayTypeDesc();
            }
            return member;
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:32,代码来源:XmlSchemaImporter.cs

示例9: ImportAttributeMember

 private void ImportAttributeMember(XmlSchemaAttribute attribute, string identifier, CodeIdentifiers members, CodeIdentifiers membersScope, string ns)
 {
     AttributeAccessor accessor = this.ImportAttribute(attribute, identifier, ns, attribute);
     if (accessor != null)
     {
         MemberMapping mapping;
         mapping = new MemberMapping {
             Elements = new ElementAccessor[0],
             Attribute = accessor,
             Name = CodeIdentifier.MakeValid(Accessor.UnescapeName(accessor.Name)),
             Name = membersScope.AddUnique(mapping.Name, mapping)
         };
         if (mapping.Name.EndsWith("Specified", StringComparison.Ordinal))
         {
             string name = mapping.Name;
             mapping.Name = membersScope.AddUnique(mapping.Name, mapping);
             membersScope.Remove(name);
         }
         members.Add(mapping.Name, mapping);
         mapping.TypeDesc = accessor.IsList ? accessor.Mapping.TypeDesc.CreateArrayTypeDesc() : accessor.Mapping.TypeDesc;
         if (((attribute.Use == XmlSchemaUse.Optional) || (attribute.Use == XmlSchemaUse.None)) && ((mapping.TypeDesc.IsValueType && !attribute.HasDefault) && !mapping.TypeDesc.HasIsEmpty))
         {
             mapping.CheckSpecified = SpecifiedAccessor.ReadWrite;
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:XmlSchemaImporter.cs

示例10: ImportChoiceGroup

 private MemberMapping ImportChoiceGroup(XmlSchemaGroupBase group, string identifier, CodeIdentifiers members, CodeIdentifiers membersScope, INameScope elementsScope, string ns, bool groupRepeats, ref bool needExplicitOrder, bool allowDuplicates)
 {
     System.Xml.Serialization.NameTable choiceElements = new System.Xml.Serialization.NameTable();
     if (this.GatherGroupChoices(group, choiceElements, identifier, ns, ref needExplicitOrder, allowDuplicates))
     {
         groupRepeats = true;
     }
     MemberMapping mapping = new MemberMapping {
         Elements = (ElementAccessor[]) choiceElements.ToArray(typeof(ElementAccessor))
     };
     Array.Sort(mapping.Elements, new ElementComparer());
     this.AddScopeElements(elementsScope, mapping.Elements, ref needExplicitOrder, allowDuplicates);
     bool flag = false;
     bool flag2 = false;
     Hashtable hashtable = new Hashtable(mapping.Elements.Length);
     for (int i = 0; i < mapping.Elements.Length; i++)
     {
         ElementAccessor accessor = mapping.Elements[i];
         string fullName = accessor.Mapping.TypeDesc.FullName;
         object obj2 = hashtable[fullName];
         if (obj2 != null)
         {
             flag = true;
             ElementAccessor accessor2 = (ElementAccessor) obj2;
             if (!flag2 && (accessor2.IsNullable != accessor.IsNullable))
             {
                 flag2 = true;
             }
         }
         else
         {
             hashtable.Add(fullName, accessor);
         }
         ArrayMapping arrayMapping = accessor.Mapping as ArrayMapping;
         if ((arrayMapping != null) && this.IsNeedXmlSerializationAttributes(arrayMapping))
         {
             accessor.Mapping = arrayMapping.TopLevelMapping;
             accessor.Mapping.ReferencedByTopLevelElement = false;
             accessor.Mapping.ReferencedByElement = true;
         }
     }
     if (flag2)
     {
         mapping.TypeDesc = base.Scope.GetTypeDesc(typeof(object));
     }
     else
     {
         TypeDesc[] typeDescs = new TypeDesc[hashtable.Count];
         IEnumerator enumerator = hashtable.Values.GetEnumerator();
         for (int j = 0; j < typeDescs.Length; j++)
         {
             if (!enumerator.MoveNext())
             {
                 break;
             }
             typeDescs[j] = ((ElementAccessor) enumerator.Current).Mapping.TypeDesc;
         }
         mapping.TypeDesc = TypeDesc.FindCommonBaseTypeDesc(typeDescs);
         if (mapping.TypeDesc == null)
         {
             mapping.TypeDesc = base.Scope.GetTypeDesc(typeof(object));
         }
     }
     if (groupRepeats)
     {
         mapping.TypeDesc = mapping.TypeDesc.CreateArrayTypeDesc();
     }
     if (membersScope != null)
     {
         mapping.Name = membersScope.AddUnique(groupRepeats ? "Items" : "Item", mapping);
         if (members != null)
         {
             members.Add(mapping.Name, mapping);
         }
     }
     if (flag)
     {
         mapping.ChoiceIdentifier = new ChoiceIdentifierAccessor();
         mapping.ChoiceIdentifier.MemberName = mapping.Name + "ElementName";
         mapping.ChoiceIdentifier.Mapping = this.ImportEnumeratedChoice(mapping.Elements, ns, mapping.Name + "ChoiceType");
         mapping.ChoiceIdentifier.MemberIds = new string[mapping.Elements.Length];
         ConstantMapping[] constants = ((EnumMapping) mapping.ChoiceIdentifier.Mapping).Constants;
         for (int k = 0; k < mapping.Elements.Length; k++)
         {
             mapping.ChoiceIdentifier.MemberIds[k] = constants[k].Name;
         }
         MemberMapping mapping3 = new MemberMapping {
             Ignore = true,
             Name = mapping.ChoiceIdentifier.MemberName
         };
         if (groupRepeats)
         {
             mapping3.TypeDesc = mapping.ChoiceIdentifier.Mapping.TypeDesc.CreateArrayTypeDesc();
         }
         else
         {
             mapping3.TypeDesc = mapping.ChoiceIdentifier.Mapping.TypeDesc;
         }
         ElementAccessor accessor3 = new ElementAccessor {
             Name = mapping3.Name,
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:XmlSchemaImporter.cs

示例11: ImportAnyMember

 private MemberMapping ImportAnyMember(XmlSchemaAny any, string identifier, CodeIdentifiers members, CodeIdentifiers membersScope, INameScope elementsScope, string ns, ref bool mixed, ref bool needExplicitOrder, bool allowDuplicates)
 {
     MemberMapping mapping;
     ElementAccessor[] elements = this.ImportAny(any, !mixed, ns);
     this.AddScopeElements(elementsScope, elements, ref needExplicitOrder, allowDuplicates);
     mapping = new MemberMapping {
         Elements = elements,
         Name = membersScope.MakeRightCase("Any"),
         Name = membersScope.AddUnique(mapping.Name, mapping)
     };
     members.Add(mapping.Name, mapping);
     mapping.TypeDesc = elements[0].Mapping.TypeDesc;
     bool isMultipleOccurrence = any.IsMultipleOccurrence;
     if (mixed)
     {
         SpecialMapping mapping2;
         mapping2 = new SpecialMapping {
             TypeDesc = base.Scope.GetTypeDesc(typeof(XmlNode)),
             TypeName = mapping2.TypeDesc.Name
         };
         mapping.TypeDesc = mapping2.TypeDesc;
         TextAccessor accessor = new TextAccessor {
             Mapping = mapping2
         };
         mapping.Text = accessor;
         isMultipleOccurrence = true;
         mixed = false;
     }
     if (isMultipleOccurrence)
     {
         mapping.TypeDesc = mapping.TypeDesc.CreateArrayTypeDesc();
     }
     return mapping;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:XmlSchemaImporter.cs

示例12: ImportAnyAttributeMember

 private void ImportAnyAttributeMember(XmlSchemaAnyAttribute any, CodeIdentifiers members, CodeIdentifiers membersScope)
 {
     SpecialMapping mapping;
     MemberMapping mapping2;
     mapping = new SpecialMapping {
         TypeDesc = base.Scope.GetTypeDesc(typeof(XmlAttribute)),
         TypeName = mapping.TypeDesc.Name
     };
     AttributeAccessor accessor = new AttributeAccessor {
         Any = true,
         Mapping = mapping
     };
     mapping2 = new MemberMapping {
         Elements = new ElementAccessor[0],
         Attribute = accessor,
         Name = membersScope.MakeRightCase("AnyAttr"),
         Name = membersScope.AddUnique(mapping2.Name, mapping2)
     };
     members.Add(mapping2.Name, mapping2);
     mapping2.TypeDesc = accessor.Mapping.TypeDesc;
     mapping2.TypeDesc = mapping2.TypeDesc.CreateArrayTypeDesc();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:XmlSchemaImporter.cs

示例13: ImportXmlnsDeclarationsMember

 private void ImportXmlnsDeclarationsMember(XmlSchemaType type, CodeIdentifiers members, CodeIdentifiers membersScope)
 {
     string str;
     if (this.KeepXmlnsDeclarations(type, out str))
     {
         StructMapping mapping;
         MemberMapping mapping2;
         TypeDesc typeDesc = base.Scope.GetTypeDesc(typeof(XmlSerializerNamespaces));
         mapping = new StructMapping {
             TypeDesc = typeDesc,
             TypeName = mapping.TypeDesc.Name,
             Members = new MemberMapping[0],
             IncludeInSchema = false,
             ReferencedByTopLevelElement = true
         };
         ElementAccessor accessor = new ElementAccessor {
             Mapping = mapping
         };
         mapping2 = new MemberMapping {
             Elements = new ElementAccessor[] { accessor },
             Name = CodeIdentifier.MakeValid((str == null) ? "Namespaces" : str),
             Name = membersScope.AddUnique(mapping2.Name, mapping2)
         };
         members.Add(mapping2.Name, mapping2);
         mapping2.TypeDesc = typeDesc;
         mapping2.Xmlns = new XmlnsAccessor();
         mapping2.Ignore = true;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:XmlSchemaImporter.cs

示例14: ImportTextMember

 private void ImportTextMember(CodeIdentifiers members, CodeIdentifiers membersScope, XmlQualifiedName simpleContentType)
 {
     TypeMapping defaultMapping;
     bool flag = false;
     if (simpleContentType != null)
     {
         defaultMapping = this.ImportType(simpleContentType, typeof(TypeMapping), null, TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue, false);
         if (!(defaultMapping is PrimitiveMapping) && !defaultMapping.TypeDesc.CanBeTextValue)
         {
             return;
         }
     }
     else
     {
         flag = true;
         defaultMapping = this.GetDefaultMapping(TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue);
     }
     TextAccessor accessor = new TextAccessor {
         Mapping = defaultMapping
     };
     MemberMapping mapping2 = new MemberMapping {
         Elements = new ElementAccessor[0],
         Text = accessor
     };
     if (flag)
     {
         mapping2.TypeDesc = accessor.Mapping.TypeDesc.CreateArrayTypeDesc();
         mapping2.Name = members.MakeRightCase("Text");
     }
     else
     {
         PrimitiveMapping mapping = (PrimitiveMapping) accessor.Mapping;
         if (mapping.IsList)
         {
             mapping2.TypeDesc = accessor.Mapping.TypeDesc.CreateArrayTypeDesc();
             mapping2.Name = members.MakeRightCase("Text");
         }
         else
         {
             mapping2.TypeDesc = accessor.Mapping.TypeDesc;
             mapping2.Name = members.MakeRightCase("Value");
         }
     }
     mapping2.Name = membersScope.AddUnique(mapping2.Name, mapping2);
     members.Add(mapping2.Name, mapping2);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:XmlSchemaImporter.cs

示例15: AddAsyncMembers

		void AddAsyncMembers (string messageName, CodeMemberMethod method)
		{
			CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
			CodePrimitiveExpression enull = new CodePrimitiveExpression (null);
			
			CodeMemberField codeField = new CodeMemberField (typeof(System.Threading.SendOrPostCallback), messageName + "OperationCompleted");
			codeField.Attributes = MemberAttributes.Private;
			CodeTypeDeclaration.Members.Add (codeField);
			
			// Event arguments class
			
			string argsClassName = classNames.AddUnique (messageName + "CompletedEventArgs", null);
			CodeTypeDeclaration argsClass = new CodeTypeDeclaration (argsClassName);
			argsClass.BaseTypes.Add (new CodeTypeReference ("System.ComponentModel.AsyncCompletedEventArgs"));

			CodeMemberField resultsField = new CodeMemberField (typeof(object[]), "results");
			resultsField.Attributes = MemberAttributes.Private;
			argsClass.Members.Add (resultsField);
			
			CodeConstructor cc = new CodeConstructor ();
			cc.Attributes = MemberAttributes.Assembly;
			cc.Parameters.Add (new CodeParameterDeclarationExpression (typeof(object[]), "results"));
			cc.Parameters.Add (new CodeParameterDeclarationExpression (typeof(System.Exception), "exception"));
			cc.Parameters.Add (new CodeParameterDeclarationExpression (typeof(bool), "cancelled"));
			cc.Parameters.Add (new CodeParameterDeclarationExpression (typeof(object), "userState"));
			cc.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("exception"));
			cc.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("cancelled"));
			cc.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("userState"));
			CodeExpression thisResults = new CodeFieldReferenceExpression (ethis, "results");
			cc.Statements.Add (new CodeAssignStatement (thisResults, new CodeVariableReferenceExpression ("results")));
			argsClass.Members.Add (cc);
			
			int ind = 0;
			
			if (method.ReturnType.BaseType != "System.Void")
				argsClass.Members.Add (CreateArgsProperty (method.ReturnType, "Result", ind++));
			
			foreach (CodeParameterDeclarationExpression par in method.Parameters) 
			{
				if (par.Direction == FieldDirection.Out || par.Direction == FieldDirection.Ref)
					argsClass.Members.Add (CreateArgsProperty (par.Type, par.Name, ind++));
			}
			
			bool needsArgsClass = (ind > 0);
			if (needsArgsClass)
				asyncTypes.Add (argsClass);
			else
				argsClassName = "System.ComponentModel.AsyncCompletedEventArgs";
			
			// Event delegate type
			
			CodeTypeDelegate delegateType = new CodeTypeDelegate (messageName + "CompletedEventHandler");
			delegateType.Parameters.Add (new CodeParameterDeclarationExpression (typeof(object), "sender"));
			delegateType.Parameters.Add (new CodeParameterDeclarationExpression (argsClassName, "args"));
			
			// Event member
			
			CodeMemberEvent codeEvent = new CodeMemberEvent ();
			codeEvent.Name = messageName + "Completed";
			codeEvent.Type = new CodeTypeReference (delegateType.Name);
			CodeTypeDeclaration.Members.Add (codeEvent);
			
			// Async method (without user state param)
			
			CodeMemberMethod am = new CodeMemberMethod ();
			am.Attributes = MemberAttributes.Public | MemberAttributes.Final;
			am.Name = method.Name + "Async";
			am.ReturnType = new CodeTypeReference (typeof(void));
			CodeMethodInvokeExpression inv;
			inv = new CodeMethodInvokeExpression (ethis, am.Name);
			am.Statements.Add (inv);
			
			// On...Completed method
			
			CodeMemberMethod onCompleted = new CodeMemberMethod ();
			onCompleted.Name = "On" + messageName + "Completed";
			onCompleted.Attributes = MemberAttributes.Private | MemberAttributes.Final;
			onCompleted.ReturnType = new CodeTypeReference (typeof(void));
			onCompleted.Parameters.Add (new CodeParameterDeclarationExpression (typeof(object), "arg"));
			
			CodeConditionStatement anIf = new CodeConditionStatement ();
			
			CodeExpression eventField = new CodeEventReferenceExpression (ethis, codeEvent.Name);
			anIf.Condition = new CodeBinaryOperatorExpression (eventField, CodeBinaryOperatorType.IdentityInequality, enull);
			CodeExpression castedArg = new CodeCastExpression (typeof(System.Web.Services.Protocols.InvokeCompletedEventArgs), new CodeVariableReferenceExpression ("arg"));
			CodeStatement invokeArgs = new CodeVariableDeclarationStatement (typeof(System.Web.Services.Protocols.InvokeCompletedEventArgs), "invokeArgs", castedArg);
			anIf.TrueStatements.Add (invokeArgs);
			
			CodeDelegateInvokeExpression delegateInvoke = new CodeDelegateInvokeExpression ();
			delegateInvoke.TargetObject = eventField;
			delegateInvoke.Parameters.Add (ethis);
			CodeObjectCreateExpression argsInstance = new CodeObjectCreateExpression (argsClassName);
			CodeExpression invokeArgsVar = new CodeVariableReferenceExpression ("invokeArgs");
			if (needsArgsClass) argsInstance.Parameters.Add (new CodeFieldReferenceExpression (invokeArgsVar, "Results"));
			argsInstance.Parameters.Add (new CodeFieldReferenceExpression (invokeArgsVar, "Error"));
			argsInstance.Parameters.Add (new CodeFieldReferenceExpression (invokeArgsVar, "Cancelled"));
			argsInstance.Parameters.Add (new CodeFieldReferenceExpression (invokeArgsVar, "UserState"));
			delegateInvoke.Parameters.Add (argsInstance);
			anIf.TrueStatements.Add (delegateInvoke);
			
//.........这里部分代码省略.........
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:101,代码来源:ProtocolImporter.cs


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