public XmlArray DoToXmlArray_FromDictionary(Type type, Type keyType, Type valueType, IDictionary dictionary, string mainNodeName, XmlMappingContainer mappings = null)
        {
            var result = new XmlArray(mainNodeName);

            var valueTypeName = valueType.Name;

            foreach (var keyValue in dictionary)
            {
                var entry = (DictionaryEntry)keyValue;

                // Int32 for example
                var keyValueXmlObject = new XmlObject(valueTypeName);

                // key
                var keyString = this.ResolveDictionaryKey(keyType, entry.Key);
                keyValueXmlObject.Add("Key", new XmlString("Key", keyString));

                // value
                var resultValue = this.ToXmlValue(valueType, entry.Value, "Value", mappings);
                keyValueXmlObject.Add("Value", resultValue);

                result.Add(keyValueXmlObject);
            }

            return(result);
        }
        public XmlArray ConvertToArray(XmlObject xmlObject)
        {
            var result = new XmlArray(xmlObject.NodeName);

            foreach (var xmlValue in xmlObject.Values)
            {
                result.Add(xmlValue.Value);
            }
            return(result);
        }
        public XmlArray ToXmlArray(XElement element)
        {
            var nodeName = element.Name.LocalName;
            var result   = new XmlArray(nodeName);

            foreach (var child in element.Elements())
            {
                var xmlValue = this.FindNextElement(child);
                result.Add(xmlValue);
            }

            return(result);
        }
        protected XmlArray DoToXmlArray(Type type, Type singleItemType, string nodeName, IEnumerable enumerable, XmlMappingContainer mappings = null)
        {
            // string[],List<string>, int[]...MyEnum[],Guid[], DateTime[]
            // int?[],... DateTime?[], Guid?[], MyEnum?[]
            // MyItem[]

            var result = new XmlArray(nodeName);

            if (enumerable != null)
            {
                foreach (var value in enumerable)
                {
                    var resultValue = this.ToXmlValue(singleItemType, value, mappings);
                    result.Add(resultValue);
                }
            }
            else
            {
                result.SetNil();
            }
            return(result);
        }