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


C# IXmlDocument.CreateComment方法代码示例

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


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

示例1: DeserializeNode

 // Token: 0x060006EC RID: 1772
 // RVA: 0x00038AB8 File Offset: 0x00036CB8
 private void DeserializeNode(JsonReader reader, IXmlDocument document, XmlNamespaceManager manager, IXmlNode currentNode)
 {
     JsonToken tokenType;
     while (true)
     {
         tokenType = reader.TokenType;
         switch (tokenType)
         {
         case JsonToken.StartConstructor:
         {
             string propertyName2 = reader.Value.ToString();
             while (reader.Read())
             {
                 if (reader.TokenType == JsonToken.EndConstructor)
                 {
                     break;
                 }
                 this.DeserializeValue(reader, document, manager, propertyName2, currentNode);
             }
             goto IL_44;
         }
         case JsonToken.PropertyName:
         {
             if (currentNode.NodeType == XmlNodeType.Document && document.DocumentElement != null)
             {
                 goto IL_17B;
             }
             string propertyName = reader.Value.ToString();
             reader.Read();
             if (reader.TokenType != JsonToken.StartArray)
             {
                 this.DeserializeValue(reader, document, manager, propertyName, currentNode);
                 goto IL_44;
             }
             int num = 0;
             while (reader.Read())
             {
                 if (reader.TokenType == JsonToken.EndArray)
                 {
                     break;
                 }
                 this.DeserializeValue(reader, document, manager, propertyName, currentNode);
                 num++;
             }
             if (num == 1 && this.WriteArrayAttribute)
             {
                 IXmlElement element = Enumerable.Single<IXmlElement>(Enumerable.OfType<IXmlElement>(currentNode.ChildNodes), (IXmlElement n) => n.LocalName == propertyName);
                 this.AddJsonArrayAttribute(element, document);
                 goto IL_44;
             }
             goto IL_44;
         }
         case JsonToken.Comment:
             currentNode.AppendChild(document.CreateComment((string)reader.Value));
             goto IL_44;
         }
         break;
         IL_44:
         if (reader.TokenType != JsonToken.PropertyName && !reader.Read())
         {
             return;
         }
     }
     switch (tokenType)
     {
     case JsonToken.EndObject:
     case JsonToken.EndArray:
         return;
     default:
         throw new JsonSerializationException("Unexpected JsonToken when deserializing node: " + reader.TokenType);
     }
     return;
     IL_17B:
     throw new JsonSerializationException("JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.");
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:77,代码来源:XmlNodeConverter.cs

示例2: DeserializeNode

    private void DeserializeNode(JsonReader reader, IXmlDocument document, XmlNamespaceManager manager, IXmlNode currentNode)
    {
      do
      {
        switch (reader.TokenType)
        {
          case JsonToken.PropertyName:
            if (currentNode.NodeType == XmlNodeType.Document && document.DocumentElement != null)
              throw new JsonSerializationException("JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.");

            string propertyName = reader.Value.ToString();
            reader.Read();

            if (reader.TokenType == JsonToken.StartArray)
            {
              int count = 0;
              while (reader.Read() && reader.TokenType != JsonToken.EndArray)
              {
                DeserializeValue(reader, document, manager, propertyName, currentNode);
                count++;
              }

              if (count == 1 && WriteArrayAttribute)
              {
                IXmlElement arrayElement = currentNode.ChildNodes.CastValid<IXmlElement>().Single(n => n.LocalName == propertyName);
                AddJsonArrayAttribute(arrayElement, document);
              }
            }
            else
            {
              DeserializeValue(reader, document, manager, propertyName, currentNode);
            }
            break;
          case JsonToken.StartConstructor:
            string constructorName = reader.Value.ToString();

            while (reader.Read() && reader.TokenType != JsonToken.EndConstructor)
            {
              DeserializeValue(reader, document, manager, constructorName, currentNode);
            }
            break;
          case JsonToken.Comment:
            currentNode.AppendChild(document.CreateComment((string)reader.Value));
            break;
          case JsonToken.EndObject:
          case JsonToken.EndArray:
            return;
          default:
            throw new JsonSerializationException("Unexpected JsonToken when deserializing node: " + reader.TokenType);
        }
      } while (reader.TokenType == JsonToken.PropertyName || reader.Read());
      // don't read if current token is a property. token was already read when parsing element attributes
    }
开发者ID:284247028,项目名称:MvvmCross,代码行数:53,代码来源:XmlNodeConverter.cs

示例3: DeserializeNode

 private void DeserializeNode(JsonReader reader, IXmlDocument document, XmlNamespaceManager manager, IXmlNode currentNode)
 {
   do
   {
     switch (reader.TokenType)
     {
       case JsonToken.StartConstructor:
         string propertyName1 = reader.Value.ToString();
         while (reader.Read() && reader.TokenType != JsonToken.EndConstructor)
           this.DeserializeValue(reader, document, manager, propertyName1, currentNode);
         break;
       case JsonToken.PropertyName:
         if (currentNode.NodeType == XmlNodeType.Document && document.DocumentElement != null)
           throw new JsonSerializationException("JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.");
         string propertyName = reader.Value.ToString();
         reader.Read();
         if (reader.TokenType == JsonToken.StartArray)
         {
           int num = 0;
           while (reader.Read() && reader.TokenType != JsonToken.EndArray)
           {
             this.DeserializeValue(reader, document, manager, propertyName, currentNode);
             ++num;
           }
           if (num == 1 && this.WriteArrayAttribute)
           {
             this.AddJsonArrayAttribute(Enumerable.Single<IXmlElement>(CollectionUtils.CastValid<IXmlElement>((IEnumerable) currentNode.ChildNodes), (Func<IXmlElement, bool>) (n => n.LocalName == propertyName)), document);
             break;
           }
           else
             break;
         }
         else
         {
           this.DeserializeValue(reader, document, manager, propertyName, currentNode);
           break;
         }
       case JsonToken.Comment:
         currentNode.AppendChild(document.CreateComment((string) reader.Value));
         break;
       case JsonToken.EndObject:
         return;
       case JsonToken.EndArray:
         return;
       default:
         throw new JsonSerializationException("Unexpected JsonToken when deserializing node: " + (object) reader.TokenType);
     }
   }
   while (reader.TokenType == JsonToken.PropertyName || reader.Read());
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:50,代码来源:XmlNodeConverter.cs


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