Exemplo n.º 1
0
        public static object ToObject(this IDictionary <string, object> values, Type objectType)
        {
            Guard.NotEmpty(values, nameof(values));
            Guard.NotNull(objectType, nameof(objectType));

            if (!DictionaryConverter.CanCreateType(objectType))
            {
                throw Error.Argument(
                          "objectType",
                          "The type '{0}' must be a class and have a parameterless default constructor in order to deserialize properly.",
                          objectType.FullName);
            }

            return(DictionaryConverter.SafeCreateAndPopulate(objectType, values));
        }
Exemplo n.º 2
0
 public override bool CanConvertTo(Type type)
 {
     return(DictionaryConverter.CanCreateType(type));
 }
Exemplo n.º 3
0
 public override bool CanConvertTo(Type type)
 {
     return(!type.IsPredefinedType() && DictionaryConverter.CanCreateType(type));
 }