예제 #1
0
        protected virtual TExtensibleTypeProperties DeserializeTypeProperties(
            string typeName,
            string json,
            out Type type)
        {
            TExtensibleTypeProperties typeProperties;

            if (this.TryGetRegisteredType(typeName, out type))
            {
                if (string.IsNullOrEmpty(json))
                {
                    // No typeProperties exist to deserialize, just initialize a default instance
                    typeProperties = (TExtensibleTypeProperties)Activator.CreateInstance(type);
                }
                else
                {
                    typeProperties = (TExtensibleTypeProperties)TypeProperties.DeserializeObject(json, type);
                }
            }
            else
            {
                Dictionary <string, JToken> serviceExtraProperties =
                    JsonConvert.DeserializeObject <Dictionary <string, JToken> >(
                        json,
                        ConversionCommon.DefaultSerializerSettings);

                typeProperties = new TGenericTypeProperties()
                {
                    ServiceExtraProperties = serviceExtraProperties
                };
                type = typeof(TGenericTypeProperties);
            }

            return(typeProperties);
        }