コード例 #1
0
        static InventoryItemDetails BuildItemDetails(ExpandoObject exp)
        {
            var data = exp as IDictionary <string, object>;

            var item = new InventoryItemDetails();

            item.appid            = data["appid"] as string;
            item.background_color = data["background_color"] as string;
            item.classid          = data["classid"] as string;
            item.descriptions     = new List <InventoryItemDescription>();
            var descs = data["descriptions"] as IDictionary <string, object>;

            if (descs != null)
            {
                foreach (var obj in descs)
                {
                    var dd   = obj.Value as IDictionary <string, object>;
                    var desc = new InventoryItemDescription();
                    desc.color = dd["color"] as string;
                    desc.value = dd["value"] as string;
                    item.descriptions.Add(desc);
                }
            }
            item.icon_drag_url = data["icon_drag_url"] as string;
            item.icon_url      = data["icon_url"] as string;
            item.name          = data["name"] as string;
            item.name_color    = data["name_color"] as string;
            item.tags          = new List <InventoryItemTag>();
            var tags = data["tags"] as ExpandoObject;

            if (tags != null)
            {
                foreach (var obj in tags)
                {
                    var dd  = obj.Value as IDictionary <string, object>;
                    var tag = new InventoryItemTag();
                    tag.category      = dd["category"] as string;
                    tag.category_name = dd["category_name"] as string;
                    tag.color         = dd["color"] as string;
                    tag.internal_name = dd["internal_name"] as string;
                    tag.name          = dd["name"] as string;
                    item.tags.Add(tag);
                }
            }
            item.tradable = (data["tradable"] as int?).Value == 1;
            item.type     = data["type"] as string;

            return(item);
        }
コード例 #2
0
        static InventoryItemDetails BuildItemDetails(ExpandoObject exp)
        {
            var data = exp as IDictionary<string, object>;

            var item = new InventoryItemDetails();
            item.appid = data["appid"] as string;
            item.background_color = data["background_color"] as string;
            item.classid = data["classid"] as string;
            item.descriptions = new List<InventoryItemDescription>();
            var descs = data["descriptions"] as IDictionary<string, object>;
            if (descs != null)
                foreach (var obj in descs)
                {
                    var dd = obj.Value as IDictionary<string, object>;
                    var desc = new InventoryItemDescription();
                    desc.color = dd["color"] as string;
                    desc.value = dd["value"] as string;
                    item.descriptions.Add(desc);
                }
            item.icon_drag_url = data["icon_drag_url"] as string;
            item.icon_url = data["icon_url"] as string;
            item.name = data["name"] as string;
            item.name_color = data["name_color"] as string;
            item.tags = new List<InventoryItemTag>();
            var tags = data["tags"] as ExpandoObject;
            if (tags != null)
                foreach (var obj in tags)
                {
                    var dd = obj.Value as IDictionary<string, object>;
                    var tag = new InventoryItemTag();
                    tag.category = dd["category"] as string;
                    tag.category_name = dd["category_name"] as string;
                    tag.color = dd["color"] as string;
                    tag.internal_name = dd["internal_name"] as string;
                    tag.name = dd["name"] as string;
                    item.tags.Add(tag);
                }
            item.tradable = (data["tradable"] as int?).Value == 1;
            item.type = data["type"] as string;

            return item;
        }