コード例 #1
0
        private string GetReflectorPropertyXmlData(object obj, IXmlSerialiser memberSerialiser)
        {
            StringBuilder xml = new StringBuilder();

            using (var writer = XmlWriter.Create(xml, new XmlWriterSettings {
                OmitXmlDeclaration = true
            }))
            {
                memberSerialiser.Write(writer, obj);
            }
            return(xml.ToString());
        }
コード例 #2
0
        protected override void WriteValue(XmlWriter writer, object value)
        {
            foreach (object element in ((IEnumerable)value))
            {
                if (element == null)
                {
                    continue;
                }

                ReflectorTypeAttribute attribute = ReflectorTypeAttribute.GetAttribute(element);
                if (attribute == null)
                {
                    writer.WriteElementString(elementName, element.ToString());
                }
                else
                {
                    // make more concise?
                    IXmlSerialiser serialiser = attribute.CreateSerialiser(element.GetType());
                    serialiser.Write(writer, element);
                }
            }
        }