Example #1
0
 /// <summary>
 /// Resources cache
 /// </summary>
 /// <param name="source"></param>
 /// <param name="options"></param>
 public AssetCachePartResources(IAsset source, AssetCacheOptions options)
 {
     this.Source   = source ?? throw new ArgumentNullException(nameof(source));
     this.Options  = options ?? throw new ArgumentNullException(nameof(options));
     this.comparer = LineComparer.Default;
     this.cache    = new Cache(comparer);
 }
Example #2
0
        /// <summary>
        /// Get options for cache streams
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static bool GetCacheStreams(this AssetCacheOptions options)
        {
            object value;

            if (options.TryGetValue(Key_CacheStreams, out value) && value is bool _value)
            {
                return(_value);
            }
            return(true);
        }
Example #3
0
        /// <summary>
        /// Get maximum resource total size option
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static int GetMaxResourceTotalSize(this AssetCacheOptions options)
        {
            object value;

            if (options.TryGetValue(Key_MaxResourceTotalSize, out value) && value is int _value)
            {
                return(_value);
            }
            return(1024 * 1024);
        }
Example #4
0
        /// <summary>
        /// Get maximum resource option
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static int GetMaxResourceCount(this AssetCacheOptions options)
        {
            object value;

            if (options.TryGetValue(Key_MaxResourceCount, out value) && value is int _value)
            {
                return(_value);
            }
            return(Int32.MaxValue);
        }
Example #5
0
 /// <summary>
 /// Create new asset cache.
 /// </summary>
 /// <param name="source">The source asset whose reuqests are cached.</param>
 /// <param name="cacheParts">parts that handle interface specific properties, such as <see cref="AssetCachePartResources"/>, AssetStringsCachePart and AssetCulturesCachePart</param>
 public AssetCache(IAsset source, IEnumerable <IAssetCachePart> cacheParts) : base(cacheParts)
 {
     Options            = new AssetCacheOptions();
     Source             = source ?? throw new ArgumentNullException(nameof(source));
     this.disposeSource = true;
 }
Example #6
0
 /// <summary>
 /// Create new asset cache.
 /// </summary>
 /// <param name="source">The source asset whose reuqests are cached.</param>
 /// <param name="cacheParts">parts that handle interface specific properties, such as <see cref="AssetCachePartResources"/>, AssetStringsCachePart and AssetCulturesCachePart</param>
 /// <param name="disposeSource">Disposes <paramref name="source"/> along with cache</param>
 public AssetCache(IAsset source, bool disposeSource = true, params IAssetCachePart[] cacheParts) : base(cacheParts)
 {
     Options            = new AssetCacheOptions();
     Source             = source ?? throw new ArgumentNullException(nameof(source));
     this.disposeSource = disposeSource;
 }
Example #7
0
 /// <summary>
 /// Create new asset cache.
 /// </summary>
 /// <param name="source">The source asset whose requests are cached.</param>
 /// <param name="disposeSource">Disposes <paramref name="source"/> along with cache</param>
 public AssetCache(IAsset source, bool disposeSource = true)
 {
     Options            = new AssetCacheOptions();
     Source             = source ?? throw new ArgumentNullException(nameof(source));
     this.disposeSource = disposeSource;
 }
Example #8
0
 /// <summary>
 /// Create part that caches cultures.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="options"></param>
 public AssetCachePartCultures(IAsset source, AssetCacheOptions options)
 {
     this.Source  = source ?? throw new ArgumentNullException(nameof(source));
     this.Options = options ?? throw new ArgumentNullException(nameof(options));
 }
Example #9
0
 /// <summary>
 /// Set option for cache streams
 /// </summary>
 /// <param name="options"></param>
 /// <param name="newValue"></param>
 /// <returns></returns>
 public static AssetCacheOptions SetCacheStreams(this AssetCacheOptions options, bool newValue)
 {
     options.Set <bool>(Key_CacheStreams, newValue);
     return(options);
 }
Example #10
0
 /// <summary>
 /// Set maximum resource total size
 /// </summary>
 /// <param name="options"></param>
 /// <param name="newValue"></param>
 /// <returns></returns>
 public static AssetCacheOptions SetMaxResourceTotalSize(this AssetCacheOptions options, int newValue)
 {
     options.Set <int>(Key_MaxResourceTotalSize, newValue);
     return(options);
 }
Example #11
0
 /// <summary>
 /// Set whether cache should create clones of keys, or whether to use the keys that come from requests in its cache structures.
 /// </summary>
 /// <param name="options"></param>
 /// <param name="cloneKeys"></param>
 /// <returns></returns>
 public static AssetCacheOptions SetCloneKeys(this AssetCacheOptions options, bool cloneKeys)
 {
     options.Set <bool>(Key_CloneKeys, cloneKeys);
     return(options);
 }