public override object Deserialize( IDictionary<string, object> dictionary,Type type,JavaScriptSerializer serializer )
        {
            if( type == typeof( ConditionDevice ) )
            {
                var obj = new ConditionDevice();
                if( dictionary.ContainsKey( "name" ) )
                    obj.Name = serializer.ConvertToType<string>(dictionary["name"] );
                if( dictionary.ContainsKey( "value" ) )
                    obj.Value = serializer.ConvertToType<string>(dictionary["value"] );

                return obj;
            }

            return null;
        }
Beispiel #2
0
        public override object Deserialize( IDictionary<string, object> dictionary,Type type,JavaScriptSerializer serializer )
        {
            if( type == typeof( Skin ) )
            {
                var obj = new Skin();
                if( dictionary.ContainsKey( "name" ) )
                    obj.Name = serializer.ConvertToType<string>(dictionary["name"] );
                if( dictionary.ContainsKey( "resolution" ) )
                    obj.ResolutionJson = serializer.ConvertToType<string>(dictionary["resolution"] );//Resolution
                if( dictionary.ContainsKey( "theme" ) )
                    obj.Theme = serializer.ConvertToType<string>(dictionary["theme"] );
                return obj;
            }

            return null;
        }
 public override IDictionary<string, object> Serialize(
     object obj,
     JavaScriptSerializer serializer)
 {
     var dataObj = serializer.ConvertToType<oEmbed>(obj);
     if (dataObj != null)
     {
         return new Dictionary<string, object>
                    {
                        {"type", dataObj.Type.ToString().ToLower()},
                        {"version", dataObj.Version},
                        {"title", dataObj.Title},
                        {"author_name", dataObj.AuthorName},
                        {"author_url", dataObj.AuthorUrl},
                        {"provider_name", dataObj.ProviderName},
                        {"provider_url", dataObj.ProviderUrl},
                        {"cache_age", dataObj.CacheAge},
                        {"thumbnail_url", dataObj.ThumbnailUrl},
                        {"thumbnail_width", dataObj.ThumbnailWidth},
                        {"thumbnail_height", dataObj.ThumbnailHeight},
                        {"url", dataObj.Url},
                        {"width", dataObj.Width},
                        {"height", dataObj.Height},
                        {"html", dataObj.Html}
                    };
     }
     return new Dictionary<string, object>();
 }
        public override object Deserialize( IDictionary<string, object> dictionary,Type type,JavaScriptSerializer serializer )
        {
            if( type == typeof( BarierPoint ) )
            {
                var obj = new BarierPoint();
                if( dictionary.ContainsKey( "x" ) )
                    obj.X = serializer.ConvertToType<int>(
                                               dictionary["x"] );
                if( dictionary.ContainsKey( "y" ) )
                    obj.Y = serializer.ConvertToType<int>(
                                               dictionary["y"] );

                return obj;
            }

            return null;
        }
Beispiel #5
0
 private static void ThrowIfNestedError(object objError, JavaScriptSerializer serializer)
 {
     if (objError != null)
     {
         BrightcoveError error = serializer.ConvertToType<BrightcoveError>(objError);
         throw new BrightcoveApiException(error);
     }
 }
Beispiel #6
0
        public override object Execute(Expression expression)
        {
            Type elementType = expression.GetElementType();
            IList<IQuickBloxCustomObject> customObjectsList = new List<IQuickBloxCustomObject>();
            var response = QuickBloxApiClient.GetCustomObject(sessionToken, this.Translate(expression));
            QuickBloxJsonResultWrapper deserializedObject;
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                var serializer = new JavaScriptSerializer();
                var json = reader.ReadToEnd();
                deserializedObject = (QuickBloxJsonResultWrapper)serializer.Deserialize(json, quickBloxJsonResultWrapper);
                response.Close();

                foreach (var item in deserializedObject.Items)
                {
                    IQuickBloxCustomObject inner = null;
                    try
                    {
                        inner = serializer.ConvertToType(item, elementType) as IQuickBloxCustomObject;
                        customObjectsList.Add(inner);
                    }
                    catch (InvalidOperationException ex)
                    {
                        var brokenJson = serializer.Serialize(item);
                        var errorMessage = String.Format("[QuickBlox] - Unable to deserialize to object. Type: {0} Json: {1}", elementType.FullName, brokenJson);
                        log.Warn(errorMessage, ex);
                        try
                        {

                            var brokenEvent = serializer.ConvertToType(item, typeof(BrokenEvent)) as IQuickBloxCustomObject;
                            (brokenEvent as BrokenEvent).Json = brokenJson;
                            (brokenEvent as BrokenEvent).EventType = elementType;
                            customObjectsList.Add(brokenEvent);
                        }
                        catch (Exception)
                        {
                            customObjectsList.Add(new BrokenEvent() { EventType = elementType, Json = brokenJson, Created_at = default(double) });
                        }
                        continue;
                    }
                };
                return customObjectsList;
            }
        }
Beispiel #7
0
            public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
            {
                UNote result = USTx.Project.CreateNote();
                result.Lyric = dictionary["y"] as string;
                result.NoteNum = Convert.ToInt32(dictionary["n"]);
                result.PosTick = Convert.ToInt32(dictionary["pos"]);
                result.DurTick = Convert.ToInt32(dictionary["dur"]);
                result.PitchBend.SnapFirst = Convert.ToBoolean(dictionary["pitsnap"]);

                var pho = dictionary["pho"] as ArrayList;
                result.Phonemes.Clear();
                foreach (var p in pho)
                {
                    var _p = serializer.ConvertToType<UPhoneme>(p);
                    _p.Parent = result;
                    result.Phonemes.Add(_p);
                }

                result.PitchBend.SnapFirst = Convert.ToBoolean(dictionary["pitsnap"]);
                var pit = dictionary["pit"] as ArrayList;
                var pitshape = dictionary["pitshape"] as ArrayList;
                double x = 0, y = 0;
                result.PitchBend.Points.Clear();
                for (int i = 0; i < pit.Count; i ++ )
                {
                    if (i % 2 == 0)
                        x = Convert.ToDouble(pit[i]);
                    else
                    {
                        y = Convert.ToDouble(pit[i]);
                        result.PitchBend.AddPoint(new PitchPoint(x, y,
                            (PitchPointShape)Enum.Parse(typeof(PitchPointShape), (string)pitshape[i / 2])));
                    }
                }

                if (dictionary.ContainsKey("vbr"))
                {
                    var vbr = dictionary["vbr"] as ArrayList;
                    result.Vibrato.Length = Convert.ToDouble(vbr[0]);
                    result.Vibrato.Period = Convert.ToDouble(vbr[1]);
                    result.Vibrato.Depth = Convert.ToDouble(vbr[2]);
                    result.Vibrato.In = Convert.ToDouble(vbr[3]);
                    result.Vibrato.Out = Convert.ToDouble(vbr[4]);
                    result.Vibrato.Shift = Convert.ToDouble(vbr[5]);
                    result.Vibrato.Drift = Convert.ToDouble(vbr[6]);
                }

                var exp = dictionary["exp"] as Dictionary<string, object>;
                foreach (var pair in exp)
                    result.Expressions[pair.Key].Data = pair.Value;

                return result;
            }
        public override object Deserialize( IDictionary<string, object> dictionary,Type type,JavaScriptSerializer serializer )
        {
            if( type == typeof( Device ) )
            {
                var obj = new Device();
                if( dictionary.ContainsKey( "publishDir" ) )
                    obj.Publish = serializer.ConvertToType<string>(dictionary["publishDir"] );
                if( dictionary.ContainsKey( "root" ) )
                    obj.Root = serializer.ConvertToType<string>(dictionary["root"] );
                if( dictionary.ContainsKey( "application" ) )
                    obj.Application = serializer.ConvertToType<string>(dictionary["application"] );
                if( dictionary.ContainsKey( "outputDir" ) )
                    obj.Output_Dir = serializer.ConvertToType<string>(dictionary["outputDir"] );
                if( dictionary.ContainsKey( "tempDir" ) )
                    obj.Temp = serializer.ConvertToType<string>(dictionary["tempDir"] );

                if( dictionary.ContainsKey( "facebookAppID" ) )
                    obj.FacebookAppID = serializer.ConvertToType<string>(dictionary["facebookAppID"] );

                if( dictionary.ContainsKey( "outputName" ) )
                    obj.Output_Name = serializer.ConvertToType<string>(dictionary["outputName"] );

                if( dictionary.ContainsKey( "log" ) )
                    obj.LogDebug = serializer.ConvertToType<bool>(dictionary["log"] );

                if( dictionary.ContainsKey( "applicationType" ) )
                    obj.ApplicationType = serializer.ConvertToType<string>(dictionary["applicationType"] );

             	    if( dictionary.ContainsKey( "includes" ) )
                    obj.Includes = serializer.ConvertToType<Includes>(dictionary["includes"] );
             	    //if( dictionary.ContainsKey( "publish" ) )
                  //  obj.PublishPropertisFull = serializer.ConvertToType<Moscrif.IDE.Devices.PublishProperty>(dictionary["publish"] );
             	    //if( dictionary.ContainsKey( "conditions" ) )
                  //  obj.PublishPropertisFull = serializer.ConvertToType<Moscrif.IDE.Devices.PublishProperty>(dictionary["conditions"] );
            return obj;
            }

            return null;
        }
Beispiel #9
0
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if(type != typeof(PostBackHash) && type != typeof(List<PostBackHash>)) {
                return null;
            }

            PostBackHash hash = new PostBackHash();

            if(dictionary.ContainsKey("id")) {
                hash.ControlID = serializer.ConvertToType<String>(dictionary["id"]);
            }

            if(dictionary.ContainsKey("widgetName")) {
                hash.WidgetName = serializer.ConvertToType<String>(dictionary["widgetName"]);
            }

            if(dictionary.ContainsKey("options")) {
                hash.Options = serializer.ConvertToType<Dictionary<String, object>>(dictionary["options"]);
            }

            return hash;
        }
        /// <summary>
        /// Deserializes all packages and their dependencies
        /// </summary>
        /// <param name="path">String path of the all packages .json file</param>
        /// <param name="jsSerializer">Javascript deserializer instanace used for the deserialization</param>
        /// <returns>Dictionary of all packages and their dependencies</returns>
        public static Dictionary<string, string[]> DeserializeJsonAllPackagesFile(string path, JavaScriptSerializer jsSerializer)
        {
            Dictionary<string, string[]> allPackagesSerialized;

            using (var reader = new StreamReader(path))
            {
                var allPackagesFile = reader.ReadToEnd();
                var obj = jsSerializer.DeserializeObject(allPackagesFile);
                allPackagesSerialized = jsSerializer.ConvertToType<Dictionary<string, string[]>>(obj);
            }

            if(allPackagesSerialized == null)
            {
                allPackagesSerialized = new Dictionary<string, string[]>();
            }

            return allPackagesSerialized;
        }
Beispiel #11
0
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if (dictionary == null)
                throw new ArgumentNullException("dictionary");

            if (type == typeof(DataTable))
            {
                // Create the instance to deserialize into.
                DataTable list = new DataTable();

                // Deserialize the ListItemCollection's items.
                ArrayList itemsList = (ArrayList)dictionary["Rows"];
                for (int i = 0; i < itemsList.Count; i++)
                    list.Rows.Add(serializer.ConvertToType<DataRow>(itemsList[i]));

                return list;
            }
            return null;
        }
        public void Deserialize(IDictionary<string, object> dictionary, JavaScriptSerializer serializer)
        {
            foreach (string key in dictionary.Keys)
            {
                switch (key)
                {
                    case "error":
                        Message = dictionary[key].ToString();
                        break;

                    case "code":
                        Code = (int)dictionary[key];
                        break;

                    case "errors":
                        Errors.Clear();
                        Errors.AddRange(serializer.ConvertToType<BrightcoveNestedError[]>(dictionary[key]));
                        break;
                }
            }
        }
        public void Deserialize(
            IDictionary<string, object> dictionary,
            JavaScriptSerializer serializer)
        {
            foreach (string key in dictionary.Keys)
            {
                switch (key)
                {
                    case "error":
                        ApiUtil.ThrowIfError(dictionary, key, serializer);
                        break;

                    case "id":
                        Id = Convert.ToInt64(dictionary[key]);
                        break;

                    case "captionSources": 
                        CaptionSources = serializer.ConvertToType<List<BrightcoveCaptionSource>>(dictionary[key]);
                        break;
                }
            }
        }
        protected override List<FeedItem> ParseDocument(Dictionary<string, object> doc)
        {
            var feedItems = new List<FeedItem>(_totalLimit);
            if (doc != null)
            {
                var serializer = new JavaScriptSerializer();
                var model = serializer.ConvertToType<Model>(doc);
                for (var i = 0; i < Math.Min(_totalLimit, model.root.data.Count); i++)
                {
                    var modelItem = model.root.data[i];
                    feedItems.Add(new FeedItem(this)
                    {
                        Published = GetPublished(modelItem.created_time),
                        Title = "Via Instagram",
                        Snippet = modelItem.caption.text,
                        ImagePreviewUri = modelItem.images.standard_resolution.url,
                        ViewUri = modelItem.link
                    });
                }
            }

            return feedItems;
        }
Beispiel #15
0
            public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
            {
                UPart result = null;
                if (dictionary.ContainsKey("notes"))
                {
                    result = new UVoicePart();
                    var _result = result as UVoicePart;

                    var notes = dictionary["notes"] as ArrayList;
                    foreach (var note in notes)
                    {
                        _result.Notes.Add(serializer.ConvertToType<UNote>(note));
                    }
                }
                else if (dictionary.ContainsKey("path"))
                    result = Wave.CreatePart(dictionary["path"] as string);

                if (result != null)
                {
                    result.Name = dictionary["name"] as string;
                    result.Comment = dictionary["comment"] as string;
                    result.TrackNo = Convert.ToInt32(dictionary["trackno"]);
                    result.PosTick = Convert.ToInt32(dictionary["pos"]);
                    result.DurTick = Convert.ToInt32(dictionary["dur"]);
                }

                return result;
            }
        /// <summary>
        /// Deserializes the specified dictionary.
        /// </summary>
        /// <param name="dictionary">The <see cref="IDictionary{String,Object}" />.</param>
        /// <param name="serializer">The <see cref="JavaScriptSerializer" />.</param>
        public void Deserialize(IDictionary<string, object> dictionary, JavaScriptSerializer serializer)
        {
            foreach (string key in dictionary.Keys)
            {
                switch (key)
                {
                    case "error":
                        ApiUtil.ThrowIfError(dictionary, key, serializer);
                        break;

                    case "accountId":
                        AccountId = Convert.ToInt64(dictionary[key]);
                        break;

                    case "audioTracks":
                        AudioTracks = serializer.ConvertToType<List<BrightcoveAudioTrack>>(dictionary[key]);
                        break;

                    case "audioTrackIds":
                        AudioTrackIds = serializer.ConvertToType<List<long>>(dictionary[key]);
                        break;

                    case "filterTags":
                        FilterTags = serializer.ConvertToType<List<string>>(dictionary[key]);
                        break;

                    case "id":
                        Id = Convert.ToInt64(dictionary[key]);
                        break;

                    case "name":
                        Name = (string)dictionary[key];
                        break;

                    case "playlistType":
                        PlaylistType = ((string)dictionary[key]).ToBrightcoveEnum<PlaylistType>();
                        break;

                    case "referenceId":
                        ReferenceId = (string)dictionary[key];
                        break;

                    case "shortDescription":
                        ShortDescription = (string)dictionary[key];
                        break;

                    case "thumbnailURL":
                        ThumbnailUrl = (string)dictionary[key];
                        break;
                }
            }
        }
Beispiel #17
0
        private List<Object> makeApiV5Call(String pathToCall, String requestMethod, Type resultType, String postData)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(this.outProtocol);
            sb.Append("://");
            sb.Append(this.hostname);
            if (this.needsPort())
            {
                sb.Append(":" + this.outPort);
            }
            sb.Append("/" + this.contextPath);
            sb.Append(pathToCall);

            if(requestMethod.ToUpper().Equals("GET") && postData != null) {
                if(sb.ToString().Contains("?")) {
                    sb.Append("&");
                } else {
                    sb.Append("?");
                }
                sb.Append(postData);
            }

            Console.WriteLine("About to call URL " + sb.ToString());
            List<Object> result = new List<Object>();

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sb.ToString());
                request.Method = requestMethod;
                request.ContentType = "application/json";
                request.Accept = "application/json";
                request.Headers.Add("Authorization", "Bearer " + this.apiKey);

                if(requestMethod.ToUpper().Equals("POST") || requestMethod.ToUpper().Equals("PUT")) {
                    if(postData != null) {
                        byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                        request.ContentLength = byteArray.Length;
                        Stream postStream = request.GetRequestStream();
                        postStream.Write(byteArray, 0, byteArray.Length);
                        postStream.Close();
                    }
                }

                WebResponse response = request.GetResponse();
                Stream dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                String responseText = reader.ReadToEnd();
                response.Close();

                //Console.WriteLine("Response is " + responseText);

                if (responseText != null)
                {
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    Dictionary<String, Object> resultDict = (Dictionary<String, Object>)jss.DeserializeObject(responseText);
                    if (resultDict != null)
                    {
                        if (resultDict.Keys.Contains("results"))
                        {
                            Object[] objArr = (Object[])resultDict["results"];
                            foreach (Object obj in objArr)
                            {
                                try
                                {
                                    var resultObject = jss.ConvertToType(obj, resultType);
                                    result.Add(resultObject);
                                }
                                catch (Exception jsonEx)
                                {
                                    Console.WriteLine("JSON exception : " + jsonEx.Message);
                                }
                            }

                        }
                        else
                        {
                            var resultObject = jss.Deserialize(responseText, resultType);
                            result.Add(resultObject);
                        }
                    }
                }

                return result;

            }
            catch (WebException webEx)
            {
                if (webEx.Response != null)
                {
                    using (HttpWebResponse err = (HttpWebResponse)webEx.Response)
                    {
                        Console.WriteLine("The server returned '{0}' with the status code '{1} ({2:d})'.",
                          err.StatusDescription, err.StatusCode, err.StatusCode);
                    }
                }
                else
                {
                    Console.WriteLine(webEx.Message);
                }
            }
            return null;  // default
        }
Beispiel #18
0
            public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
            {
                UProject result = new UProject();
                string ustxVersion = dictionary["ustxversion"] as string;
                USTx.Project = result;
                result.Name = dictionary["name"] as string;
                result.Comment = dictionary["comment"] as string;
                result.OutputDir = dictionary["output"] as string;
                result.CacheDir = dictionary["cache"] as string;
                result.BPM = Convert.ToDouble(dictionary["bpm"]);
                result.BeatPerBar = Convert.ToInt32(dictionary["bpbar"]);
                result.BeatUnit = Convert.ToInt32(dictionary["bunit"]);
                result.Resolution = Convert.ToInt32(dictionary["res"]);

                foreach (var pair in (Dictionary<string, object>)(dictionary["exptable"]))
                {
                    var exp = serializer.ConvertToType(pair.Value, typeof(IntExpression)) as IntExpression;
                    var _exp = new IntExpression(null, pair.Key, exp.Abbr)
                    {
                        Data = exp.Data,
                        Min = exp.Min,
                        Max = exp.Max,
                    };
                    result.ExpressionTable.Add(pair.Key, _exp);
                }

                var singers = dictionary["singers"] as ArrayList;
                foreach (var singer in singers)
                    result.Singers.Add(serializer.ConvertToType(singer, typeof(USinger)) as USinger);

                foreach (var track in dictionary["tracks"] as ArrayList)
                {
                    var _tarck = serializer.ConvertToType(track, typeof(UTrack)) as UTrack;
                    result.Tracks.Add(_tarck);
                }

                foreach (var part in dictionary["parts"] as ArrayList)
                    result.Parts.Add(serializer.ConvertToType(part, typeof(UPart)) as UPart);

                USTx.Project = null;
                return result;
            }
            public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
            {
                MergedAssetFile mergedAssetFile = new MergedAssetFile
                                                      {
                                                          Order = serializer.ConvertToType<int>(dictionary["o"]),
                                                          Name = serializer.ConvertToType<string>(dictionary["n"])
                                                      };

                return mergedAssetFile;
            }
            public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
            {
                MergedAsset mergedAsset = new MergedAsset
                                              {
                                                  ContentType = serializer.ConvertToType<string>(dictionary["ct"]),
                                                  Version = serializer.ConvertToType<string>(dictionary["v"]),
                                                  Compress = serializer.ConvertToType<bool>(dictionary["c"]),
                                                  CacheDurationInDays = serializer.ConvertToType<float>(dictionary["cd"])
                                              };

                mergedAsset.Directories.AddRange(serializer.ConvertToType<IList<MergedAssetDirectory>>(dictionary["d"]));

                return mergedAsset;
            }
		public void Deserialize(IDictionary<string, object> dictionary, JavaScriptSerializer serializer)
		{
			foreach (string key in dictionary.Keys)
			{
				switch (key)
				{
					case "error":
						ApiUtil.ThrowIfError(dictionary, key, serializer);
						break;

					case "accountId":
						AccountId = Convert.ToInt64(dictionary[key]);
						break;

					case "albumTitle":
						AlbumTitle = (string)dictionary[key];
						break;

					case "artistName":
						ArtistName = (string)dictionary[key];
						break;

					case "creationDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => CreationDate = d);
						break;

					case "endDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => EndDate = d);
						break;

					case "id":
						Id = Convert.ToInt64(dictionary[key]);
						break;

					case "largeImageURL":
						LargeImageUrl = (string)dictionary[key];
						break;

					case "lastModifiedDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => LastModifiedDate = d);
						break;

					case "length":
						Length = Convert.ToInt64(dictionary[key]);
						break;

					case "linkText":
						LinkText = (string)dictionary[key];
						break;

					case "linkURL":
						LinkUrl = (string)dictionary[key];
						break;

					case "longDescription":
						LongDescription = (string)dictionary[key];
						break;

					case "name":
						Name = (string)dictionary[key];
						break;

					case "publishedDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => PublishedDate = d);
						break;

					case "referenceId":
						ReferenceId = (string)dictionary[key];
						break;

					case "releaseDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => ReleaseDate = d);
						break;

					case "shortDescription":
						ShortDescription = (string)dictionary[key];
						break;

					case "startDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => StartDate = d);
						break;

					case "tags":
						Tags.Clear();
						Tags.AddRange(serializer.ConvertToType<List<string>>(dictionary[key]));
						break;

					case "thumbnailURL":
						ThumbnailUrl = (string)dictionary[key];
						break;

					case "trackAssetURL":
						TrackAssetUrl = (string)dictionary[key];
						break;
				}
			}
		}
            public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
            {
                MergedAssetDirectory mergedAssetDirectory = new MergedAssetDirectory
                                                                {
                                                                    Path = serializer.ConvertToType<string>(dictionary["p"])
                                                                };

                mergedAssetDirectory.Files.AddRange(serializer.ConvertToType<IList<MergedAssetFile>>(dictionary["f"]));

                return mergedAssetDirectory;
            }
        /// <summary>
        /// Deserializes the specified dictionary.
        /// </summary>
        /// <param name="dictionary">The <see cref="IDictionary{String,Object}" />.</param>
        /// <param name="serializer">The <see cref="JavaScriptSerializer" />.</param>
        public void Deserialize(IDictionary<string, object> dictionary, JavaScriptSerializer serializer)
        {
            foreach (string key in dictionary.Keys)
            {
                switch (key)
                {
                    case "error":
                        ApiUtil.ThrowIfError(dictionary, key, serializer);
                        break;

                    case "id":
                        Id = Convert.ToInt64(dictionary[key]);
                        break;

                    case "image":
                        Image = serializer.ConvertToType<BrightcoveImage>(dictionary[key]);
                        break;

                    case "tooltip":
                        Tooltip = (string) dictionary[key];
                        break;

                    case "linkURL":
                        LinkUrl = (string) dictionary[key];
                        break;

                    case "alignment":
                        Alignment = ((string) dictionary[key]).ToBrightcoveEnum<LogoOverlayAlignment>();
                        break;
                }
            }
        }
        protected override List<FeedItem> ParseDocument(Dictionary<string, object> doc)
        {
            var feedItems = new List<FeedItem>(_totalLimit);
            if (doc != null)
            {
                var serializer = new JavaScriptSerializer();
                var model = serializer.ConvertToType<Model>(doc);
                for (var i = 0; i < Math.Min(_totalLimit, model.root.Count); i++)
                {
                    var modelItem = model.root[i];
                    feedItems.Add(new FeedItem(this)
                    {
                        Published = GetPublished(modelItem.created_at),
                        Title = GetTitle(modelItem.source),
                        Snippet = GetSnippet(modelItem.text),
                        ViewUri = GetViewUri(modelItem.id)
                    });
                }
            }

            return feedItems;
        }
 public override object Deserialize(IDictionary<string, object> dictionary, System.Type type, JavaScriptSerializer serializer)
 {
     var json = new JsonObject();
     foreach (var item in dictionary)
     {
         object value = item.Value;
         if (value is IDictionary<string, object>)
         {
             value = serializer.ConvertToType<JsonObject>(value);
         }
         json[item.Key] = value;
     }
     return json;
 }
        public override object Deserialize(IDictionary<string, object> dictionary,
                                           Type type,
                                           JavaScriptSerializer serializer)
        {
            if (type == typeof (oEmbed))
            {
                var obj = new oEmbed();

                if (dictionary.ContainsKey("version"))
                    obj.Version = serializer.ConvertToType<string>(dictionary["version"]);
                if (dictionary.ContainsKey("title"))
                    obj.Title = serializer.ConvertToType<string>(dictionary["title"]);
                if (dictionary.ContainsKey("type"))
                    obj.Type = serializer.ConvertToType<oEmbedType>(dictionary["type"]);
                if (dictionary.ContainsKey("author_name"))
                    obj.AuthorName = serializer.ConvertToType<string>(dictionary["author_name"]);
                if (dictionary.ContainsKey("author_url"))
                    obj.AuthorUrl = serializer.ConvertToType<string>(dictionary["author_url"]);
                if (dictionary.ContainsKey("provider_name"))
                    obj.ProviderName = serializer.ConvertToType<string>(dictionary["provider_name"]);
                if (dictionary.ContainsKey("provider_url"))
                    obj.ProviderUrl = serializer.ConvertToType<string>(dictionary["provider_url"]);
                if (dictionary.ContainsKey("cache_age"))
                    obj.CacheAge = serializer.ConvertToType<int>(dictionary["cache_age"]);
                if (dictionary.ContainsKey("thumbnail_url"))
                    obj.ThumbnailUrl = serializer.ConvertToType<string>(dictionary["thumbnail_url"]);
                if (dictionary.ContainsKey("thumbnail_width"))
                    obj.ThumbnailWidth = serializer.ConvertToType<int?>(dictionary["thumbnail_width"]);
                if (dictionary.ContainsKey("thumbnail_height"))
                    obj.ThumbnailHeight = serializer.ConvertToType<int?>(dictionary["thumbnail_height"]);
                if (dictionary.ContainsKey("url"))
                    obj.Url = serializer.ConvertToType<string>(dictionary["url"]);
                if (dictionary.ContainsKey("width") && dictionary["width"] != null)
                    obj.Width = serializer.ConvertToType<int>(dictionary["width"]);
                if (dictionary.ContainsKey("height") && dictionary["height"] != null)
                    obj.Height = serializer.ConvertToType<int>(dictionary["height"]);
                if (dictionary.ContainsKey("html"))
                    obj.Html = serializer.ConvertToType<string>(dictionary["html"]);


                return obj;
            }

            return null;
        }
		public void Deserialize(IDictionary<string, object> dictionary, JavaScriptSerializer serializer)
		{
			foreach (string key in dictionary.Keys)
			{
				switch (key)
				{
					case "error":
						ApiUtil.ThrowIfError(dictionary, key, serializer);
						break;

					case "accountId":
						AccountId = Convert.ToInt64(dictionary[key]);
						break;

					case "creationDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => CreationDate = d);
						break;

					case "cuePoints":
						CuePoints = serializer.ConvertToType<List<BrightcoveCuePoint>>(dictionary[key]);
						break;

					case "customFields":
						CustomFields = serializer.ConvertToType<CustomFieldCollection>(dictionary[key]);
						break;

					case "economics":
						Economics = ((string)dictionary[key]).ToBrightcoveEnum<Economics>();
						break;

					case "endDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => EndDate = d);
						break;

					case "FLVURL":
						FlvUrl = (string)dictionary[key];
						break;

					case "id":
						Id = Convert.ToInt64(dictionary[key]);
						break;
					
					case "itemState":
						ItemState = ((string) dictionary[key]).ToBrightcoveEnum<ItemState>();
						break;

					case "lastModifiedDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => LastModifiedDate = d);
						break;

					case "length":
						Length = Convert.ToInt64(dictionary[key]);
						break;

					case "linkURL":
						LinkUrl = (string)dictionary[key];
						break;

					case "linkText":
						LinkText = (string)dictionary[key];
						break;

					case "longDescription":
						LongDescription = (string)dictionary[key];
						break;

					case "name":
						Name = (string)dictionary[key];
						break;

					case "playsTotal":
						// sometimes this come back null, it seems
						if (dictionary[key] != null)
						{
							PlaysTotal = (int)dictionary[key];
						}
						break;

					case "playsTrailingWeek":
						if (dictionary[key] != null)
						{
							PlaysTrailingWeek = (int)dictionary[key];
						}
						break;

					case "publishedDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => PublishedDate = d);
						break;

					case "referenceId":
						ReferenceId = (string)dictionary[key];
						break;

					case "renditions":
						Renditions = serializer.ConvertToType<BrightcoveItemCollection<BrightcoveRendition>>(dictionary[key]);
						break;

					case "shortDescription":
						ShortDescription = (string)dictionary[key];
						break;

					case "startDate":
						DateUtil.ConvertAndSetDate(dictionary[key], d => StartDate = d);
						break;

					case "tags":
						Tags.Clear();
						Tags.AddRange(serializer.ConvertToType<List<string>>(dictionary[key])); 
						break;

					case "thumbnailURL":
						ThumbnailUrl = (string)dictionary[key];
						break;

					case "videoStillURL":
						VideoStillUrl = (string)dictionary[key];
						break;

					case "videoFullLength":
						VideoFullLength = serializer.ConvertToType<BrightcoveRendition>(dictionary[key]);
						break;

					default:
						break;
				}
			}
		}