示例#1
0
        private void CollectBundle(ResolvedBundle resolvedBundle, string assetUrl, IAssetIndexMap assetIndexMap)
        {
            // Check if index map contains it already (that also means object id has been stored as well)
            if (resolvedBundle.DependencyIndexMap.ContainsKey(assetUrl) || resolvedBundle.IndexMap.ContainsKey(assetUrl))
            {
                return;
            }

            ObjectId objectId;

            if (!assetIndexMap.TryGetValue(assetUrl, out objectId))
            {
                throw new InvalidOperationException(string.Format("Could not find asset {0} for bundle {1}", assetUrl, resolvedBundle.Name));
            }

            // Add asset to index map
            resolvedBundle.IndexMap.Add(assetUrl, objectId);

            // Check if object id has already been added (either as dependency or inside this actual pack)
            // As a consequence, no need to check references since they will somehow be part of this package or one of its dependencies.
            if (resolvedBundle.DependencyObjectIds.Contains(objectId) || !resolvedBundle.ObjectIds.Add(objectId))
            {
                return;
            }

            foreach (var reference in GetChunkReferences(ref objectId))
            {
                CollectBundle(resolvedBundle, reference, assetIndexMap);
            }
        }
示例#2
0
        private void CollectReferences(Bundle bundle, HashSet <string> assets, string assetUrl, IAssetIndexMap assetIndexMap)
        {
            // Already included?
            if (!assets.Add(assetUrl))
            {
                return;
            }

            ObjectId objectId;

            if (!assetIndexMap.TryGetValue(assetUrl, out objectId))
            {
                throw new InvalidOperationException(string.Format("Could not find asset {0} for bundle {1}", assetUrl, bundle.Name));
            }

            // Include references
            foreach (var reference in GetChunkReferences(ref objectId))
            {
                CollectReferences(bundle, assets, reference, assetIndexMap);
            }
        }