Пример #1
0
 public AssetNotLoadedException(Type type, string path, IAssetLoaderParameters param = null)
     : base(string.Format("Asset not loaded: '{0}' ({1})", path, type))
 {
     this.Type   = type;
     this.Path   = path;
     this.Params = param;
 }
Пример #2
0
        /// <summary>
        /// Returns the asset associated with the specified path.
        /// Throws an AssetNotLoadedException if no asset is found.
        /// </summary>
        public T Get <T>(string path, IAssetLoaderParameters param = null)
        {
            Type type = typeof(T);

            if (type == null)
            {
                throw new AssetNotLoadedException(typeof(T), path);
            }

            using (Key.Lock(assets)) {
                IReferencedObject ro = assets.Get(new AssetDescriptor(type, path, param), null);
                if (ro == null)
                {
                    throw new AssetNotLoadedException(typeof(T), path);
                }

                object result = ro.Asset;
                if (result == null)
                {
                    throw new AssetNotLoadedException(typeof(T), path);
                }

                return((T)result);
            }
        }
Пример #3
0
        //
        // Methods used to schedule the loading of an asset, or immediate unloading thereof.
        //
        #region Load / Unload Methods

        /// <summary>
        /// Schedules the specified asset for loading. The request will not be processed
        /// until Update() is called.
        /// </summary>
        public void Load <T>(string path, IAssetLoaderParameters param = null)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            Load(new AssetDescriptor(typeof(T), path, param));
        }
Пример #4
0
 public static AssetDescriptor Create <T>(string path, IAssetLoaderParameters param = null)
 {
     if (path != null)
     {
         path = path.Replace("\\", "/");
     }
     return(new AssetDescriptor(typeof(T), path, param));
 }
Пример #5
0
 public AssetDescriptor(Type type, string path, IAssetLoaderParameters param = null)
 {
     if (path != null)
     {
         path = path.Replace("\\", "/");
     }
     Type   = type;
     Path   = path;
     Params = param;
 }
Пример #6
0
        public bool IsLoaded(Type type, string path, IAssetLoaderParameters param = null)
        {
            if (type == null || path == null)
            {
                return(false);
            }

            using (Key.Lock(assets)) {
                return(assets.ContainsKey(new AssetDescriptor(type, path)));
            }
        }
Пример #7
0
 /// <summary>
 /// Schedules the specified asset for loading. The request will not be processed
 /// until Update() is called.
 /// </summary>
 public void Load(Type type, string path, IAssetLoaderParameters param = null)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     Load(new AssetDescriptor(type, path, param));
 }
Пример #8
0
        public int GetRefCount <T>(string path, IAssetLoaderParameters param = null)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            using (Key.Lock(assets)) {
                AssetDescriptor desc = AssetDescriptor.Create <T>(path, param);
                if (assets.ContainsKey(desc))
                {
                    return(assets[desc].RefCount);
                }

                return(0);
            }
        }
Пример #9
0
 /// <summary>
 /// Unloads the asset associated with the specified path.
 /// If there are no references left to the asset, it is removed and destroyed, if needed.
 /// </summary>
 public void Unload <T>(string path, IAssetLoaderParameters param = null)
 {
     Unload(new AssetDescriptor(typeof(T), path, param));
 }
Пример #10
0
 /// <summary>
 /// Unloads the asset associated with the specified path.
 /// If there are no references left to the asset, it is removed and destroyed, if needed.
 /// </summary>
 public void Unload(Type type, string path, IAssetLoaderParameters param = null)
 {
     Unload(new AssetDescriptor(type, path, param));
 }
Пример #11
0
 public abstract object LoadSync( AssetManager manager, string path, FileInfo fileHandle, IAssetLoaderParameters param );
Пример #12
0
 public abstract object LoadSync(AssetManager manager, string path, FileInfo fileHandle, IAssetLoaderParameters param);
Пример #13
0
 /// <param name="fileName">Name of the asset to load</param>
 /// <param name="fileHandle">The resolved file to load</param>
 /// <param name="param">parameters for loading the asset</param>
 public abstract List <AssetDescriptor> GetDependencies(AssetManager manager, string fileName, FileInfo fileHandle, IAssetLoaderParameters param);