Skip to content

Commit be75f1a

Browse files
committed
add some helpers
1 parent 3362a66 commit be75f1a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Files/Helpers/StorageItemHelpers.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class StorageItemHelpers
1212
{
1313
public static async Task<IStorageItem> PathToStorageItemAsync(string path, Type type)
1414
{
15+
if (type == typeof(IStorageItem))
16+
{
17+
throw new InvalidOperationException("An implementation type is needed.");
18+
}
19+
1520
if (type == typeof(StorageFile))
1621
{
1722
return await StorageFile.GetFileFromPathAsync(path).AsTask();
@@ -35,9 +40,9 @@ public static async Task<IStorageItem> PathToStorageItemAsync(string path, Type
3540
throw new InvalidOperationException();
3641
}
3742

38-
public static Task<IStorageItem> PathToStorageItemAsync<T>(string path) where T : IStorageItem
43+
public static async Task<T> PathToStorageItemAsync<T>(string path) where T : IStorageItem
3944
{
40-
return PathToStorageItemAsync(path, typeof(T));
45+
return (T)await PathToStorageItemAsync(path, typeof(T));
4146
}
4247

4348
public static bool Exists(string path)

0 commit comments

Comments
 (0)