Пример #1
0
        public SettingViewModel(IDiskCache diskCache, IAppToastService appToastService)
        {
            _diskCache       = diskCache;
            _appToastService = appToastService;

            Initialize();
        }
Пример #2
0
        private static void InitializeIfNeeded(int maxCacheSize           = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
                                               IDiskCache diskCache       = null, IDownloadCache downloadCache = null, bool loadWithTransparencyChannel = false, bool fadeAnimationEnabled = true,
                                               bool transformPlaceholders = true, InterpolationMode downsampleInterpolationMode = InterpolationMode.Default, int httpHeadersTimeout = HttpHeadersTimeout, int httpReadTimeout = HttpReadTimeout
                                               )
        {
            if (_initialized)
            {
                return;
            }

            lock (_initializeLock)
            {
                if (_initialized)
                {
                    return;
                }

                var userDefinedConfig = new Configuration(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache,
                                                          loadWithTransparencyChannel, fadeAnimationEnabled, transformPlaceholders, downsampleInterpolationMode,
                                                          httpHeadersTimeout, httpReadTimeout);
                Config = GetDefaultConfiguration(userDefinedConfig);

                _initialized = true;
            }
        }
Пример #3
0
 public SpriteHolder(IDiskCache dc)
 {
     this._dc    = dc;
     _placer     = new Sprite2dPlacer();
     _allSprites = new List <SourceInfo.Sprite>();
     _newSprites = new List <SourceInfo.Sprite>();
 }
Пример #4
0
        private const int BufferSize = 4096;         // Xamarin large object heap threshold is 8K

        public DownloadCache(HttpClient httpClient, IDiskCache diskCache, TimeSpan diskCacheDuration)
        {
            DownloadHttpClient = httpClient;
            _md5Helper         = new MD5Helper();
            _diskCache         = diskCache;
            _diskCacheDuration = diskCacheDuration;
        }
Пример #5
0
        public static TSProject?Create(IDirectoryCache?dir, IDiskCache diskCache, ILogger logger, string?diskName, bool virtualProject = false)
        {
            if (dir == null)
            {
                return(null);
            }
            if (dir.Project != null)
            {
                return((TSProject)dir.Project);
            }
            var proj = new TSProject
            {
                Owner          = dir,
                DiskCache      = diskCache,
                Logger         = logger,
                Name           = diskName,
                Valid          = true,
                ProjectOptions = new ProjectOptions()
            };

            proj.Virtual = virtualProject;
            proj.ProjectOptions.Owner = proj;
            if (virtualProject)
            {
                proj.ProjectOptions.FillProjectOptionsFromPackageJson(null);
            }
            else
            {
                dir.Project = proj;
            }

            return(proj);
        }
Пример #6
0
 void RecursiveFileSearch(IDirectoryCache owner, IDiskCache diskCache, Regex fileRegex, List <string> res)
 {
     diskCache.UpdateIfNeeded(owner);
     if (owner.IsInvalid)
     {
         return;
     }
     foreach (var item in owner)
     {
         if (item is IDirectoryCache)
         {
             if (item.Name == "node_modules")
             {
                 continue;
             }
             if (item.IsInvalid)
             {
                 continue;
             }
             RecursiveFileSearch(item as IDirectoryCache, diskCache, fileRegex, res);
         }
         else if (item is IFileCache && !item.IsVirtual)
         {
             if (fileRegex.IsMatch(item.Name))
             {
                 res.Add(item.FullPath);
             }
         }
     }
 }
Пример #7
0
 public SpriteHolder(IDiskCache dc, ILogger logger)
 {
     _dc         = dc;
     _logger     = logger;
     _placer     = new Sprite2dPlacer();
     _allSprites = new List <OutputSprite>();
     _newSprites = new List <OutputSprite>();
 }
Пример #8
0
 public Configuration(int maxCacheSize     = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
                      IDiskCache diskCache = null, IDownloadCache downloadCache = null)
 {
     MaxCacheSize  = maxCacheSize;
     HttpClient    = httpClient;
     Scheduler     = scheduler;
     Logger        = logger;
     DiskCache     = diskCache;
     DownloadCache = downloadCache;
 }
Пример #9
0
 public static TSFileAdditionalInfo Create(IFileCache file, IDiskCache diskCache)
 {
     if (file == null)
     {
         return(null);
     }
     return(new TSFileAdditionalInfo {
         Owner = file, DiskCache = diskCache
     });
 }
Пример #10
0
        /// <summary>
        /// Initialize ImageService default values. This can only be done once: during app start.
        /// </summary>
        /// <param name="maxCacheSize">Max cache size. If zero then 20% of the memory will be used.</param>
        /// <param name="httpClient">.NET HttpClient to use. If null then a ModernHttpClient is instanciated.</param>
        /// <param name="scheduler">Work scheduler used to organize/schedule loading tasks.</param>
        /// <param name="logger">Basic logger. If null a very simple implementation that prints to console is used.</param>
        /// <param name="diskCache">Disk cache. If null a default disk cache is instanciated that uses a journal mechanism.</param>
        /// <param name="downloadCache">Download cache. If null a default download cache is instanciated, which relies on the DiskCache</param>
        public static void Initialize(int maxCacheSize = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
            IDiskCache diskCache = null, IDownloadCache downloadCache = null)
        {
            lock (_initializeLock)
            {
                if (_initialized)
                    throw new Exception("FFImageLoading.ImageService is already initialized");
            }

            InitializeIfNeeded(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache);
        }
Пример #11
0
        public static void Initialize(int?maxCacheSize           = null, HttpClient httpClient        = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
                                      IDiskCache diskCache       = null, IDownloadCache downloadCache = null, bool?loadWithTransparencyChannel = null, bool?fadeAnimationEnabled = null,
                                      bool?transformPlaceholders = null, InterpolationMode?downsampleInterpolationMode = null, int httpHeadersTimeout = 15, int httpReadTimeout  = 30
                                      )
        {
            var cfg = new Configuration();

            if (httpClient != null)
            {
                cfg.HttpClient = httpClient;
            }
            if (scheduler != null)
            {
                cfg.Scheduler = scheduler;
            }
            if (logger != null)
            {
                cfg.Logger = logger;
            }
            if (diskCache != null)
            {
                cfg.DiskCache = diskCache;
            }
            if (downloadCache != null)
            {
                cfg.DownloadCache = downloadCache;
            }
            if (loadWithTransparencyChannel.HasValue)
            {
                cfg.LoadWithTransparencyChannel = loadWithTransparencyChannel.Value;
            }
            if (fadeAnimationEnabled.HasValue)
            {
                cfg.FadeAnimationEnabled = fadeAnimationEnabled.Value;
            }
            if (transformPlaceholders.HasValue)
            {
                cfg.TransformPlaceholders = transformPlaceholders.Value;
            }
            if (downsampleInterpolationMode.HasValue)
            {
                cfg.DownsampleInterpolationMode = downsampleInterpolationMode.Value;
            }
            cfg.HttpHeadersTimeout = httpHeadersTimeout;
            cfg.HttpReadTimeout    = httpReadTimeout;
            if (maxCacheSize.HasValue)
            {
                cfg.MaxCacheSize = maxCacheSize.Value;
            }

            Initialize(cfg);
        }
Пример #12
0
        /// <summary>
        /// Initialize ImageService default values. This can only be done once: during app start.
        /// </summary>
        /// <param name="maxCacheSize">Max cache size. If zero then 20% of the memory will be used.</param>
        /// <param name="httpClient">.NET HttpClient to use. If null then a ModernHttpClient is instanciated.</param>
        /// <param name="scheduler">Work scheduler used to organize/schedule loading tasks.</param>
        /// <param name="logger">Basic logger. If null a very simple implementation that prints to console is used.</param>
        /// <param name="diskCache">Disk cache. If null a default disk cache is instanciated that uses a journal mechanism.</param>
        /// <param name="downloadCache">Download cache. If null a default download cache is instanciated, which relies on the DiskCache</param>
        public static void Initialize(int maxCacheSize     = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
                                      IDiskCache diskCache = null, IDownloadCache downloadCache = null)
        {
            lock (_initializeLock)
            {
                if (_initialized)
                {
                    throw new Exception("FFImageLoading.ImageService is already initialized");
                }
            }

            InitializeIfNeeded(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache);
        }
Пример #13
0
     public static TSProject Get(IDirectoryCache dir, IDiskCache diskCache, ILogger logger)
     {
         if (dir == null)
         {
             return(null);
         }
         if (dir.AdditionalInfo == null)
         {
             dir.AdditionalInfo = new TSProject {
                 Owner = dir, DiskCache = diskCache, Logger = logger
             }
         }
         ;
         return((TSProject)dir.AdditionalInfo);
     }
 }
Пример #14
0
        public Configuration(int maxCacheSize, HttpClient httpClient, IWorkScheduler scheduler, IMiniLogger logger,
			IDiskCache diskCache, IDownloadCache downloadCache, bool loadWithTransparencyChannel, bool fadeAnimationEnabled,
			int httpHeadersTimeout, int httpReadTimeout
		)
        {
            MaxCacheSize = maxCacheSize;
            HttpClient = httpClient;
            Scheduler = scheduler;
            Logger = logger;
            DiskCache = diskCache;
            DownloadCache = downloadCache;
            LoadWithTransparencyChannel = loadWithTransparencyChannel;
            FadeAnimationEnabled = fadeAnimationEnabled;
            HttpHeadersTimeout = httpHeadersTimeout;
            HttpReadTimeout = httpReadTimeout;
        }
Пример #15
0
        public static TSProject?Create(IDirectoryCache?dir, IDiskCache diskCache, ILogger logger, string?diskName, bool virtualProject = false)
        {
            if (dir == null)
            {
                return(null);
            }
            if (dir.Project != null)
            {
                return((TSProject)dir.Project);
            }
            if (diskName == null)
            {
                if (dir.Parent?.Name.StartsWith("@") ?? false)
                {
                    diskName = dir.Parent.Name + "/" + dir.Name;
                }
                else
                {
                    diskName = dir.Name;
                }
            }

            var proj = new TSProject
            {
                Owner          = dir,
                DiskCache      = diskCache,
                Logger         = logger,
                Name           = diskName,
                Valid          = true,
                ProjectOptions = new(),
                Virtual        = virtualProject
            };

            proj.ProjectOptions.Owner = proj;
            if (virtualProject)
            {
                proj.ProjectOptions.FillProjectOptionsFromPackageJson(null, dir);
            }
            else
            {
                dir.Project = proj;
            }

            return(proj);
        }
Пример #16
0
        public Configuration(int maxCacheSize, HttpClient httpClient, IWorkScheduler scheduler, IMiniLogger logger,
			IDiskCache diskCache, IDownloadCache downloadCache, bool loadWithTransparencyChannel, bool fadeAnimationEnabled,
			bool transformPlaceholders, InterpolationMode downsampleInterpolationMode, int httpHeadersTimeout, int httpReadTimeout
		)
        {
            MaxCacheSize = maxCacheSize;
            HttpClient = httpClient;
            Scheduler = scheduler;
            Logger = logger;
            DiskCache = diskCache;
            DownloadCache = downloadCache;
			LoadWithTransparencyChannel = loadWithTransparencyChannel;
			FadeAnimationEnabled = fadeAnimationEnabled;
            TransformPlaceholders = transformPlaceholders;
			DownsampleInterpolationMode = downsampleInterpolationMode;
            HttpHeadersTimeout = httpHeadersTimeout;
			HttpReadTimeout = httpReadTimeout;
        }
Пример #17
0
 public Configuration(int maxCacheSize, HttpClient httpClient, IWorkScheduler scheduler, IMiniLogger logger,
                      IDiskCache diskCache, IDownloadCache downloadCache, bool loadWithTransparencyChannel, bool fadeAnimationEnabled,
                      bool transformPlaceholders, InterpolationMode downsampleInterpolationMode, int httpHeadersTimeout, int httpReadTimeout
                      )
 {
     MaxCacheSize  = maxCacheSize;
     HttpClient    = httpClient;
     Scheduler     = scheduler;
     Logger        = logger;
     DiskCache     = diskCache;
     DownloadCache = downloadCache;
     LoadWithTransparencyChannel = loadWithTransparencyChannel;
     FadeAnimationEnabled        = fadeAnimationEnabled;
     TransformPlaceholders       = transformPlaceholders;
     DownsampleInterpolationMode = downsampleInterpolationMode;
     HttpHeadersTimeout          = httpHeadersTimeout;
     HttpReadTimeout             = httpReadTimeout;
 }
Пример #18
0
        private static void InitializeIfNeeded(int maxCacheSize = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
			IDiskCache diskCache = null, IDownloadCache downloadCache = null, bool loadWithTransparencyChannel = false, bool fadeAnimationEnabled = true,
			int httpHeadersTimeout = HttpHeadersTimeout, int httpReadTimeout = HttpReadTimeout
		)
        {
			if (_initialized)
				return;

			lock (_initializeLock)
			{
				if (_initialized)
					return;
			
				var userDefinedConfig = new Configuration(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache, loadWithTransparencyChannel, fadeAnimationEnabled, httpHeadersTimeout, httpReadTimeout);
				Config = GetDefaultConfiguration(userDefinedConfig);

				_initialized = true;
			}
        }
Пример #19
0
        public static TSProject Get(IDirectoryCache dir, IDiskCache diskCache, ILogger logger, string diskName)
        {
            if (dir == null)
            {
                return(null);
            }
            if (dir.AdditionalInfo == null)
            {
                var proj = new TSProject
                {
                    Owner          = dir, DiskCache = diskCache, Logger = logger, Name = diskName,
                    ProjectOptions = new ProjectOptions()
                };
                proj.ProjectOptions.Owner = proj;
                dir.AdditionalInfo        = proj;
            }

            return((TSProject)dir.AdditionalInfo);
        }
Пример #20
0
        public static TSProject Create(IDirectoryCache dir, IDiskCache diskCache, ILogger logger, string diskName)
        {
            if (dir == null)
            {
                return(null);
            }
            var proj = new TSProject
            {
                Owner          = dir,
                DiskCache      = diskCache,
                Logger         = logger,
                Name           = diskName,
                Valid          = true,
                ProjectOptions = new ProjectOptions()
            };

            proj.ProjectOptions.Owner = proj;
            return(proj);
        }
Пример #21
0
            /// <summary>
            /// Creates a group.
            /// </summary>
            /// <param name="cache">The cache.</param>
            /// <param name="key">The cache group key.</param>
            /// <param name="location">The location of the cache group.</param>
            /// <exception cref="ArgumentNullException">Thrown if <paramref name="cache"/>,
            /// <paramref name="key"/> or <paramref name="location" /> is null.</exception>
            public Group(IDiskCache cache, string key, DirectoryInfo location)
            {
                if (cache == null)
                {
                    throw new ArgumentNullException("cache");
                }
                if (key == null)
                {
                    throw new ArgumentNullException("key");
                }
                if (location == null)
                {
                    throw new ArgumentNullException("location");
                }

                this.cache    = cache;
                this.key      = key;
                this.location = location;
            }
Пример #22
0
        /// <summary>
        /// Initialize ImageService default values. This can only be done once: during app start.
        /// </summary>
        /// <param name="maxCacheSize">Max cache size. If zero then 20% of the memory will be used.</param>
		/// <param name="httpClient">.NET HttpClient to use. If null then a.NET HttpClient is instanciated.</param>
        /// <param name="scheduler">Work scheduler used to organize/schedule loading tasks.</param>
        /// <param name="logger">Basic logger. If null a very simple implementation that prints to console is used.</param>
        /// <param name="diskCache">Disk cache. If null a default disk cache is instanciated that uses a journal mechanism.</param>
        /// <param name="downloadCache">Download cache. If null a default download cache is instanciated, which relies on the DiskCache</param>
		/// <param name="loadWithTransparencyChannel">Gets a value indicating whether images should be loaded with transparency channel. On Android we save 50% of the memory without transparency since we use 2 bytes per pixel instead of 4.</param>
		/// <param name="fadeAnimationEnabled">Defines if fading should be performed while loading images.</param>
        /// <param name="transformPlaceholders">Defines if transforms should be applied to placeholders.</param>
		/// <param name="downsampleInterpolationMode">Defines default downsample interpolation mode.</param>
		/// <param name="httpHeadersTimeout">Maximum time in seconds to wait to receive HTTP headers before the HTTP request is cancelled.</param>
		/// <param name="httpReadTimeout">Maximum time in seconds to wait before the HTTP request is cancelled.</param>
		public static void Initialize(int? maxCacheSize = null, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
			IDiskCache diskCache = null, IDownloadCache downloadCache = null, bool? loadWithTransparencyChannel = null, bool? fadeAnimationEnabled = null,
			bool? transformPlaceholders = null, InterpolationMode? downsampleInterpolationMode = null, int httpHeadersTimeout = HttpHeadersTimeout, int httpReadTimeout = HttpReadTimeout
		)
        {
			lock (_initializeLock)
			{
				_initialized = false;

				if (Config != null)
				{
					// If DownloadCache is not updated but HttpClient is then we inform DownloadCache
					if (httpClient != null && downloadCache == null)
					{
						downloadCache = Config.DownloadCache;
						downloadCache.DownloadHttpClient = httpClient;
					}

					logger.Debug("Skip configuration for maxCacheSize and diskCache. They cannot be redefined.");
					maxCacheSize = Config.MaxCacheSize;
					diskCache = Config.DiskCache;

					// Redefine these if they were provided only
					httpClient = httpClient ?? Config.HttpClient;
					scheduler = scheduler ?? Config.Scheduler;
					logger = logger ?? Config.Logger;
					downloadCache = downloadCache ?? Config.DownloadCache;
					loadWithTransparencyChannel = loadWithTransparencyChannel ?? Config.LoadWithTransparencyChannel;
					fadeAnimationEnabled = fadeAnimationEnabled ?? Config.FadeAnimationEnabled;
					transformPlaceholders = transformPlaceholders ?? Config.TransformPlaceholders;
					downsampleInterpolationMode = downsampleInterpolationMode ?? Config.DownsampleInterpolationMode;
				}


				InitializeIfNeeded(maxCacheSize ?? 0, httpClient, scheduler, logger, diskCache, downloadCache,
					loadWithTransparencyChannel ?? false, fadeAnimationEnabled ?? true,
					transformPlaceholders ?? true, downsampleInterpolationMode ?? InterpolationMode.Default, 
					httpHeadersTimeout, httpReadTimeout
				);
			}
        }
Пример #23
0
        /// <summary>
        /// Initialize ImageService default values. This can only be done once: during app start.
        /// </summary>
        /// <param name="maxCacheSize">Max cache size. If zero then 20% of the memory will be used.</param>
        /// <param name="httpClient">.NET HttpClient to use. If null then a ModernHttpClient is instanciated.</param>
        /// <param name="scheduler">Work scheduler used to organize/schedule loading tasks.</param>
        /// <param name="logger">Basic logger. If null a very simple implementation that prints to console is used.</param>
        /// <param name="diskCache">Disk cache. If null a default disk cache is instanciated that uses a journal mechanism.</param>
        /// <param name="downloadCache">Download cache. If null a default download cache is instanciated, which relies on the DiskCache</param>
        /// <param name="loadWithTransparencyChannel">Gets a value indicating whether images should be loaded with transparency channel. On Android we save 50% of the memory without transparency since we use 2 bytes per pixel instead of 4.</param>
        /// <param name="fadeAnimationEnabled">Defines if fading should be performed while loading images.</param>
        /// <param name="transformPlaceholders">Defines if transforms should be applied to placeholders.</param>
        /// <param name="downsampleInterpolationMode">Defines default downsample interpolation mode.</param>
        /// <param name="httpHeadersTimeout">Maximum time in seconds to wait to receive HTTP headers before the HTTP request is cancelled.</param>
        /// <param name="httpReadTimeout">Maximum time in seconds to wait before the HTTP request is cancelled.</param>
        public static void Initialize(int?maxCacheSize           = null, HttpClient httpClient        = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
                                      IDiskCache diskCache       = null, IDownloadCache downloadCache = null, bool?loadWithTransparencyChannel = null, bool?fadeAnimationEnabled = null,
                                      bool?transformPlaceholders = null, InterpolationMode?downsampleInterpolationMode = null, int httpHeadersTimeout = HttpHeadersTimeout, int httpReadTimeout = HttpReadTimeout
                                      )
        {
            lock (_initializeLock)
            {
                _initialized = false;

                if (Config != null)
                {
                    // If DownloadCache is not updated but HttpClient is then we inform DownloadCache
                    if (httpClient != null && downloadCache == null)
                    {
                        downloadCache = Config.DownloadCache;
                        downloadCache.DownloadHttpClient = httpClient;
                    }

                    logger.Debug("Skip configuration for maxCacheSize and diskCache. They cannot be redefined.");
                    maxCacheSize = Config.MaxCacheSize;
                    diskCache    = Config.DiskCache;

                    // Redefine these if they were provided only
                    httpClient    = httpClient ?? Config.HttpClient;
                    scheduler     = scheduler ?? Config.Scheduler;
                    logger        = logger ?? Config.Logger;
                    downloadCache = downloadCache ?? Config.DownloadCache;
                    loadWithTransparencyChannel = loadWithTransparencyChannel ?? Config.LoadWithTransparencyChannel;
                    fadeAnimationEnabled        = fadeAnimationEnabled ?? Config.FadeAnimationEnabled;
                    transformPlaceholders       = transformPlaceholders ?? Config.TransformPlaceholders;
                    downsampleInterpolationMode = downsampleInterpolationMode ?? Config.DownsampleInterpolationMode;
                }


                InitializeIfNeeded(maxCacheSize ?? 0, httpClient, scheduler, logger, diskCache, downloadCache,
                                   loadWithTransparencyChannel ?? false, fadeAnimationEnabled ?? true,
                                   transformPlaceholders ?? true, downsampleInterpolationMode ?? InterpolationMode.Default,
                                   httpHeadersTimeout, httpReadTimeout
                                   );
            }
        }
Пример #24
0
        private static void InitializeIfNeeded(int maxCacheSize     = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
                                               IDiskCache diskCache = null, IDownloadCache downloadCache = null)
        {
            if (_initialized)
            {
                return;
            }

            lock (_initializeLock)
            {
                if (_initialized)
                {
                    return;
                }

                var userDefinedConfig = new Configuration(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache);
                Config = GetDefaultConfiguration(userDefinedConfig);

                _initialized = true;
            }
        }
Пример #25
0
		public static void Initialize(int? maxCacheSize = null, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
			IDiskCache diskCache = null, IDownloadCache downloadCache = null, bool? loadWithTransparencyChannel = null, bool? fadeAnimationEnabled = null,
			bool? transformPlaceholders = null, InterpolationMode? downsampleInterpolationMode = null, int httpHeadersTimeout = 15, int httpReadTimeout = 30
		)
        {
			var cfg = new Configuration();

			if (httpClient != null) cfg.HttpClient = httpClient;
			if (scheduler != null) cfg.Scheduler = scheduler;
			if (logger != null) cfg.Logger = logger;
			if (diskCache != null) cfg.DiskCache = diskCache;
			if (downloadCache != null) cfg.DownloadCache = downloadCache;
			if (loadWithTransparencyChannel.HasValue) cfg.LoadWithTransparencyChannel = loadWithTransparencyChannel.Value;
			if (fadeAnimationEnabled.HasValue) cfg.FadeAnimationEnabled = fadeAnimationEnabled.Value;
			if (transformPlaceholders.HasValue) cfg.TransformPlaceholders = transformPlaceholders.Value;
			if (downsampleInterpolationMode.HasValue) cfg.DownsampleInterpolationMode = downsampleInterpolationMode.Value;
			cfg.HttpHeadersTimeout = httpHeadersTimeout;
			cfg.HttpReadTimeout = httpReadTimeout;
			if (maxCacheSize.HasValue) cfg.MaxCacheSize = maxCacheSize.Value;

			Initialize(cfg);
        }
Пример #26
0
 public static TSProject FindInfoForModule(IDirectoryCache dir, IDiskCache diskCache, string moduleName, out string diskName)
 {
     while (!dir.IsFake)
     {
         diskCache.UpdateIfNeeded(dir);
         var nmdir = dir.TryGetChild("node_modules") as IDirectoryCache;
         if (nmdir != null)
         {
             diskCache.UpdateIfNeeded(nmdir);
             var mdir = nmdir.TryGetChild(moduleName) as IDirectoryCache;
             if (mdir != null)
             {
                 diskName = mdir.Name;
                 diskCache.UpdateIfNeeded(mdir);
                 return(Get(mdir, diskCache));
             }
         }
         dir = dir.Parent;
     }
     diskName = null;
     return(null);
 }
Пример #27
0
            /// <summary>
            /// Creates a group.
            /// </summary>
            /// <param name="cache">The cache.</param>
            /// <param name="key">The cache group key.</param>
            /// <param name="location">The location of the cache group.</param>
            /// <exception cref="ArgumentNullException">Thrown if <paramref name="cache"/>,
            /// <paramref name="key"/> or <paramref name="location" /> is null.</exception>
            public Group(IDiskCache cache, string key, DirectoryInfo location)
            {
                if (cache == null)
                    throw new ArgumentNullException("cache");
                if (key == null)
                    throw new ArgumentNullException("key");
                if (location == null)
                    throw new ArgumentNullException("location");

                this.cache = cache;
                this.key = key;
                this.location = location;
            }
Пример #28
0
 public NpmNodePackageManager(IDiskCache diskCache, ILogger logger)
 {
     _diskCache = diskCache;
     _logger    = logger;
     _npmPath   = GetNpmPath();
 }
Пример #29
0
 public SourceReader(IDiskCache diskCache, string root)
 {
     _diskCache = diskCache;
     _root      = root;
 }
Пример #30
0
 /// <inheritdoc />
 /// <summary>
 /// 初始化 <see cref="DiskCachePipe{TSource}" /> 类的新实例。
 /// </summary>
 /// <param name="designModeService">设计模式服务。</param>
 /// <param name="diskCache">磁盘缓存。</param>
 public DiskCachePipe(IDesignModeService designModeService, [NotNull] IDiskCache diskCache) : base(designModeService)
 {
     _diskCache = diskCache ?? throw new ArgumentNullException(nameof(diskCache));
 }
 public Builder DiskCache(IDiskCache diskCache)
 {
     config.DiskCache = diskCache;
     return(this);
 }
Пример #32
0
 public YarnNodePackageManager(IDiskCache diskCache, ILogger logger)
 {
     _diskCache = diskCache;
     _logger    = logger;
     _yarnPath  = GetYarnPath();
 }
Пример #33
0
 public DataManager(CustomersRepository customersRepository, EntitiesRepository entitiesRepository, IDiskCache cache)
 {
     _customersRepository = customersRepository;
     _entitiesRepository  = entitiesRepository;
     _cache = cache;
 }
 public Builder DiskCache(IDiskCache diskCache) {
     config.DiskCache = diskCache;
     return this;
 }
Пример #35
0
        public static TSProject FindInfoForModule(IDirectoryCache projectDir, IDirectoryCache dir, IDiskCache diskCache,
                                                  ILogger logger,
                                                  string moduleName,
                                                  out string diskName)
        {
            if (projectDir.TryGetChildNoVirtual("node_modules") is IDirectoryCache pnmdir)
            {
                diskCache.UpdateIfNeeded(pnmdir);
                if (pnmdir.TryGetChild(moduleName, true) is IDirectoryCache mdir)
                {
                    diskName = mdir.Name;
                    diskCache.UpdateIfNeeded(mdir);
                    return(Get(mdir, diskCache, logger, diskName));
                }
            }

            while (dir != null)
            {
                if (diskCache.TryGetItem(PathUtils.Join(dir.FullPath, "node_modules")) is IDirectoryCache nmdir)
                {
                    diskCache.UpdateIfNeeded(nmdir);
                    if (nmdir.TryGetChild(moduleName, true) is IDirectoryCache mdir)
                    {
                        diskName = mdir.Name;
                        diskCache.UpdateIfNeeded(mdir);
                        return(Get(mdir, diskCache, logger, diskName));
                    }
                }

                dir = dir.Parent;
            }

            diskName = null;
            return(null);
        }
Пример #36
0
		private const int BufferSize = 4096; // Xamarin large object heap threshold is 8K

        public DownloadCache(HttpClient httpClient, IDiskCache diskCache)
        {
			DownloadHttpClient = httpClient;
            _md5Helper = new MD5Helper();
            _diskCache = diskCache;
        }
Пример #37
0
 public AssetsGenerator(IDiskCache cache)
 {
     _cache = cache;
 }
Пример #38
0
        private const int BufferSize = 4096;         // Xamarin large object heap threshold is 8K

        public DownloadCache(HttpClient httpClient, IDiskCache diskCache)
        {
            DownloadHttpClient = httpClient;
            _md5Helper         = new MD5Helper();
            _diskCache         = diskCache;
        }
Пример #39
0
        private static void InitializeIfNeeded(int maxCacheSize = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null,
            IDiskCache diskCache = null, IDownloadCache downloadCache = null)
        {
            if (_initialized)
                return;

            lock (_initializeLock)
            {
                if (_initialized)
                    return;

                var userDefinedConfig = new Configuration(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache);
                Config = GetDefaultConfiguration(userDefinedConfig);

                _initialized = true;
            }
        }
Пример #40
0
 public DiffChangeLog(IDiskCache diskCache)
 {
     _diskCache = diskCache;
 }