WriteStartElement() public method

public WriteStartElement ( string memberName, string memberNamespace, string contentNamespace ) : void
memberName string
memberNamespace string
contentNamespace string
return void
Esempio n. 1
0
 public override void SerializeNonReference(object graph,
                                            XmlFormatterSerializer serializer)
 {
     foreach (object o in (IEnumerable)graph)
     {
         serializer.WriteStartElement(element_qname.Name, XmlName.Namespace, CurrentNamespace);
         serializer.Serialize(element_type, o);
         serializer.WriteEndElement();
     }
 }
Esempio n. 2
0
        public override void SerializeNonReference(object graph,
                                                   XmlFormatterSerializer serializer)
        {
            // output item xmlns in advance so that it does not result in excessive xmlns overwrites.
            if (XmlName.Namespace != element_qname.Namespace && element_qname.Namespace != KnownTypeCollection.MSSimpleNamespace)
            {
                serializer.Writer.WriteXmlnsAttribute(null, element_qname.Namespace);
            }

            foreach (object o in (IEnumerable)graph)
            {
                serializer.WriteStartElement(element_qname.Name, XmlName.Namespace, CurrentNamespace);
                serializer.Serialize(element_type, o);
                serializer.WriteEndElement();
            }
        }
Esempio n. 3
0
        public virtual void SerializeNonReference(object graph,
                                                  XmlFormatterSerializer serializer)
        {
            foreach (DataMemberInfo dmi in Members)
            {
                FieldInfo    fi = dmi.Member as FieldInfo;
                PropertyInfo pi = fi == null ?
                                  (PropertyInfo)dmi.Member : null;
                Type type = fi != null ?
                            fi.FieldType : pi.PropertyType;
                object value = fi != null?
                               fi.GetValue(graph) :
                                   pi.GetValue(graph, null);

                serializer.WriteStartElement(dmi.XmlName, dmi.XmlRootNamespace, dmi.XmlNamespace);
                serializer.Serialize(type, value);
                serializer.WriteEndElement();
            }
        }
Esempio n. 4
0
 public override void SerializeNonReference(object graph,
                                            XmlFormatterSerializer serializer)
 {
     if (add_method != null)               // generic
     {
         if (pair_type == null)
         {
             pair_type           = typeof(KeyValuePair <,>).MakeGenericType(add_method.DeclaringType.GetGenericArguments());
             pair_key_property   = pair_type.GetProperty("Key");
             pair_value_property = pair_type.GetProperty("Value");
         }
         foreach (object p in (IEnumerable)graph)
         {
             serializer.WriteStartElement(item_qname.Name, item_qname.Namespace, CurrentNamespace);
             serializer.WriteStartElement(key_qname.Name, key_qname.Namespace, CurrentNamespace);
             serializer.Serialize(pair_key_property.PropertyType, pair_key_property.GetValue(p, null));
             serializer.WriteEndElement();
             serializer.WriteStartElement(value_qname.Name, value_qname.Namespace, CurrentNamespace);
             serializer.Serialize(pair_value_property.PropertyType, pair_value_property.GetValue(p, null));
             serializer.WriteEndElement();
             serializer.WriteEndElement();
         }
     }
     else                 // non-generic
     {
         foreach (DictionaryEntry p in (IEnumerable)graph)
         {
             serializer.WriteStartElement(item_qname.Name, item_qname.Namespace, CurrentNamespace);
             serializer.WriteStartElement(key_qname.Name, key_qname.Namespace, CurrentNamespace);
             serializer.Serialize(key_type, p.Key);
             serializer.WriteEndElement();
             serializer.WriteStartElement(value_qname.Name, value_qname.Namespace, CurrentNamespace);
             serializer.Serialize(value_type, p.Value);
             serializer.WriteEndElement();
             serializer.WriteEndElement();
         }
     }
 }