Serializer cache of delegates required to create a type from a string map (e.g. for REST urls)
        public object Parse(IDictionary <string, string> keyValuePairs, Type returnType)
        {
            StringMapTypeDeserializer stringMapTypeDeserializer;

            lock (typeStringMapSerializerMap)
            {
                if (!typeStringMapSerializerMap.TryGetValue(returnType, out stringMapTypeDeserializer))
                {
                    stringMapTypeDeserializer = new StringMapTypeDeserializer(returnType);
                    typeStringMapSerializerMap.Add(returnType, stringMapTypeDeserializer);
                }
            }

            return(stringMapTypeDeserializer.CreateFromMap(keyValuePairs));
        }
Exemplo n.º 2
0
        private StringMapTypeDeserializer GetOrAddStringMapTypeDeserializer(Type returnType)
        {
            StringMapTypeDeserializer stringMapTypeDeserializer;

            lock (typeStringMapSerializerMap)
            {
                if (!typeStringMapSerializerMap.TryGetValue(returnType, out stringMapTypeDeserializer))
                {
                    stringMapTypeDeserializer = new StringMapTypeDeserializer(returnType);
                    typeStringMapSerializerMap.Add(returnType, stringMapTypeDeserializer);
                }
            }

            return(stringMapTypeDeserializer);
        }