forked from CommunityToolkit/WindowsCommunityToolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileCache.cs
More file actions
51 lines (46 loc) · 1.92 KB
/
FileCache.cs
File metadata and controls
51 lines (46 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Storage.Streams;
namespace Microsoft.Toolkit.Uwp.UI
{
/// <summary>
/// Provides methods and tools to cache files in a folder
/// </summary>
public class FileCache : CacheBase<StorageFile>
{
/// <summary>
/// Private singleton field.
/// </summary>
private static FileCache _instance;
/// <summary>
/// Gets public singleton property.
/// </summary>
public static FileCache Instance => _instance ?? (_instance = new FileCache());
/// <summary>
/// Cache specific hooks to process items from HTTP response
/// </summary>
/// <param name="stream">input stream</param>
/// <param name="initializerKeyValues">key value pairs used when initializing instance of generic type</param>
/// <returns>awaitable task</returns>
protected override Task<StorageFile> InitializeTypeAsync(Stream stream, List<KeyValuePair<string, object>> initializerKeyValues = null)
{
// nothing to do in this instance;
return null;
}
/// <summary>
/// Cache specific hooks to process items from HTTP response
/// </summary>
/// <param name="baseFile">storage file</param>
/// <param name="initializerKeyValues">key value pairs used when initializing instance of generic type</param>
/// <returns>awaitable task</returns>
protected override Task<StorageFile> InitializeTypeAsync(StorageFile baseFile, List<KeyValuePair<string, object>> initializerKeyValues = null)
{
return Task.Run(() => baseFile);
}
}
}