public List <Type> Deserialize(XElement xColumnSet)
        {
            var xColumns = xColumnSet.Elements("column");

            var xTypes = xColumns.Select(p => p.Element("data-type"));

            var types = xTypes.Select(p => _dataTypeSerializer.Deserialize(p));

            var nullableTypes = types.Select(p => GetNullableType(p));

            return(nullableTypes.ToList());
        }
Ejemplo n.º 2
0
        public object Deserialize(XElement xProperty, Type type)
        {
            if (type == typeof(Boolean))
            {
                return((Boolean)xProperty);
            }

            if (type == typeof(DateTime))
            {
                return((DateTime)xProperty);
            }

            if (type == typeof(Int32))
            {
                return((Int32)xProperty);
            }

            if (type == typeof(Double))
            {
                return((Double)xProperty);
            }

            if (type == typeof(String))
            {
                return((String)xProperty);
            }

            if (type == typeof(Boolean?))
            {
                return(string.IsNullOrEmpty(xProperty.Value)
                    ? null
                    : (Boolean?)xProperty);
            }

            if (type == typeof(DateTime?))
            {
                return(string.IsNullOrEmpty(xProperty.Value)
                    ? null
                    : (DateTime?)xProperty);
            }

            if (type == typeof(Double?))
            {
                return(string.IsNullOrEmpty(xProperty.Value)
                    ? null
                    : (Double?)xProperty);
            }

            if (type == typeof(Int32?))
            {
                return(string.IsNullOrEmpty(xProperty.Value)
                    ? null
                    : (Int32?)xProperty);
            }

            if (type == typeof(Rect))
            {
                return(DeserializeRect(xProperty));
            }

            if (type == typeof(BitmapImage))
            {
                return(DeserializeImage(xProperty));
            }

            if (type.BaseType == typeof(Enum))
            {
                return(Enum.Parse(type, xProperty.Value));
            }


            if (type == typeof(Type))
            {
                return(_dataTypeSerializer.Deserialize(xProperty));
            }

            throw new ArgumentException(PropertyCannotBeDeserialized);
        }