[NUI] Adjust directory (#903)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / XamlBinding / BindableObjectExtensions.cs
1 using System;
2 using System.ComponentModel;
3 using System.Linq.Expressions;
4
5 namespace Tizen.NUI.Binding
6 {
7     /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
8     [EditorBrowsable(EditorBrowsableState.Never)]
9     public static class BindableObjectExtensions
10     {
11         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
12         [EditorBrowsable(EditorBrowsableState.Never)]
13         public static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null,
14                                       string stringFormat = null)
15         {
16             if (self == null)
17                 throw new ArgumentNullException("self");
18             if (targetProperty == null)
19                 throw new ArgumentNullException("targetProperty");
20
21             var binding = new Binding(path, mode, converter, stringFormat: stringFormat);
22             self.SetBinding(targetProperty, binding);
23         }
24
25         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
26         [EditorBrowsable(EditorBrowsableState.Never)]
27         [Obsolete]
28         public static void SetBinding<TSource>(this BindableObject self, BindableProperty targetProperty, Expression<Func<TSource, object>> sourceProperty, BindingMode mode = BindingMode.Default,
29                                                IValueConverter converter = null, string stringFormat = null)
30         {
31             if (self == null)
32                 throw new ArgumentNullException("self");
33             if (targetProperty == null)
34                 throw new ArgumentNullException("targetProperty");
35             if (sourceProperty == null)
36                 throw new ArgumentNullException("sourceProperty");
37
38             Binding binding = Binding.Create(sourceProperty, mode, converter, stringFormat: stringFormat);
39             self.SetBinding(targetProperty, binding);
40         }
41     }
42 }