Exemplo n.º 1
0
        public DeserializationOptions(IDictionary <Type, Dictionary <string, Action <object, EventReader> > > overrides, IDictionary <string, Type> mappings)
        {
            var overrideList = from over in overrides
                               from prop in over.Value
                               select new DeserializationOverride(over.Key, prop.Key, prop.Value);

            this.overrides = new DeserializationOverrides(overrideList);
            this.mappings  = new TagMappings(mappings);
        }
        public DeserializationOptions(IDictionary<Type, Dictionary<string, Action<object, EventReader>>> overrides, IDictionary<string, Type> mappings)
        {
            var overrideList = from over in overrides
                               from prop in over.Value
                               select new DeserializationOverride(over.Key, prop.Key, prop.Value);

            this.overrides = new DeserializationOverrides(overrideList);
            this.mappings = new TagMappings(mappings);
        }
Exemplo n.º 3
0
        private static Type GetType(string tag, Type defaultType, TagMappings mappings)
        {
            Type actualType = GetTypeFromTag(tag, defaultType, mappings);

            if (actualType.IsInterface)
            {
                Type implementationType;
                if (defaultInterfaceImplementations.TryGetValue(actualType.GetGenericTypeDefinition(), out implementationType))
                {
                    return(implementationType.MakeGenericType(actualType.GetGenericArguments()));
                }
            }

            return(actualType);
        }
Exemplo n.º 4
0
        private static Type GetTypeFromTag(string tag, Type defaultType, TagMappings mappings)
        {
            if (tag == null)
            {
                return(defaultType);
            }

            Type predefinedType = mappings.GetMapping(tag);

            if (predefinedType != null || predefinedTypes.TryGetValue(tag, out predefinedType))
            {
                return(predefinedType);
            }

            return(Type.GetType(tag.Substring(1), true));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeserializationOptions"/> class.
 /// </summary>
 /// <param name="overrides">The overrides.</param>
 /// <param name="mappings">The mappings.</param>
 public DeserializationOptions(IEnumerable <DeserializationOverride> overrides, IDictionary <string, Type> mappings)
 {
     this.overrides = new DeserializationOverrides(overrides);
     this.mappings  = new TagMappings(mappings);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeserializationOptions"/> class.
 /// </summary>
 public DeserializationOptions()
 {
     overrides = new DeserializationOverrides();
     mappings  = new TagMappings();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DeserializationOptions"/> class.
 /// </summary>
 /// <param name="overrides">The overrides.</param>
 /// <param name="mappings">The mappings.</param>
 public DeserializationOptions(IEnumerable<DeserializationOverride> overrides, IDictionary<string, Type> mappings)
 {
     this.overrides = new DeserializationOverrides(overrides);
     this.mappings = new TagMappings(mappings);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DeserializationOptions"/> class.
 /// </summary>
 public DeserializationOptions()
 {
     overrides = new DeserializationOverrides();
     mappings = new TagMappings();
 }