コード例 #1
0
        public IXmlNode CreateAttribute(string name, string value)
        {
            XmlNodeWrapper attribute = new XmlNodeWrapper(_document.CreateAttribute(name));
              attribute.Value = value;

              return attribute;
        }
コード例 #2
0
        public IXmlNode CreateAttribute(string qualifiedName, string namespaceURI, string value)
        {
            XmlNodeWrapper attribute = new XmlNodeWrapper(_document.CreateAttribute(qualifiedName, namespaceURI));
              attribute.Value = value;

              return attribute;
        }
コード例 #3
0
        /// <summary>
        /// Writes the JSON representation of the object.
        /// </summary>
        /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
        /// <param name="serializer">The calling serializer.</param>
        /// <param name="value">The value.</param>
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            IXmlNode node;

              if (value is XmlNode)
            node = new XmlNodeWrapper((XmlNode)value);
            #if !NET20
              else if (value is XObject)
            node = XContainerWrapper.WrapNode((XObject)value);
            #endif
              else
            throw new ArgumentException("Value must be an XmlNode", "value");

              XmlNamespaceManager manager = new XmlNamespaceManager(new NameTable());
              PushParentNamespaces(node, manager);

              writer.WriteStartObject();
              SerializeNode(writer, node, manager, true);
              writer.WriteEndObject();
        }