public void WriteDynamicDictionary(DynamicDictionaryAttribute attribute, object writer,
                                           object value, WriteSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            XmlWriter   xmlWriter   = writer.Convert <XmlWriter>();
            PrefixTable prefixTable = serializerData.Convert <PrefixTable>();

            WriteStartElement(xmlWriter, info.QName, prefixTable);
            IDictionary dict = value as IDictionary;

            if (dict != null)
            {
                var configData = attribute.PlugInFactory.ConfigData;
                foreach (DictionaryEntry item in dict)
                {
                    var   itemAttr = configData[item.Value.GetType()];
                    QName itemName = itemAttr.GetQName(itemAttr.LocalName);
                    Write(writer, item.Value, info.ModelName, settings, itemName, prefixTable, null);
                    //WriteStartElement(xmlWriter, itemName, prefixTable);
                    //InternalWriteXml(writer, item.Value, info.ModelName, settings, prefixTable);
                    //xmlWriter.WriteEndElement();
                }
            }

            xmlWriter.WriteEndElement();
        }
        public object BeginWrite(object writer, object receiver, WriteSettings settings, QName root)
        {
            XmlWriter   xmlWriter   = writer.Convert <XmlWriter>();
            PrefixTable prefixTable = new PrefixTable();

            xmlWriter.WriteStartDocument();
            return(prefixTable);
        }
        public void WriteTagElement(TagElementAttribute attribute, object writer,
                                    object value, WriteSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            XmlWriter   xmlWriter   = writer.Convert <XmlWriter>();
            PrefixTable prefixTable = serializerData.Convert <PrefixTable>();

            WriteStartElement(xmlWriter, info.QName, prefixTable);
            SerializerUtil.WriteChildElement(this, writer, attribute.ChildElements, settings,
                                             value, (objValue, propInfo) => value, prefixTable);
            xmlWriter.WriteEndElement();
        }
 private static void WriteStartElement(XmlWriter writer, QName name, PrefixTable prefixTable)
 {
     if (name.HasNamespace)
     {
         writer.WriteStartElement(prefixTable.GetPrefix(name.Namespace),
                                  name.LocalName, name.Namespace);
     }
     else
     {
         writer.WriteStartElement(name.LocalName);
     }
 }
        public void WriteComplexElement(SimpleComplexElementAttribute attribute, object writer,
                                        object value, WriteSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            XmlWriter   xmlWriter   = writer.Convert <XmlWriter>();
            PrefixTable prefixTable = serializerData.Convert <PrefixTable>();

            WriteStartElement(xmlWriter, info.QName, prefixTable);
            string data = ObjectUtil.ToString(info.Converter, value, settings);

            WriteComplexContent(xmlWriter, data);
            xmlWriter.WriteEndElement();
        }
        public void WriteObjectElement(ObjectElementAttribute attribute, object writer,
                                       object value, WriteSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            PrefixTable prefixTable = serializerData.Convert <PrefixTable>();

            Write(writer, value, info.ModelName, settings, info.QName, prefixTable, null);
            //XmlWriter xmlWriter = writer.Convert<XmlWriter>();

            //WriteStartElement(xmlWriter, info.QName, prefixTable);
            //InternalWriteXml(writer, value, info.ModelName, settings, prefixTable);
            //xmlWriter.WriteEndElement();
        }
        public void WriteDictionary(DictionaryAttribute attribute, object writer,
                                    object value, WriteSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            XmlWriter   xmlWriter   = writer.Convert <XmlWriter>();
            PrefixTable prefixTable = serializerData.Convert <PrefixTable>();

            WriteStartElement(xmlWriter, info.QName, prefixTable);
            IDictionary dict = value as IDictionary;

            if (dict != null)
            {
                foreach (DictionaryEntry item in dict)
                {
                    xmlWriter.WriteStartElement(item.Key.ToString());
                    xmlWriter.WriteString(ObjectUtil.ToString(info.Converter, item.Value, settings));
                    xmlWriter.WriteEndElement();
                }
            }

            xmlWriter.WriteEndElement();
        }
        public void WriteObjectDictionary(ObjectDictionaryAttribute attribute, object writer,
                                          object value, WriteSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            XmlWriter   xmlWriter   = writer.Convert <XmlWriter>();
            PrefixTable prefixTable = serializerData.Convert <PrefixTable>();

            WriteStartElement(xmlWriter, info.QName, prefixTable);
            IDictionary dict = value as IDictionary;

            if (dict != null)
            {
                foreach (DictionaryEntry item in dict)
                {
                    Write(writer, item.Value, info.ModelName, settings,
                          QName.Get(item.Key.ToString()), prefixTable, null);
                    //xmlWriter.WriteStartElement(item.Key.ToString());
                    //InternalWriteXml(writer, item.Value, info.ModelName, settings, prefixTable);
                    //xmlWriter.WriteEndElement();
                }
            }

            xmlWriter.WriteEndElement();
        }
        public void WriteAttribute(SimpleAttributeAttribute attribute, object writer,
                                   object value, WriteSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            if (ObjectUtil.IsDefaultValue(attribute.DefaultValue, value))
            {
                return;
            }

            XmlWriter xmlWriter = writer.Convert <XmlWriter>();
            QName     name      = info.QName;

            if (name.HasNamespace)
            {
                PrefixTable prefix = serializerData.Convert <PrefixTable>();
                xmlWriter.WriteAttributeString(prefix.GetPrefix(name.Namespace), name.LocalName,
                                               name.Namespace, ObjectUtil.ToString(info.Converter, value, settings));
            }
            else
            {
                xmlWriter.WriteAttributeString(name.LocalName,
                                               ObjectUtil.ToString(info.Converter, value, settings));
            }
        }
        public void WriteElement(SimpleElementAttribute attribute, object writer,
                                 object value, WriteSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            if (!attribute.IsMultiple && ObjectUtil.IsDefaultValue(attribute.DefaultValue, value))
            {
                return;
            }

            XmlWriter   xmlWriter   = writer.Convert <XmlWriter>();
            PrefixTable prefixTable = serializerData.Convert <PrefixTable>();

            WriteStartElement(xmlWriter, info.QName, prefixTable);
            string data = ObjectUtil.ToString(info.Converter, value, settings);

            if (attribute.UseCData)
            {
                xmlWriter.WriteCData(data);
            }
            else
            {
                xmlWriter.WriteString(data);
            }
            xmlWriter.WriteEndElement();
        }