public TypeMappingWrapper(CollectionTypeMapping data)
 {
     this.mData = data;
 }
        public ConnectionProperties Deserialize(XElement root)
        {
            ConnectionProperties obj = new ConnectionProperties();

            var xElement = root.Element("ConnectionString");

            if (xElement != null)
            {
                obj.ConnectionString = xElement.Value;
            }

            //assembly locations
            xElement = root.Element("AssemblyLocations");
            if (xElement != null)
            {
                obj.AssemblyLocations = new HashSet <string>();
                foreach (var el in xElement.Descendants("Location"))
                {
                    obj.AssemblyLocations.Add(el.Value);
                }
            }

            //collection type mappings
            xElement = root.Element("CollectionTypeMappings");
            if (xElement != null)
            {
                obj.CollectionTypeMappings = new Dictionary <string, HashSet <CollectionTypeMapping> >();
                foreach (var db in xElement.Descendants("Database").Where(x => x.Attribute("name") != null))
                {
                    var set = new HashSet <CollectionTypeMapping>();
                    foreach (var coll in db.Descendants("CollectionTypeMapping"))
                    {
                        CollectionTypeMapping newMap = ctmSerializer.Deserialize(coll);
                        set.Add(newMap);
                    }
                    obj.CollectionTypeMappings.Add(db.Attribute("name").Value, set);
                }
            }

            //selected DB
            xElement = root.Element("SelectedDb");
            if (xElement != null)
            {
                obj.SelectedDatabase = xElement.Value;
            }

            //custom serializers
            xElement = root.Element("CustomSerializers");
            if (xElement != null)
            {
                obj.CustomSerializers = new Dictionary <string, string>();
                foreach (var serializer in xElement.Descendants("Serializer"))
                {
                    var key   = serializer.Attribute("type").Value;
                    var value = serializer.Attribute("serializer").Value;

                    obj.CustomSerializers[key] = value;
                }
            }

            //additional options
            xElement = root.Element("AdditionalOptions");
            if (xElement != null)
            {
                obj.AdditionalOptions = this.additionalOptionsSerializer.Deserialize(xElement);
            }

            //Initialization query
            xElement = root.Element("InitializationQuery");
            if (xElement != null)
            {
                obj.InitializationQuery = this.linqPadQuerySerializer.Deserialize(xElement);
            }

            return(obj);
        }