Ejemplo n.º 1
0
        public void WriteMembers(object instance, ISerialiserNode parentNode, Type type)
        {
            var typeName = typeNamesCache.GetTypeName(type);

            using (var dictNode = ownerDocument.CreateTypedElement("dict", typeName, parentNode))
            {
                WriteItems(dictNode, (IDictionary)instance);
            }
        }
Ejemplo n.º 2
0
        public void Write(object instance, INodeWriter parentNode, Type referencedAsType)
        {
            var valueID  = valuesCache.Add(instance);
            var typeName = typeNamesCache.GetTypeName(instance.GetType());

            using (var arrayNode = ownerDocument.CreateTypedElement("arrayOfDoubles",
                                                                    typeName, parentNode))
            {
                arrayNode.AddAttribute("ID", valueID.ToString());

                using (var itemsNode = ownerDocument.CreateElement("items", arrayNode))
                {
                    var values = (Array)instance;
                    itemsNode.AddAttribute("count", values.Length);

                    var innerText         = new StringBuilder();
                    var itemsPerLineCount = 0;
                    foreach (var listItem in values)
                    {
                        innerText.AppendFormat("{0},", listItem);
                        if (++itemsPerLineCount == 10)
                        {
                            itemsPerLineCount = 0;
                            innerText.AppendFormat("\r\n");
                        }
                    }

                    itemsNode.InnerText = innerText.ToString();
                }
            }
        }
Ejemplo n.º 3
0
        public void Write(object instance, INodeWriter parentNode, Type referencedAsType)
        {
            var typeName = typeNamesCache.GetTypeName(instance.GetType());

            using (var valueNode = ownerDocument.CreateTypedElement("enum",
                                                                    typeName,
                                                                    parentNode))
            {
                valueNode.InnerText = Enum.GetName(instance.GetType(), instance);
            }
        }