Esempio n. 1
0
 public void SerializeObject(SerializationXmlTextWriter writer, object value, XmlSerializerNamespaces namespaces, bool alwaysEmitTypes)
 {
     if (value != null)
     {
         writer.WriteValue(value);
     }
 }
 public void SerializeObject(SerializationXmlTextWriter writer, object value, XmlSerializerNamespaces namespaces, bool alwaysEmitTypes)
 {
     if (value != null)
     {
         if (_type == typeof(bool))
         {
             writer.WriteAttributeString(_attributeName, value.ToString().ToLower());
         }
         else
         {
             writer.WriteAttributeString(_attributeName, value.ToString());
         }
     }
 }
Esempio n. 3
0
        public void SerializeObject(SerializationXmlTextWriter writer, object instance, XmlSerializerNamespaces namespaces, bool alwaysEmitTypes)
        {
            if (_rootElementName != null)
            {
                writer.WriteStartDocument();
                writer.WriteStartElement(_rootElementName);
                writer.WriteDefaultNamespaces();

                if (!string.IsNullOrWhiteSpace(_defaultNamespace))
                {
                    writer.WriteAttributeString("xmlns", null, null, _defaultNamespace);
                }
            }

            foreach (var item in (IEnumerable)instance)
            {
                _itemSerializer.SerializeObject(writer, item, namespaces, alwaysEmitTypes);
            }

            if (_rootElementName != null)
            {
                writer.WriteEndElement();
            }
        }