-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathCloudDetector.cs
40 lines (34 loc) · 1.06 KB
/
CloudDetector.cs
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
// Copyright (c) Files Community
// Licensed under the MIT License.
using Files.App.Utils.Cloud;
namespace Files.App.Utils.Cloud
{
/// <summary>
/// Provides an utility for cloud detection.
/// </summary>
public sealed class CloudDetector : ICloudDetector
{
public async Task<IEnumerable<ICloudProvider>> DetectCloudProvidersAsync()
{
var tasks = new List<Task<IEnumerable<ICloudProvider>>>();
foreach (var detector in EnumerateDetectors())
tasks.Add(detector.DetectCloudProvidersAsync());
await Task.WhenAll(tasks);
return tasks
.SelectMany(task => task.Result)
.OrderBy(task => task.ID.ToString())
.ThenBy(task => task.Name)
.Distinct();
}
private static IEnumerable<ICloudDetector> EnumerateDetectors()
{
yield return new GoogleDriveCloudDetector();
yield return new DropBoxCloudDetector();
yield return new BoxCloudDetector();
yield return new GenericCloudDetector();
yield return new SynologyDriveCloudDetector();
yield return new LucidLinkCloudDetector();
yield return new SyncCloudDetector();
}
}
}