コード例 #1
0
        public async static Task <PrinterSettings> LoadOemProfileAsync(PublicDevice publicDevice, string make, string model)
        {
            string cacheScope = Path.Combine("public-profiles", make);
            string cachePath  = ApplicationController.CacheablePath(cacheScope, publicDevice.CacheKey);

            return(await ApplicationController.LoadCacheableAsync <PrinterSettings>(
                       publicDevice.CacheKey,
                       cacheScope,
                       async() =>
            {
                // The collector specifically returns null to ensure LoadCacheable skips writing the
                // result to the cache. After this result is returned, it will attempt to load from
                // the local cache if the collector yielded no result
                if (File.Exists(cachePath) ||
                    ApplicationController.DownloadPublicProfileAsync == null)
                {
                    return null;
                }
                else
                {
                    // If the cache file for the current deviceToken does not exist, attempt to download it.
                    // An http 304 results in a null value and LoadCacheable will then load from the cache
                    return await ApplicationController.DownloadPublicProfileAsync(publicDevice.ProfileToken);
                }
            },
                       Path.Combine("Profiles", make, model + ProfileManager.ProfileExtension)));
        }
コード例 #2
0
		public async static Task<PrinterSettings> LoadOemProfileAsync(PublicDevice publicDevice, string make, string model)
		{
			string cacheScope = Path.Combine("public-profiles", make);
			string cachePath = ApplicationController.CacheablePath(cacheScope, publicDevice.CacheKey);

			return await ApplicationController.LoadCacheableAsync<PrinterSettings>(
				publicDevice.CacheKey,
				cacheScope,
				async () =>
				{
					// The collector specifically returns null to ensure LoadCacheable skips writing the
					// result to the cache. After this result is returned, it will attempt to load from
					// the local cache if the collector yielded no result
					if(File.Exists(cachePath))
					{
						return null;
					}
					else
					{
						// If the cache file for the current deviceToken does not exist, attempt to download it.
						// An http 304 results in a null value and LoadCacheable will then load from the cache
						return await ApplicationController.DownloadPublicProfileAsync(publicDevice.ProfileToken);
					}
				},
				Path.Combine("Profiles", make, model + ProfileManager.ProfileExtension));
		}