Example #1
0
 public ProxyAsset(string identifier, object config, string contentSha, AssetMemoryManager storage)
 {
     Identifier    = identifier;
     Configuration = config;
     _contentSha   = contentSha;
     _storage      = storage;
 }
Example #2
0
        public static async Task <IEnumerable <IProxyAsset> > FetchOrCreate(
            this IBuildCache cache,
            string pipeline, AssetMemoryManager mem, AssetSource source,
            Func <AssetSource, Task <IEnumerable <IProxyAsset> > > build)
        {
            var cacheKey = BuildCache.ComputeCacheKey(pipeline, source);

            while (true)
            {
                var cached = await cache.Fetch(cacheKey);

                if (cached.Type == CacheResult.Cached)
                {
                    var cachedAssets = await Task.WhenAll(cached.Assets.Select(mem.DeserializeProxy));

                    if (cachedAssets.All(a => a != null))
                    {
                        return(cachedAssets);
                    }
                }

                if (cached.Type == CacheResult.IncompleteKey)
                {
                    cacheKey = BuildCache.ComputeCacheKey(pipeline, source, cached.MissingInputs);
                }
                else
                {
                    break;
                }
            }

            var assets = (await build(source)).ToList();

            var extraFiles        = new string[0]; //TODO: record extra input files
            var serializedProxies = assets.Select(mem.SerializeProxy).ToList();

            if (extraFiles.Length == 0)
            {
                await cache.Store(cacheKey, CacheRecord.Found(serializedProxies));
            }
            else
            {
                await cache.Store(cacheKey, CacheRecord.Incomplete(extraFiles));

                await cache.Store(BuildCache.ComputeCacheKey(pipeline, source, extraFiles),
                                  CacheRecord.Found(serializedProxies));
            }

            return(assets);
        }
Example #3
0
 public IProxyAsset ConstructProxy(AssetMemoryManager mem) => new ProxyAsset <T>(this, mem);
Example #4
0
 public ProxyAsset(ProxyMeta <T> meta, AssetMemoryManager storage)
     : this(meta.Identifier, meta.Configuration, meta.ContentSha, storage)
 {
 }