forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtensions.cs
63 lines (55 loc) · 1.68 KB
/
Extensions.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Runtime.CompilerServices;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
namespace Xamarin.Forms.Platform.UWP
{
internal static class Extensions
{
public static ConfiguredTaskAwaitable<T> DontSync<T>(this IAsyncOperation<T> self)
{
return self.AsTask().ConfigureAwait(false);
}
public static ConfiguredTaskAwaitable DontSync(this IAsyncAction self)
{
return self.AsTask().ConfigureAwait(false);
}
public static void SetBinding(this FrameworkElement self, DependencyProperty property, string path)
{
self.SetBinding(property, new Windows.UI.Xaml.Data.Binding { Path = new PropertyPath(path) });
}
public static void SetBinding(this FrameworkElement self, DependencyProperty property, string path, Windows.UI.Xaml.Data.IValueConverter converter)
{
self.SetBinding(property, new Windows.UI.Xaml.Data.Binding { Path = new PropertyPath(path), Converter = converter });
}
internal static InputScopeNameValue GetKeyboardButtonType(this ReturnType returnType)
{
switch (returnType)
{
case ReturnType.Default:
case ReturnType.Done:
case ReturnType.Go:
case ReturnType.Next:
case ReturnType.Send:
return InputScopeNameValue.Default;
case ReturnType.Search:
return InputScopeNameValue.Search;
default:
throw new System.NotImplementedException($"ReturnType {returnType} not supported");
}
}
internal static InputScope ToInputScope(this ReturnType returnType)
{
var scopeName = new InputScopeName()
{
NameValue = GetKeyboardButtonType(returnType)
};
var inputScope = new InputScope
{
Names = { scopeName }
};
return inputScope;
}
}
}