Esempio n. 1
0
        /// <summary>
        /// Loads an asset.
        /// </summary>
        /// <param name="asset">The Asset.</param>
        /// <param name="type">The Type.</param>
        /// <returns>IContent.</returns>
        private IContent Load(string asset, Type type)
        {
            IContent data;

            if (QueryCache(asset, type, out data))
            {
                return(data);
            }

            if (!File.Exists(Path.Combine(RootPath, asset)))
            {
                throw new ContentLoadException("Asset not found.");
            }

            data = ContentPipeline.ProcessDatatype(Path.Combine(RootPath, asset), type);
            ApplyCache(asset, data);

            return(data);
        }
Esempio n. 2
0
        /// <summary>
        /// Loads an asset.
        /// </summary>
        /// <typeparam name="T">The Type.</typeparam>
        /// <param name="asset">The Asset.</param>
        /// <returns>T.</returns>
        public T Load <T>(string asset) where T : IContent
        {
            //make the path valid if not
            asset = asset.Replace("/", @"\");

            //query content cache first.
            T data;

            if (QueryCache(asset, out data))
            {
                return(data);
            }

            if (!File.Exists(Path.Combine(RootPath, asset)))
            {
                throw new ContentLoadException("Asset not found.");
            }

            data = ContentPipeline.ProcessDatatype <T>(Path.Combine(RootPath, asset));
            ApplyCache(asset, data);

            return(data);
        }