Exemplo n.º 1
0
        public async Task <IAsset> GetUnresolved(string name)
        {
            var compiledAsset = await _compiledAssetFs.Get(name);

            if (compiledAsset == null)
            {
                throw new AssetNotFoundException(name);
            }
            using (var serializedAsset = ReadableSerializedAsset.FromStream(await compiledAsset.GetContentStream().ConfigureAwait(false), false))
            {
                var loaderType = serializedAsset.GetLoader();
                if (loaderType == null)
                {
                    throw new InvalidOperationException(
                              "Unable to load asset '" + name + "' because the loader type '" + serializedAsset.GetString("_Loader") + "' could not be resolved to a real type.");
                }
                IAssetLoader loaderInstance;
                try
                {
                    loaderInstance = (IAssetLoader)_kernel.Get(loaderType);
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException(
                              "Unable to load asset '" + name + "' because no suitable loader could be resolved.",
                              ex);
                }
                return(await loaderInstance.Load(name, serializedAsset, this).ConfigureAwait(false));
            }
        }
Exemplo n.º 2
0
            async Task <IReadableSerializedAsset> IAssetDependencies.GetOptionalCompileTimeCompiledDependency(string name)
            {
                // Always add the dependency, since the compiler will do different things if the dependency
                // appears on disk.
                _serializedAsset.AddCompilationDependency(name);

                var compiledAssetFile = await _compiledAssetFs.EnsureCompiled(await _compiledAssetFs._assetFs.Get(name).ConfigureAwait(false)).ConfigureAwait(false);

                if (compiledAssetFile == null)
                {
                    return(null);
                }
                return(ReadableSerializedAsset.FromStream(await compiledAssetFile.GetContentStream().ConfigureAwait(false), false));
            }
Exemplo n.º 3
0
            public async Task <string[]> GetDependentOnAssetFsFileNames()
            {
                if (_dependencies != null)
                {
                    return(_dependencies);
                }

                await _streamSemaphore.WaitAsync();

                try
                {
                    _stream.Seek(0, SeekOrigin.Begin);
                    using (var asset = ReadableSerializedAsset.FromStream(_stream, true))
                    {
                        _dependencies = asset.Dependencies.ToArray();
                    }
                    return(_dependencies);
                }
                finally
                {
                    _streamSemaphore.Release();
                }
            }