예제 #1
0
        /// <summary>
        /// Creates a new package instance
        /// </summary>
        public PackageMeta()
        {
            this.dependencies = CollectionPool <Dictionary <PackageId, PackageVersion>, PackageId, PackageVersion> .Get();

            this.references = CollectionPool <Dictionary <PackageId, PackageVersion>, PackageId, PackageVersion> .Get();

            this.platform = CollectionPool <HashSet <string>, string> .Get();

            this.architecture = CollectionPool <HashSet <PlatformTarget>, PlatformTarget> .Get();

            this.files = CollectionPool <HashSet <string>, string> .Get();

            this.tags = CollectionPool <HashSet <string>, string> .Get();

            this.maintainer = CollectionPool <HashSet <Identity>, Identity> .Get();

            this.events = CollectionPool <Dictionary <string, string>, string, string> .Get();

            this.parameter = CollectionPool <Dictionary <string, string>, string, string> .Get();
        }
        public bool TryParseValue(Type targetType, object value, out object result)
        {
            JsonNode node = (value as JsonNode);

            if (node != null && node.Type == JsonNodeType.Object)
            {
                Type[]   genericArgs = targetType.GetGenericArguments();
                Type     functorType = typeof(Func <, ,>).MakeGenericType(genericArgs[0], genericArgs[1], targetType);
                Delegate creator     = functorType.GetCreator(targetType);

                List <object> items = CollectionPool <List <object>, object> .Get();

                try
                {
                    node = node.Child;
                    while (node != null)
                    {
                        if (node.Type > JsonNodeType.Array)
                        {
                            object k, v; if (node.Name.TryCast(genericArgs[0], out k) && k != null && node.RawValue.TryCast(genericArgs[1], out v) && v != null)
                            {
                                items.Add(creator.DynamicInvoke(k, v));
                            }
                        }
                        node = node.Next;
                    }
                    result = items.ToArray();
                    return(true);
                }
                finally
                {
                    CollectionPool <List <object>, object> .Return(items);
                }
            }
            else
            {
                result = null;
                return(false);
            }
        }
예제 #3
0
        void AddLodingTask <T>(
            AssetEntryRecord assetEntryRecord,
            FixedList <AssetBundleRecord> necessaryAssetBundleRecords,
            Action <T> onLoaded,
            Func <AssetBundle, AssetEntryRecord, AssetBundleRequest> getAssetBundleRequestFunc,
            Func <AssetBundleRequest, T> getAssetFunc)
        {
            if (isDestroyed)
            {
                return;
            }

            int         loadingTaskId      = loadingTaskIdGenerator.Get();
            IEnumerator getAssetEnumerator = GetAsset(
                loadingTaskId,
                assetEntryRecord,
                necessaryAssetBundleRecords,
                onLoaded,
                getAssetBundleRequestFunc,
                getAssetFunc);
            var loadingTask = new LoadingTask(necessaryAssetBundleRecords, getAssetEnumerator);

            loadingTasks.Add(loadingTaskId, loadingTask);

            foreach (AssetBundleRecord assetBundleRecord in necessaryAssetBundleRecords)
            {
                string        assetBundleName = assetBundleRecord.AssetBundleName;
                HashSet <int> taskIds;
                if (!loadingTaskIdSets.TryGetValue(assetBundleName, out taskIds))
                {
                    taskIds = intHashSetPool.Get();
                    loadingTaskIdSets.Add(assetBundleName, taskIds);
                }

                taskIds.Add(loadingTaskId);
            }

            if (loadingTask.NecessaryAssetBundleRecords.All(r => loadedAssetBundles.ContainsKey(r.AssetBundleName)))
            {
                coroutineOwner.Run(loadingTask.GetAssetEnumerator);
                return;
            }

            foreach (AssetBundleRecord assetBundleRecord in loadingTask.NecessaryAssetBundleRecords)
            {
                string assetBundleName = assetBundleRecord.AssetBundleName;

                if (loadedAssetBundles.ContainsKey(assetBundleName))
                {
                    continue;
                }

                if (loadingAssetBundleRecords.ContainsKey(assetBundleName))
                {
                    continue;
                }

                loadingAssetBundleRecords.Add(assetBundleName, assetBundleRecord);
                storageChecker.Load(assetBundleRecord, onAssetBundleLoaded);
            }
        }