[NUI] Change GetDefaultWindow() to static func (#900)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / BindableObjectExtensions.cs
1 using System;
2 using System.Linq.Expressions;
3
4 namespace Tizen.NUI.Binding
5 {
6     internal static class BindableObjectExtensions
7     {
8         public static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null,
9                                       string stringFormat = null)
10         {
11             if (self == null)
12                 throw new ArgumentNullException("self");
13             if (targetProperty == null)
14                 throw new ArgumentNullException("targetProperty");
15
16             var binding = new Binding(path, mode, converter, stringFormat: stringFormat);
17             self.SetBinding(targetProperty, binding);
18         }
19
20         [Obsolete]
21         public static void SetBinding<TSource>(this BindableObject self, BindableProperty targetProperty, Expression<Func<TSource, object>> sourceProperty, BindingMode mode = BindingMode.Default,
22                                                IValueConverter converter = null, string stringFormat = null)
23         {
24             if (self == null)
25                 throw new ArgumentNullException("self");
26             if (targetProperty == null)
27                 throw new ArgumentNullException("targetProperty");
28             if (sourceProperty == null)
29                 throw new ArgumentNullException("sourceProperty");
30
31             Binding binding = Binding.Create(sourceProperty, mode, converter, stringFormat: stringFormat);
32             self.SetBinding(targetProperty, binding);
33         }
34     }
35 }