/// <summary> /// Deserializes the object out of a JSON dynamic object for a certain type. /// </summary> /// <param name="httpClient">the HTTP client</param> /// <param name="type">the type</param> /// <param name="model">the JSON dynamic object of a model</param> /// <returns>the deserialized object</returns> public static Model Deserialize(IClarifaiHttpClient httpClient, Type type, dynamic model) { var typeToDeserialization = new Dictionary <Type, Func <Model> > { { typeof(Color), () => ColorModel.Deserialize(httpClient, model) }, { typeof(Concept), () => ConceptModel.Deserialize(httpClient, model) }, { typeof(Detection), () => DetectionModel.Deserialize(httpClient, model) }, { typeof(Embedding), () => EmbeddingModel.Deserialize(httpClient, model) }, { typeof(FaceEmbedding), () => FaceEmbeddingModel.Deserialize(httpClient, model) }, { typeof(Frame), () => VideoModel.Deserialize(httpClient, model) }, }; if (!typeToDeserialization.ContainsKey(type)) { throw new ClarifaiException(string.Format("Unknown model type: {}", type)); } return(typeToDeserialization[type]()); }