public void SetupBundleItemDisplay(BundleItem newBundleItem)
    {

        bundleItem = newBundleItem;

        ItemName.text = bundleItem.Name;
        itemAmount.text = "Amount: " + bundleItem.Quantity;

        ItemTextureCache.instance.GetItemTexture(bundleItem.Image, OnReceivedItemTexture);
    }
 public void OnGamepadButtonsReleased(Buttons GamepadButtons)
 {
     if (IsGamepadFocused && !RecentlyGainedFocus)
     {
         //  Handle action buttons
         if (GamepadControls.IsMatch(GamepadButtons, GamepadControls.Current.SecondaryAction))
         {
             SecondaryActionButtonPressedItem = null;
             SecondaryActionButtonPressedTime = null;
         }
     }
 }
Beispiel #3
0
    private void AddBundle(string strDir, string strPath)
    {
        BundleItem cItem;

        if (!m_dicBundleCount.TryGetValue(strPath, out cItem))
        {
            cItem        = new BundleItem();
            cItem.nCount = 1;
            cItem.lstDir = new List <string>();
            cItem.lstDir.Add(strDir);
            m_dicBundleCount.Add(strPath, cItem);
        }
    }
Beispiel #4
0
    public List <ItemBundle> ConvertToListItemBundle(string dataString)
    {
        List <ItemBundle> ItemBundles = new List <ItemBundle>();

        string parsedString = ParseString(dataString);

        JsonData itemBundleData = LitJson.JsonMapper.ToObject(parsedString);

        for (int i = 0; i < itemBundleData.Count; i++)
        {
            ItemBundle itemBundle = new ItemBundle();
            itemBundle.ID          = int.Parse(itemBundleData[i]["ID"].ToString());
            itemBundle.Name        = itemBundleData[i]["Name"].ToString();
            itemBundle.Description = itemBundleData[i]["Description"].ToString();
            itemBundle.CreditPrice = int.Parse(itemBundleData[i]["CreditPrice"].ToString());
            itemBundle.CoinPrice   = int.Parse(itemBundleData[i]["CoinPrice"].ToString());
            itemBundle.State       = (CloudGoodsBundle)Enum.Parse(typeof(CloudGoodsBundle), itemBundleData[i]["State"].ToString());
            itemBundle.Image       = itemBundleData[i]["Image"].ToString();

            //TODO Implement itembundle behaviours

            JsonData BundleItemData = itemBundleData[i]["items"];

            for (int j = 0; j < BundleItemData.Count; j++)
            {
                BundleItem bundleItem = new BundleItem();
                bundleItem.Quantity    = int.Parse(BundleItemData[j]["Quantity"].ToString());
                bundleItem.Name        = BundleItemData[j]["Name"].ToString();
                bundleItem.Image       = BundleItemData[j]["Image"].ToString();
                bundleItem.Description = BundleItemData[j]["Description"].ToString();
                bundleItem.Quality     = int.Parse(BundleItemData[j]["Quality"].ToString());

                JsonData bundleItemDetailData = LitJson.JsonMapper.ToObject(BundleItemData[j]["Detail"].ToString());

                for (int k = 0; k < bundleItemDetailData.Count; k++)
                {
                    BundleItemDetails bundleDetails = new BundleItemDetails();
                    bundleDetails.BundleDetailName = bundleItemDetailData[k]["Name"].ToString();
                    bundleDetails.Value            = float.Parse(bundleItemDetailData[k]["Value"].ToString());

                    bundleItem.bundleItemDetails.Add(bundleDetails);
                }

                itemBundle.bundleItems.Add(bundleItem);
            }

            ItemBundles.Add(itemBundle);
        }

        return(ItemBundles);
    }
        private void FillBundleItem(CatalogBundleItemModel model, BundleItem item)
        {
            model.RealPrice = GetBundleRealPrice(item, out var realPriceWithoutDiscount);
            model.RealPriceWithoutDiscount = realPriceWithoutDiscount;

            model.VirtualPrice = GetBundleVirtualPrice(item, out var virtualPriceWithoutDiscount);
            model.VirtualPriceWithoutDiscount = virtualPriceWithoutDiscount;

            model.ContentRealPrice = GetBundleContentRealPrice(item, out var contentRealPriceWithoutDiscount);
            model.ContentRealPriceWithoutDiscount = contentRealPriceWithoutDiscount;

            model.ContentVirtualPrice = GetBundleContentVirtualPrice(item, out var contentVirtualPriceWithoutDiscount);
            model.ContentVirtualPriceWithoutDiscount = contentVirtualPriceWithoutDiscount;
        }
Beispiel #6
0
        private void AddToMod(string depotpath, BundleManager bmanager)
        {
            var manager = bmanager;

            if (!manager.Items.ContainsKey(depotpath))
            {
                return;
            }

            BundleItem selectedBundle = null;

            if (manager.Items[depotpath].Count > 1)
            {
                var bundles = manager.Items[depotpath].ToDictionary(bundle => bundle.Bundle.FileName);

                var dlg = new frmExtractAmbigious(bundles.Keys);
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                selectedBundle = bundles[dlg.SelectedBundle];
            }
            else
            {
                selectedBundle = manager.Items[depotpath].Last();
            }

            var filename = Path.Combine(ActiveMod.FileDirectory, depotpath);

            try
            {
                Directory.CreateDirectory(Path.GetDirectoryName(filename));
            }
            catch
            {
            }

            if (File.Exists(filename))
            {
                if (MessageBox.Show(filename + " already exists, do you want to overwrite it?", "Add mod file error.", MessageBoxButtons.OKCancel) != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                File.Delete(filename);
            }

            selectedBundle.Extract(filename);
        }
Beispiel #7
0
        // 是否正在下载中,或是否需要下载
        public bool SingleABNeedDownload(string path)
        {
            // 下载中
            ToDownloadBundle obj = m_toDownloadSingleBundles.Find(t => t.Path == path);

            if (obj != null)
            {
                return(true);
            }

            // 属于加载时再下载的资源
            BundleItem bundleObj = GetBundleObj(path);

            return(bundleObj != null && bundleObj.State == BundleState.DownloadWhenUse);
        }
Beispiel #8
0
    private void ReplacePH()
    {
        foreach (GameObject ph in placeholders)
        {
            DioramaObject dio = ph.GetComponent <DioramaObject>();
            BundleItem    t   = TODV2.GetItemByID(dio.todID);

            string path = t.TopFolder.ToString() + @"\";
            path += t.BundleName + @"\" + (t.FolderPath.Replace(",", @"\")) + @"\";
            path += t.prefabName.Replace(".prefab", "");
            path += " Rigged";
            GameObject next = GameObject.Instantiate(Resources.Load(path, typeof(GameObject)), ph.transform.position, ph.transform.rotation, ph.transform.parent) as GameObject;
            ph.SetActive(false);
        }
    }
Beispiel #9
0
    void    SaveFile(byte[] data, BundleItem item)
    {
        string     localPath = FixedPath(item.bundlePath);
        FileStream file      = new FileStream(localPath, FileMode.Create);

        //file.Write(data,0,data.Length);
        if (item.isCompress)
        {
            SD.Decompress(new MemoryStream(data), file);
        }
        else
        {
            file.Write(data, 0, data.Length);
        }
        file.Close();
    }
    public void SetupBundleItemDisplay(BundleItem newBundleItem)
    {
        bundleItem = newBundleItem;

        ItemName.text   = bundleItem.Name;
        itemAmount.text = "Amount: " + bundleItem.Quantity;

        ItemStats.text = "";

        foreach (BundleItemDetails details in newBundleItem.bundleItemDetails)
        {
            ItemStats.text += details.BundleDetailName + " : " + details.Value + " \n";
        }

        CloudGoods.GetItemTexture(bundleItem.Image, OnReceivedItemTexture);
    }
    void SetBundleItemToDisplay(int index)
    {
        BundleItem bundleitem = itemBundle.bundleItems[index];

        ItemName.text = bundleitem.Name;

        string formated = "";

        foreach (BundleItemDetails detail in bundleitem.bundleItemDetails)
        {
            formated = string.Format("{0}{1}: {2}\n", formated, detail.BundleDetailName, detail.Value.ToString());
        }

        ItemDetails.text = formated;

        CloudGoods.GetItemTexture(bundleitem.Image, OnReceivedItemTexture);
    }
        private KeyValuePair <string, uint>?GetBundleVirtualPrice(BundleItem item, out KeyValuePair <string, uint>?priceWithoutDiscount)
        {
            var virtualPrices = item.virtual_prices.ToList();

            if (!virtualPrices.Any())
            {
                priceWithoutDiscount = null;
                return(null);
            }

            var virtualPrice = virtualPrices.Count(v => v.is_default) == 0
                                ? virtualPrices.First()
                                : virtualPrices.First(v => v.is_default);

            priceWithoutDiscount = new KeyValuePair <string, uint>(virtualPrice.sku, virtualPrice.GetAmountWithoutDiscount());
            return(new KeyValuePair <string, uint>(virtualPrice.sku, virtualPrice.GetAmount()));
        }
        private KeyValuePair <string, uint>?GetBundleContentVirtualPrice(BundleItem bundle, out KeyValuePair <string, uint>?priceWithoutDiscount)
        {
            var bundleContent = bundle.content.ToList();

            if (!bundleContent.Any())
            {
                priceWithoutDiscount = null;
                return(null);
            }

            uint   contentVirtualPrice = 0;
            uint   contentVirtualPriceWithoutDiscount = 0;
            string virtualCurrency = "";

            foreach (var bundleContentItem in bundleContent)
            {
                var virtualPrices = bundleContentItem.virtual_prices.ToList();

                if (!virtualPrices.Any())
                {
                    priceWithoutDiscount = null;
                    return(null);
                }

                var virtualPrice = virtualPrices.Count(v => v.is_default) == 0
                                        ? virtualPrices.First()
                                        : virtualPrices.First(v => v.is_default);

                if (string.IsNullOrEmpty(virtualCurrency))
                {
                    virtualCurrency = virtualPrice.sku;
                }

                if (virtualCurrency != virtualPrice.sku)
                {
                    priceWithoutDiscount = null;
                    return(null);
                }

                contentVirtualPrice += virtualPrice.GetAmount();
                contentVirtualPriceWithoutDiscount += virtualPrice.GetAmountWithoutDiscount();
            }

            priceWithoutDiscount = new KeyValuePair <string, uint>(virtualCurrency, contentVirtualPriceWithoutDiscount);
            return(new KeyValuePair <string, uint>(virtualCurrency, contentVirtualPrice));
        }
Beispiel #14
0
        public void OptimizerBundleItemsAddWithBadPathThrowsFileNotFoundExceptionTest()
        {
            OptimizationSettings config = new OptimizationSettings()
            {
                ApplicationPath   = TestContext.DeploymentDirectory,
                BundleSetupMethod = (bundles) => {
                    var bundle     = new ScriptBundle("~/bundles/bogus");
                    var bundleItem = new BundleItem("~/totallybogus");
                    bundle.Items.Add(bundleItem);
                    bundles.Add(bundle);
                }
            };

            ExceptionHelper.ExpectException <FileNotFoundException>(() => {
                BundleResponse response = Optimizer.BuildBundle("~/bundles/bogus", config);
            });
        }
        public void OnMouseButtonPressed(ButtonPressedEventArgs e)
        {
            if (!IsJojaMember)
            {
                if (e.Button == SButton.MouseLeft)
                {
                    HandlePrimaryAction(GetHoveredItem());
                }

                if (e.Button == SButton.MouseRight)
                {
                    HandleSecondaryAction(GetHoveredItem());
                    SecondaryActionButtonPressedItem = HoveredBundleItem;
                    SecondaryActionButtonPressedTime = DateTime.Now;
                }
            }
        }
        public bool TryNavigateEnter(NavigationDirection StartingSide, Rectangle?ClosestTo)
        {
            IsGamepadFocused        = true;
            IsNavigatingWithGamepad = true;

            if (ClosestTo.HasValue)
            {
                List <Rectangle> AllSlots = TaskHeaderPositions.Select(x => x.Value).Union(ItemSlotPositions.Select(x => x.Value)).ToList();
                Rectangle        ToSelect = AllSlots.OrderBy(x => x.GetOffseted(TopLeftScreenPosition).SquaredDistanceBetweenCenters(ClosestTo.Value)).First();

                foreach (KeyValuePair <BundleItem, Rectangle> KVP in ItemSlotPositions)
                {
                    if (KVP.Value == ToSelect)
                    {
                        HoveredBundleItem = KVP.Key;
                        HoveredBundleTask = null;
                        return(true);
                    }
                }

                foreach (KeyValuePair <BundleTask, Rectangle> KVP in TaskHeaderPositions)
                {
                    if (KVP.Value == ToSelect)
                    {
                        HoveredBundleTask = KVP.Key;
                        HoveredBundleItem = null;
                        return(true);
                    }
                }
            }

            if (StartingSide == NavigationDirection.Right)
            {
                while (TryNavigate(NavigationDirection.Right, NavigationWrappingMode.NoWrap, NavigationWrappingMode.NoWrap))
                {
                }
            }
            if (StartingSide == NavigationDirection.Down)
            {
                while (TryNavigate(NavigationDirection.Down, NavigationWrappingMode.NoWrap, NavigationWrappingMode.NoWrap))
                {
                }
            }

            return(true);
        }
        public void OnMouseMoved(CursorMovedEventArgs e)
        {
            if (!IsJojaMember)
            {
                if (Bounds.Contains(e.OldPosition.ScreenPixels.AsPoint()) || Bounds.Contains(e.NewPosition.ScreenPixels.AsPoint()))
                {
                    BundleItem PreviouslyHovered = HoveredBundleItem;

                    this.HoveredBundleItem = null;
                    if (ItemSlotPositions != null)
                    {
                        foreach (KeyValuePair <BundleItem, Rectangle> KVP in ItemSlotPositions)
                        {
                            Rectangle Rect = KVP.Value;
                            if (Rect.GetOffseted(TopLeftScreenPosition).Contains(e.NewPosition.ScreenPixels.AsPoint()))
                            {
                                if (PreviouslyHovered != null && PreviouslyHovered != KVP.Key)
                                {
                                    SecondaryActionButtonPressedItem = null;
                                }
                                this.HoveredBundleItem       = KVP.Key;
                                this.IsNavigatingWithGamepad = false;
                                break;
                            }
                        }
                    }

                    this.HoveredBundleTask = null;
                    if (TaskHeaderPositions != null)
                    {
                        foreach (KeyValuePair <BundleTask, Rectangle> KVP in TaskHeaderPositions)
                        {
                            Rectangle Rect = KVP.Value;
                            if (Rect.GetOffseted(TopLeftScreenPosition).Contains(e.NewPosition.ScreenPixels.AsPoint()))
                            {
                                this.HoveredBundleTask       = KVP.Key;
                                this.IsNavigatingWithGamepad = false;
                                break;
                            }
                        }
                    }
                }
            }

            UpdateHoveredItem(e);
        }
        public bool TryNavigate(NavigationDirection Direction, NavigationWrappingMode HorizontalWrapping, NavigationWrappingMode VerticalWrapping)
        {
            Rectangle?HoveredSlot = GetHoveredSlot(false);

            if (IsGamepadFocused && HoveredSlot == null)
            {
                HoveredBundleItem       = ItemSlotPositions.First().Key;
                IsNavigatingWithGamepad = HoveredBundleItem != null;
                return(HoveredBundleItem != null);
            }
            else if (TryGetSlotNeighbor(HoveredSlot, Direction, HorizontalWrapping, VerticalWrapping, out Rectangle? Neighbor))
            {
                foreach (KeyValuePair <BundleItem, Rectangle> KVP in ItemSlotPositions)
                {
                    if (KVP.Value == Neighbor.Value)
                    {
                        HoveredBundleItem       = KVP.Key;
                        HoveredBundleTask       = null;
                        IsNavigatingWithGamepad = true;
                        return(true);
                    }
                }

                foreach (KeyValuePair <BundleTask, Rectangle> KVP in TaskHeaderPositions)
                {
                    if (KVP.Value == Neighbor.Value)
                    {
                        HoveredBundleTask       = KVP.Key;
                        HoveredBundleItem       = null;
                        IsNavigatingWithGamepad = true;
                        return(true);
                    }
                }

                HoveredBundleItem = null;
                HoveredBundleTask = null;

                return(false);
            }
            else
            {
                return(false);
            }
        }
Beispiel #19
0
    public void SetObject(BundleItem t, float sizeMod)
    {
        AssetBundle ab = AssetBundleManager.GetAssetBundle(t.BundleName).assetBundle;

        Destroy(go);
        this.todID = t.id;
        gridScale  = t.gridScale;

        if (t.LoadFromResources)
        {
            string path = t.TopFolder.ToString() + @"\";
            path += t.BundleName + @"\" + (t.FolderPath.Replace(",", @"\")) + @"\";
            path += t.prefabName.Replace(".prefab", "");
            go    = GameObject.Instantiate(Resources.Load(path, typeof(GameObject))) as GameObject;
        }
        else
        {
            try
            {
                go = Instantiate(ab.LoadAsset(t.PrefabName, typeof(GameObject))) as GameObject;
                Common.ReassignTextures(go, t.HasLight);
            }
            catch (Exception e)
            {
                Debug.Log(t.prefabName + " ID: " + t.id + " failed to load -- " + e.StackTrace);
            }
        }


        //if (t.HasAnimation) {
        CheckAnimation(go, t.SavedInt);
        //}

        go.name = "Test";

        go.transform.parent        = this.transform;
        go.transform.localPosition = t.offsetPos;
        go.transform.localRotation = t.offsetRot;
        go.transform.localScale    = new Vector3(t.offsetScale * sizeMod, t.offsetScale * sizeMod, t.offsetScale * sizeMod);

        Common.DestroyAll(go);
    }
    private static string?GetRawContentString(BundleItem item)
    {
        switch (item.ContentFormat?.ToUpperInvariant())
        {
        case "BASE64":
            byte[] decoded = Convert.FromBase64String(item.ContentString ?? string.Empty);
            return(Encoding.UTF8.GetString(decoded));

        case "JSON":
            return(item.ContentJson !.ToString());

        case null:
        case "":
        case "STRING":
            return(item.ContentString);

        default:
            throw new NotSupportedException($"Content format '{item.ContentFormat}' for bundle item with Id '{item.Id}' is not supported.");
        }
    }
        /// <inheritdoc />
        /// <summary>
        /// Update a bundle item &lt;b&gt;Permissions Needed:&lt;/b&gt; BUNDLES_ADMIN
        /// </summary>
        /// <param name="id">The id of the bundle</param>
        /// <param name="cascade">Whether to cascade group changes, such as in the limited gettable behavior. A 400 error will return otherwise if the group is already in use with different values.</param>
        /// <param name="bundleItem">The bundle item object</param>
        public void UpdateBundleItem(int?id, bool?cascade, BundleItem bundleItem)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling UpdateBundleItem");
            }

            mWebCallEvent.WebPath = "/store/bundles/{id}";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "id" + "}", KnetikClient.ParameterToString(id));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            if (cascade != null)
            {
                mWebCallEvent.QueryParams["cascade"] = KnetikClient.ParameterToString(cascade);
            }

            mWebCallEvent.PostBody = KnetikClient.Serialize(bundleItem); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mUpdateBundleItemStartTime = DateTime.Now;
            mWebCallEvent.Context      = mUpdateBundleItemResponseContext;
            mWebCallEvent.RequestType  = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdateBundleItemStartTime, "UpdateBundleItem", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
    private static void ValidateItem(BundleItem item, out Uri?uri, out Version?version)
    {
        version = null;

        if (item.Uri == null)
        {
            throw new InvalidOperationException($"Bundle item with Id '{item.Id}' has no URI configured.");
        }

        string templated = TemplateString(item.Uri, item.TemplateValues);

        if (!Uri.TryCreate(templated, UriKind.Absolute, out uri))
        {
            throw new InvalidOperationException($"Bundle item with Id '{item.Id}' has an invalid absolute URI '{item.Uri}' configured.");
        }

        if (item.Version != null && !Version.TryParse(item.Version, out version))
        {
            throw new InvalidOperationException($"Bundle item with Id '{item.Id}' has an invalid version '{item.Version}' configured.");
        }
    }
Beispiel #23
0
        public void OptimizerUppercaseOnlyFirstItemTransformTest()
        {
            OptimizationSettings config = new OptimizationSettings()
            {
                ApplicationPath   = TestContext.DeploymentDirectory,
                BundleSetupMethod = (bundles) => {
                    var bundle     = new ScriptBundle("~/bundles/upper");
                    var bundleItem = new BundleItem("~/scripts/first.js");
                    bundleItem.Transforms.Add(new UppercaseTransform());
                    bundle.Items.Add(bundleItem);
                    bundleItem = new BundleItem("~/scripts/second.js");
                    bundle.Items.Add(bundleItem);
                    bundles.Add(bundle);
                }
            };

            BundleResponse response = Optimizer.BuildBundle("~/bundles/upper", config);

            Assert.IsNotNull(response);
            Assert.AreEqual("ALERT(\"FIRST\");alert(\"second\")", response.Content);
            Assert.AreEqual(JsMinify.JsContentType, response.ContentType);
        }
        public void OnGamepadButtonsPressed(Buttons GamepadButtons)
        {
            if (IsGamepadFocused && !RecentlyGainedFocus)
            {
                if (!GamepadControls.HandleNavigationButtons(this, GamepadButtons, GetHoveredSlot(true)))
                {
                    this.IsGamepadFocused = false;
                }

                //  Handle action buttons
                if (GamepadControls.IsMatch(GamepadButtons, GamepadControls.Current.PrimaryAction))
                {
                    HandlePrimaryAction(GetHoveredItem());
                }
                if (GamepadControls.IsMatch(GamepadButtons, GamepadControls.Current.SecondaryAction))
                {
                    HandleSecondaryAction(GetHoveredItem());
                    SecondaryActionButtonPressedItem = HoveredBundleItem;
                    SecondaryActionButtonPressedTime = DateTime.Now;
                }
            }
        }
Beispiel #25
0
        public override void Parse()
        {
            int        userCount  = 0;
            List <int> addedItems = new List <int>();
            int        genreID    = 1;

            foreach (UserItem userItem in DataManager.UserItems)
            {
                _AddUser(userItem.user_id, userItem.user_url, userItem.items_count);
                foreach (Item item in userItem.items)
                {
                    BundleItem bundleItem = _GetBundleItem(item.item_name);
                    if (bundleItem != null && !addedItems.Contains(item.item_id))
                    {
                        _AddItem(item.item_id, item.item_name, bundleItem.item_url, genreID, Math.Round(float.Parse(bundleItem.discounted_price.Replace("$", "")), 2));
                        _AddGenreContents(bundleItem.genre, item.item_id);
                        addedItems.Add(item.item_id);
                        genreID++;
                    }
                    else if (!addedItems.Contains(item.item_id))
                    {
                        _AddItem(item.item_id, item.item_name, null, -1, -1);
                        addedItems.Add(item.item_id);
                    }
                    _AddLibrary(userItem.user_id, item.item_id, item.playtime_forever, item.playtime_2weeks);
                }
                userCount++;
                DataManager.DisplayProgress("User Items Progress: ", userCount, DataManager.UserItems.Count, DataManager.UserItems.Count / 1000);
            }
            DataManager.DisplayProgress("User Items Progress: ", 1, 1, 1);
            Console.WriteLine("\nAdded " + userCount + " users");
            DataManager.AddTable("Genres", DataManager.GenreDataTable);
            DataManager.AddTable("Users", DataManager.UserDataTable);
            DataManager.AddTable("Items", DataManager.ItemDataTable);
            DataManager.AddTable("ItemsGenreContents", DataManager.GenreContentsTable);
            DataManager.AddTable("Libraries", DataManager.LibraryDataTable);
        }
Beispiel #26
0
    public List <ItemBundle> ConvertToListItemBundle(string dataString)
    {
        List <ItemBundle> ItemBundles = new List <ItemBundle>();

        JToken itemBundleParse = JToken.Parse(dataString);
        JArray itemBundleObj   = JArray.Parse(itemBundleParse.ToString());

        for (int i = 0; i < itemBundleObj.Count; i++)
        {
            ItemBundle itemBundle = JsonConvert.DeserializeObject <ItemBundle>(itemBundleObj[i].ToString());

            JArray BundleItemArray = JArray.Parse(itemBundleObj[i]["items"].ToString());

            for (int j = 0; j < BundleItemArray.Count; j++)
            {
                BundleItem bundleItem = JsonConvert.DeserializeObject <BundleItem>(BundleItemArray[j].ToString());

                JArray bundleDetailsArray = JArray.Parse(BundleItemArray[j]["Detail"].ToString());

                for (int k = 0; k < bundleDetailsArray.Count; k++)
                {
                    BundleItemDetails bundleDetails = new BundleItemDetails();
                    bundleDetails.BundleDetailName = bundleDetailsArray[k]["Name"].ToString();
                    bundleDetails.Value            = int.Parse(bundleDetailsArray[k]["Value"].ToString());

                    bundleItem.bundleItemDetails.Add(bundleDetails);
                }

                itemBundle.bundleItems.Add(bundleItem);
            }

            ItemBundles.Add(itemBundle);
        }

        return(ItemBundles);
    }
Beispiel #27
0
        private static int StressTestFile(BundleItem f, ref ConcurrentDictionary <string, string> unknownclasses, ref long totalbytes, ref long unknownbytes, ref Dictionary <string, Tuple <long, long> > chunkstate)
        {
            var crw = new CR2WFile();

            using (var ms = new MemoryStream())
                using (var br = new BinaryReader(ms))
                {
                    f.ExtractExistingMMF(ms);
                    ms.Seek(0, SeekOrigin.Begin);

                    #region Reading Test A
                    // reading test
                    crw.Read(br);
                    #endregion

                    #region StringTableTest A.1
                    // additional tests
                    (var dict, var strings, var nameslist, var importslist) = crw.GenerateStringtable();
                    var newdictvalues = dict.Values.ToList();
                    var dictvalues    = crw.StringDictionary.Values.ToList();
                    var diffDictList  = dictvalues.Except(newdictvalues).ToList();

                    bool isclassicalinconsistentw2anims = false;
                    bool isclassicalinconsistentw2phase = false;

                    if (diffDictList.Count != 0)
                    {
                        //w2anims inconsistencies
                        foreach (string str in diffDictList)
                        {
                            if (str == "extAnimEvents" ||
                                str == "array:2,0,handle:CExtAnimEventsFile" ||
                                str == "CExtAnimEventsFile" ||
                                str.Contains("sounds\\") ||
                                str.Contains("sound\\"))
                            {
                                isclassicalinconsistentw2anims = true;
                                break;
                            }
                            else
                            {
                                continue;
                            }
                        }
                        //w2phase inconsistencies
                        foreach (string str in diffDictList)
                        {
                            if (str == "@SItem" ||
                                str == "SItem" ||
                                str == "#CEnvironmentDefinition" ||
                                str == "CEnvironmentDefinition")
                            {
                                isclassicalinconsistentw2phase = true;
                                break;
                            }
                            else
                            {
                                continue;
                            }
                        }

                        if (isclassicalinconsistentw2anims)
                        {
                            //throw new InvalidBundleException("Classical inconsistent .w2anims - " +
                            //    ".w2animev sound handles left behind in string lists, but actual data is empty");
                        }
                        else if (isclassicalinconsistentw2phase)
                        {
                            //throw new InvalidBundleException("Inconsistent .w2phase - " +
                            //    "secret e3 files");
                            // skip test B
                        }
                        else
                        {
                            throw new InvalidBundleException(" Generated dictionary not equal actual dictionary.");
                        }
                    }
                    #endregion

                    #region Writing Test B
                    if (isclassicalinconsistentw2phase || isclassicalinconsistentw2anims)
                    {
                        // skip test
                        // add additional fail-safe test?
                    }
                    else
                    {
                        byte[] buffer_testB;
                        byte[] buffer_testB_original;

                        using (var ms_testB = new MemoryStream())
                            using (var bw_testB = new BinaryWriter(ms_testB))
                            {
                                crw.Write(bw_testB);
                                buffer_testB = ms_testB.ToArray();
                            }

                        // compare
                        ms.Seek(0, SeekOrigin.Begin);
                        buffer_testB_original = ms.ToArray();

                        if (!Enumerable.SequenceEqual(buffer_testB_original, buffer_testB))
                        {
                            throw new InvalidBundleException(" Generated cr2w file not equal to original file.");
                        }
                    }
                    #endregion
                }
            foreach (var ut in crw.UnknownTypes)
            {
                unknownclasses.TryAdd(ut, ut);
            }
            foreach (var c in crw.Chunks)
            {
                var ubsl = c.unknownBytes?.Bytes != null ? c.unknownBytes.Bytes.Length : 0;

                lock (chunkstate)
                {
                    if (!chunkstate.ContainsKey(c.REDType))
                    {
                        chunkstate.Add(c.REDType, new Tuple <long, long>(0, 0));
                    }
                    var already = chunkstate[c.REDType];
                    chunkstate[c.REDType] = new Tuple <long, long>(
                        already.Item1 + c.Export.dataSize,
                        already.Item2 + ubsl
                        );
                }

                Interlocked.Add(ref totalbytes, c.Export.dataSize);
                Interlocked.Add(ref unknownbytes, ubsl);
            }
            return(0);
        }
        public void InitializeLayout(int ResizeIteration)
        {
            if (BundleBag == null)
            {
                return;
            }

            if (ResizeIteration > 1)
            {
                this.SlotSize = Math.Min(OriginalSlotSize, Math.Max(24, OriginalSlotSize - (ResizeIteration - 1) * 8));
            }

            if (IsJojaMember)
            {
                this.RelativeBounds = new Rectangle(0, 0, 640 + Padding * 2, 288 + Padding * 2);
            }
            else
            {
                HoveredBundleTask = null;
                HoveredBundleItem = null;
                SecondaryActionButtonPressedTime = null;
                SecondaryActionButtonPressedItem = null;

                int RoomBottomMargin = 12;
                int RoomRightMargin  = 8;

                int StartX = Padding;
                int StartY = Padding;

                CommunityCenterBundles CC = CommunityCenterBundles.Instance;

                this.RoomHeaderPositions = new Dictionary <BundleRoom, Rectangle>();
                this.RoomSlotPositions   = new Dictionary <BundleRoom, List <Rectangle> >();
                this.TaskHeaderPositions = new Dictionary <BundleTask, Rectangle>();
                this.TaskSlotPositions   = new Dictionary <BundleTask, List <Rectangle> >();
                this.ItemSlotPositions   = new OrderedDictionary <BundleItem, Rectangle>();
                this.LockedSlotPositions = new List <Rectangle>();

                int RoomNameWidth = CC.Rooms.Select(x => (int)(RoomHeaderFont.MeasureString(x.DisplayName).X *RoomHeaderScale)).DefaultIfEmpty(100).Max() + 32;

                int CurrentRow    = 0;
                int CurrentColumn = 0;
                int RoomIndex     = 0;
                foreach (BundleRoom Room in CC.Rooms)
                {
                    if (BundleBag.InvalidRooms[BundleBag.Size].Contains(Room.Name))
                    {
                        continue;
                    }

                    Rectangle RoomHeader = new Rectangle(StartX, StartY + CurrentRow * SlotSize + RoomIndex * RoomBottomMargin, RoomNameWidth, SlotSize);
                    RoomHeaderPositions.Add(Room, RoomHeader);

                    List <Rectangle> CurrentRoomSlotPositions = new List <Rectangle>();
                    RoomSlotPositions.Add(Room, CurrentRoomSlotPositions);

                    foreach (BundleTask Task in Room.Tasks)
                    {
                        if (CurrentColumn == ColumnCount)
                        {
                            CurrentColumn = 0;
                            CurrentRow++;
                        }

                        Rectangle TaskHeader = new Rectangle(StartX + RoomNameWidth + RoomRightMargin + CurrentColumn * SlotSize, StartY + CurrentRow * SlotSize + RoomIndex * RoomBottomMargin, SlotSize, SlotSize);
                        TaskHeaderPositions.Add(Task, TaskHeader);
                        CurrentRoomSlotPositions.Add(TaskHeader);

                        List <Rectangle> CurrentTaskSlotPositions = new List <Rectangle>();
                        TaskSlotPositions.Add(Task, CurrentTaskSlotPositions);

                        CurrentColumn++;

                        foreach (BundleItem Item in Task.Items)
                        {
                            if (!BundleTask.IsValidItemId(Item.Id))
                            {
                                continue;
                            }

                            if (CurrentColumn == ColumnCount)
                            {
                                CurrentColumn = 0;
                                CurrentRow++;
                            }

                            Rectangle Slot = new Rectangle(StartX + RoomNameWidth + RoomRightMargin + CurrentColumn * SlotSize, StartY + CurrentRow * SlotSize + RoomIndex * RoomBottomMargin, SlotSize, SlotSize);
                            CurrentRoomSlotPositions.Add(Slot);
                            CurrentTaskSlotPositions.Add(Slot);
                            ItemSlotPositions.Add(Item, Slot);

                            CurrentColumn++;
                        }
                    }

                    if (ShowLockedSlots)
                    {
                        while (CurrentColumn < ColumnCount)
                        {
                            Rectangle LockedSlot = new Rectangle(StartX + RoomNameWidth + RoomRightMargin + CurrentColumn * SlotSize, StartY + CurrentRow * SlotSize + RoomIndex * RoomBottomMargin, SlotSize, SlotSize);
                            LockedSlotPositions.Add(LockedSlot);
                            CurrentColumn++;
                        }
                    }

                    CurrentColumn = 0;
                    CurrentRow++;
                    RoomIndex++;
                }

                this.RelativeBounds = new Rectangle(0, 0, Padding + RoomNameWidth + RoomRightMargin + ColumnCount * SlotSize + Padding,
                                                    Padding + CurrentRow * SlotSize + Padding + (RoomIndex - 1) * RoomBottomMargin);
            }
        }
    public List<ItemBundle> ConvertToListItemBundle(string dataString)
    {
        List<ItemBundle> ItemBundles = new List<ItemBundle>();

        string parsedString = ParseString(dataString);

        JsonData itemBundleData = LitJson.JsonMapper.ToObject(parsedString);

        for (int i = 0; i < itemBundleData.Count; i++)
        {
            ItemBundle itemBundle = new ItemBundle();
            itemBundle.ID = int.Parse(itemBundleData[i]["ID"].ToString());
            itemBundle.Name = itemBundleData[i]["Name"].ToString();
            itemBundle.Description = itemBundleData[i]["Description"].ToString();
            itemBundle.CreditPrice = int.Parse(itemBundleData[i]["CreditPrice"].ToString());
            itemBundle.CoinPrice = int.Parse(itemBundleData[i]["CoinPrice"].ToString());
            itemBundle.State = int.Parse(itemBundleData[i]["State"].ToString());

            //TODO Implement itembundle behaviours

            JsonData BundleItemData = itemBundleData[i]["items"];

            for (int j = 0; j < BundleItemData.Count; j++)
            {
                BundleItem bundleItem = new BundleItem();
                bundleItem.Quantity = int.Parse(BundleItemData[j]["Quantity"].ToString());
                bundleItem.Name = BundleItemData[j]["Name"].ToString();
                bundleItem.Image = BundleItemData[j]["Image"].ToString();
                bundleItem.Description = BundleItemData[j]["Description"].ToString();
                bundleItem.Quality = int.Parse(BundleItemData[j]["Quality"].ToString());

                JsonData bundleItemDetailData = LitJson.JsonMapper.ToObject(BundleItemData[j]["Detail"].ToString());

                for (int k = 0; k < bundleItemDetailData.Count; k++)
                {
                    BundleItemDetails bundleDetails = new BundleItemDetails();
                    bundleDetails.BundleDetailName = bundleItemDetailData[k]["Name"].ToString();
                    bundleDetails.Value = int.Parse(bundleItemDetailData[k]["Value"].ToString());

                    bundleItem.bundleItemDetails.Add(bundleDetails);
                }

                itemBundle.bundleItems.Add(bundleItem);
            }

            ItemBundles.Add(itemBundle);
        }

        return ItemBundles;
    }
Beispiel #30
0
    IEnumerator     UpdateAllBundle()
    {
        //if(!updating)
        {
            string xml_version = "";
            if (version.Length == 0)
            {
                string svnVersion = AppVersion()["versionName"].Split('.')[3];

                if (Application.platform == RuntimePlatform.Android)
                {
                    version = "0/";
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    version = "10/";
                }
                else if (Application.platform == RuntimePlatform.WP8Player)
                {
                    version = "20/";
                }
                else if (Application.platform == RuntimePlatform.WindowsEditor)
                {
#if UNITY_ANDROID
                    version = "0/";
#endif

#if UNITY_IPHONE
                    version = "10/";
#endif
                }

                version    += svnVersion + "/";
                xml_version = svnVersion;
            }

            cdnIndex = 0;


            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            string url     = GetServer() + "bundleinfo.xml" + xml_version;
            byte[] xmlData = null;
            if (InternalNetDebug)
            {
                xmlData = File.ReadAllBytes(url);
            }
            else
            {
                string bundleInfo = "";
                while (true)
                {
                    long[] velocity = new long[cdn.Length];
                    for (int i = 0; i < cdn.Length; i++)
                    {
                        url = GetServer() + "bundleinfo.xml" + xml_version;
                        Debug.Log(url);
                        System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                        watch.Start();
                        wwwPercent = new WWW(url);
                        yield return(wwwPercent);

                        if (wwwPercent.error != null)
                        {
                            velocity[i] = -1;
                            Debug.Log(wwwPercent.error);
                        }
                        else
                        {
                            bundleInfo = wwwPercent.text;
                            watch.Stop();
                            velocity[i] = watch.ElapsedTicks;
                        }
                        ChangeCDN();
                    }
                    bool bValid = false;
                    long last   = long.MaxValue;
                    for (int i = 0; i < cdn.Length; i++)
                    {
                        if (velocity[i] != -1 && velocity[i] < last)
                        {
                            last     = velocity[i];
                            cdnIndex = i;
                            bValid   = true;
                        }
                    }
                    if (!bValid)
                    {
                        sdUICharacter.Instance.ShowLoginMsg("Can't Get Resource Version Information,Retry in 5 Second Later");
                        yield return(new WaitForSeconds(5.0f));
                    }
                    else
                    {
                        sdUICharacter.Instance.HideLoginMsg();
                        break;
                    }
                }

                Debug.Log("parse server bundleinfo.xml ");

                xmlData    = wwwPercent.bytes;
                wwwPercent = null;
            }

            byte[] buffer = new byte[1024 * 1024];

            MemoryStream dst = new MemoryStream(buffer, true);
            MemoryStream src = new MemoryStream(xmlData);
            SD.Decompress(src, dst);

            string csvContent = Encoding.ASCII.GetString(buffer, 0, (int)dst.Position);
            //Debug.Log(csvContent);

            string[] lines = csvContent.Split('\n');
            ParseBundleCSV(lines, ref bundles, bundleTable);


            Debug.Log("load local bundleinfo.xml");
            //加载本地xml..
            //System.Xml.XmlDocument docLocal =new System.Xml.XmlDocument();
            Hashtable downloadBundle = new Hashtable();
            try
            {
                if (File.Exists(LocalPath + "bundleinfo.txt"))
                {
                    //docLocal.Load(local+"bundleinfo.xml");
                    StreamReader r = File.OpenText(LocalPath + "bundleinfo.txt");
                    while (!r.EndOfStream)
                    {
                        string line = r.ReadLine();
                        if (line.Length > 0)
                        {
                            string[] strElement = line.Split(',');
                            downloadBundle[strElement[0]] = uint.Parse(strElement[1]);
                        }
                        //localContent	 = docLocal.SelectSingleNode("Bundles");
                    }
                    r.Close();
                }
            }catch (System.Exception e)
            {
                Debug.Log(e.Message + "load xml failed!");
                //root1=null;
            }

            BundleGlobalItem[] updateBundles = null;
            strVersionFile = "";
            if (downloadBundle.Count > 0)
            {
                Debug.Log("delete unused bundle");
                //删除上个版本中(不在这个版本中)的文件..
                //BundleItem[] oldBundle	=	null;
                //Hashtable oldTable		=	new Hashtable();
                //ParseXmlBundle(root1,ref oldBundle,oldTable);



                Debug.Log("Last Bundle Count = " + downloadBundle.Count);
                //Debug.Log("Current Bundle Count = " + BundleIndex.Count);
                foreach (DictionaryEntry de in downloadBundle)
                {
                    string name = de.Key  as string;
                    uint   ver  = (uint)de.Value;
                    //Debug.Log("Compare Bundle Index ["+item.bundlePath+"]");
                    if (!bundleTable.ContainsKey(name))
                    {
                        string strLocalPath = FixedPath(name);
                        Debug.Log("delete bundle " + name + ver);
                        File.Delete(strLocalPath);
                        if (File.Exists(strLocalPath))
                        {
                            Debug.Log("delete bundle Failed! " + strLocalPath);
                        }
                    }
                    else
                    {
                        //Debug.Log("bundle is exist! "+item.bundlePath + item.version);
                    }
                }


                Debug.Log("find bundle need for update");
                List <BundleGlobalItem> lstDownload = new List <BundleGlobalItem>();
                //判断是否需要更新文件..
                for (int i = 0; i < bundles.Length; i++)
                {
                    BundleGlobalItem item = bundles[i];
                    if (item == null)
                    {
                        continue;
                    }
                    if (!downloadBundle.ContainsKey(item.itemInfo.bundlePath))
                    {
                        lstDownload.Add(item);
                    }
                    else
                    {
                        uint ver = (uint)downloadBundle[item.itemInfo.bundlePath];
                        if (ver != item.itemInfo.version)
                        {
                            lstDownload.Add(item);
                            continue;
                        }

                        if (!File.Exists(FixedPath(item.itemInfo.bundlePath)))
                        {
                            lstDownload.Add(item);
                            continue;
                        }
                        strVersionFile += item.itemInfo.bundlePath + "," + item.itemInfo.version + ",\r\n";
                    }
                }
                SaveVersion(strVersionFile);

                Debug.Log("update some bundle = " + lstDownload.Count);

                updateBundles = lstDownload.ToArray();
            }
            else
            {
                Debug.Log("update all bundle" + bundles.Length);
                updateBundles = bundles;
            }
            if (updateBundles != null)
            {
                Thread UnCompressThread = new Thread(new ThreadStart(UnCompressMain));
                UnCompressThread.Start();


                for (int i = 0; i < updateBundles.Length;)
                {
                    OnDownload(i, updateBundles.Length);
                    BundleGlobalItem item = updateBundles[i];
                    Debug.Log("download bundle " + item.itemInfo.bundlePath);
                    //guiText.text	=	i+"/"+BundleInfoArray.Length;
                    //Download(BundleInfoArray[i]);

                    string bundleurl  = GetServer() + item.itemInfo.bundlePath.Replace("$", "__") + item.itemInfo.version.ToString();
                    byte[] bundleData = null;
                    if (InternalNetDebug)
                    {
                        yield return(0);

                        if (!File.Exists(bundleurl))
                        {
                            Debug.Log("Bundle Don't Exist! " + bundleurl);
                            i++;
                            continue;
                        }

                        bundleData = File.ReadAllBytes(bundleurl);
                    }
                    else
                    {
                        wwwPercent = new WWW(bundleurl);
                        yield return(wwwPercent);

                        if (wwwPercent.error != null)
                        {
                            Debug.Log(wwwPercent.error);
                            if (wwwPercent.error.Contains("FileNotFoundException") ||
                                wwwPercent.error.Contains("404: not found") ||
                                wwwPercent.error.Contains("404 Not Found"))
                            {
                                sdUICharacter.Instance.HideLoginMsg();
                                i++;
                            }
                            else
                            {
                                sdUICharacter.Instance.ShowLoginMsg(wwwPercent.error);
                                ChangeCDN();
                            }
                            wwwPercent = null;
                            continue;
                        }
                        else
                        {
                            //校验压缩之后的CRC是否匹配 不匹配则更换CDN 重新下载..
                            BundleItem iteminfo = item.itemInfo;
                            byte[]     data     = wwwPercent.bytes;
                            uint       comp_crc = SevenZip.CRC.CalculateDigest(data, 0, (uint)data.Length);
                            if (comp_crc != iteminfo.compress_crc)
                            {
                                Debug.Log(iteminfo.bundlePath + " compress_crc doesn't match " + comp_crc + " " + iteminfo.compress_crc);
                                sdUICharacter.Instance.ShowLoginMsg("crc doesn't match,download again!");
                                ChangeCDN();
                                continue;
                            }
                            else
                            {
                                sdUICharacter.Instance.HideLoginMsg();
                            }
                        }
                        bundleData = wwwPercent.bytes;
                    }

                    SaveFileAsync(bundleData, item);

                    wwwPercent = null;

                    i++;
                }
            }

            ExitUnCompress = true;
            while (true)
            {
                if (ExitUnCompress)
                {
                    yield return(0);
                }
                else
                {
                    break;
                }
            }

            Debug.Log("update finished!");

            OnDownloadFinished();
        }
        StartCoroutine(updateLoad());
    }
        private RequireBundles GetBundles(JObject document)
        {
            var bundles = new RequireBundles();

            bundles.BundleEntries = new List <RequireBundle>();
            string parseSection = "bundles";

            if (document != null && document[parseSection] != null)
            {
                JToken bundlesParent = JsonParseOrThrow <JObject>(document[parseSection], parseSection, Path, null);
                bundles.BundleEntries = bundlesParent.Select(
                    r =>
                {
                    var bundle              = new RequireBundle();
                    var prop                = (JProperty)r;
                    bundle.Name             = prop.Name;
                    string parseSectionHint = $"{parseSection}.{prop.Name}";
                    if (prop.Value is JArray)
                    {
                        bundle.IsVirtual   = false;
                        JArray arr         = JsonParseOrThrow <JArray>(prop.Value, parseSectionHint, Path, null);
                        bundle.BundleItems = arr.Select(x => new BundleItem {
                            ModuleName = x.ToString()
                        }).ToList();
                    }
                    else if (prop.Value is JObject)
                    {
                        var obj           = prop.Value as JObject;
                        bundle.OutputPath = JsonParseStringOrThrow(obj, "outputPath", parseSectionHint, Path);
                        JArray inclArr    = JsonParseArrayOrThrow(obj, "includes", parseSectionHint, Path);
                        if (inclArr != null)
                        {
                            bundle.Includes = inclArr.Select(x => x.ToString()).ToList();
                        }

                        JArray itemsArr = JsonParseArrayOrThrow(obj, "items", parseSectionHint, Path);
                        if (itemsArr != null)
                        {
                            string parseSectionHint2 = $"{parseSectionHint}.items";
                            bundle.BundleItems       = itemsArr.Select(
                                x =>
                            {
                                var result = new BundleItem();
                                if (x is JObject)
                                {
                                    result.ModuleName      = JsonParseStringOrThrow(x as JObject, "path", parseSectionHint2, Path);
                                    result.CompressionType = JsonParseStringOrThrow(x as JObject, "compression", parseSectionHint2, Path);
                                }
                                else if (x is JValue && x.Type == JTokenType.String)
                                {
                                    result.ModuleName = x.ToString();
                                }

                                return(result);
                            }).ToList();
                        }

                        var isVirtual = obj["virtual"];
                        if (isVirtual != null && !(isVirtual is JValue))
                        {
                            throw new JsonReaderException($"Element 'virtual' in {parseSectionHint} is expected to be 'JValue'; found instead: '{isVirtual.GetType()}'. Value: {isVirtual}");
                        }
                        bundle.IsVirtual = isVirtual is JValue &&
                                           isVirtual.Type == JTokenType.Boolean &&
                                           (bool)((JValue)isVirtual).Value;
                    }

                    return(bundle);
                })
                                        .ToList();
            }

            return(bundles);
        }
Beispiel #32
0
        private RequireBundles GetBundles(JObject document)
        {
            var bundles = new RequireBundles();

            bundles.BundleEntries = new List <RequireBundle>();
            if (document != null && document["bundles"] != null)
            {
                bundles.BundleEntries = document["bundles"].Select(
                    r =>
                {
                    var bundle  = new RequireBundle();
                    var prop    = (JProperty)r;
                    bundle.Name = prop.Name;
                    if (prop.Value is JArray)
                    {
                        bundle.IsVirtual   = false;
                        var arr            = prop.Value as JArray;
                        bundle.BundleItems = arr.Select(x => new BundleItem {
                            ModuleName = x.ToString()
                        }).ToList();
                    }
                    else if (prop.Value is JObject)
                    {
                        var obj           = prop.Value as JObject;
                        bundle.OutputPath = obj["outputPath"] != null ? obj["outputPath"].ToString() : null;
                        var inclArr       = obj["includes"] as JArray;
                        if (inclArr != null)
                        {
                            bundle.Includes = inclArr.Select(x => x.ToString()).ToList();
                        }

                        var itemsArr = obj["items"] as JArray;
                        if (itemsArr != null)
                        {
                            bundle.BundleItems = itemsArr.Select(
                                x =>
                            {
                                var result = new BundleItem();
                                if (x is JObject)
                                {
                                    result.ModuleName      = x["path"] != null ? x["path"].ToString() : null;
                                    result.CompressionType = x["compression"] != null ? x["compression"].ToString() : null;
                                }
                                else if (x is JValue && x.Type == JTokenType.String)
                                {
                                    result.ModuleName = x.ToString();
                                }

                                return(result);
                            }).ToList();
                        }

                        var isVirtual    = obj["virtual"];
                        bundle.IsVirtual = isVirtual is JValue &&
                                           isVirtual.Type == JTokenType.Boolean &&
                                           (bool)((JValue)isVirtual).Value;
                    }

                    return(bundle);
                })
                                        .ToList();
            }

            return(bundles);
        }