public override void Deserialize(KnetikJSONNode json) { base.Deserialize(json); Assets = new Dictionary<string, ItemAsset>(); URLs = new Dictionary<string, string>(); if (json ["assets"].AsArray != null) { foreach (KnetikJSONNode node in json["assets"].Children) { string slug = node ["slug"].Value; ItemAsset asset = new ItemAsset(Client); asset.Deserialize(node ["asset"]); Assets.Add(slug, asset); URLs.Add(slug, asset.URL); } } else if (json ["urls"].AsArray != null) { foreach (KnetikJSONNode node in json["urls"].Children) { URLs.Add(node["name"].Value, node["url"].Value); } } }
public override void Deserialize (KnetikJSONNode json) { base.Deserialize (json); Value = json["value"].AsInt; int unearnedAssetId = json ["unearned_asset_id"].AsInt; int earnedAssetId = json ["earned_asset_id"].AsInt; foreach (ItemAsset asset in Assets) { if (asset.ID == unearnedAssetId) { UnearnedAsset = asset; } else if (asset.ID == earnedAssetId) { EarnedAsset = asset; } } }
public override void Deserialize(KnetikJSONNode json) { if(json == null || json.ToString() == "\"null\"") { return; } if (json ["id"] != null && json ["id"] != "null") { ID = json ["id"].AsInt; } UniqueKey = json ["unique_key"].Value; TypeHint = json ["type_hint"].Value; Name = json ["name"].Value; ShortDescription = json ["short_description"].Value; LongDescription = json ["long_description"].Value; Assets.Clear (); if (json ["assets"] != null) { foreach (KnetikJSONNode node in json["assets"].Children) { ItemAsset asset = new ItemAsset (Client); asset.Deserialize (node); if (json ["behaviors"] != null) { asset.setSlug(json ["behaviors"]); } Assets.Add (asset); } } Skus.Clear (); if (json ["skus"] != null) { foreach (KnetikJSONNode node in json["skus"].Children) { CatalogSku sku = new CatalogSku (Client, this); sku.Deserialize (node); Skus.Add (sku); } } Behaviors.Clear(); if (json ["behaviors"] != null) { foreach (KnetikJSONNode node in json["behaviors"].Children) { Behavior behavior = Behavior.Parse (Client, node); Behaviors.Add (behavior.TypeHint, behavior); } } if (json ["deleted_at"] != null && json ["deleted_at"] != "null") { DeletedAt = new DateTime (json ["deleted_at"].AsInt); } if (json ["date_created"] != null && json ["date_created"] != "null") { DateCreated = new DateTime (json ["date_created"].AsInt); } if (json ["date_updated"] != null && json ["date_updated"] != "null") { DateUpdated = new DateTime (json ["date_updated"].AsInt); } }