[NUI] Roll back to fix build error of TCT code
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / XamlBinding / BindableObjectExtensions.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using System;
19 using System.ComponentModel;
20 using System.Linq.Expressions;
21
22 namespace Tizen.NUI.Binding
23 {
24     /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
25     [EditorBrowsable(EditorBrowsableState.Never)]
26     public static class BindableObjectExtensions
27     {
28         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
29         [EditorBrowsable(EditorBrowsableState.Never)]
30         public static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null,
31                                       string stringFormat = null)
32         {
33             if (self == null)
34                 throw new ArgumentNullException(nameof(self));
35             if (targetProperty == null)
36                 throw new ArgumentNullException(nameof(targetProperty));
37
38             var binding = new Binding(path, mode, converter, stringFormat: stringFormat);
39             self.SetBinding(targetProperty, binding);
40         }
41
42         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
43         [EditorBrowsable(EditorBrowsableState.Never)]
44         [ObsoleteAttribute(" ", false)]
45         public static void SetBinding<TSource>(this BindableObject self, BindableProperty targetProperty, Expression<Func<TSource, object>> sourceProperty, BindingMode mode = BindingMode.Default,
46                                                IValueConverter converter = null, string stringFormat = null)
47         {
48             if (self == null)
49                 throw new ArgumentNullException(nameof(self));
50             if (targetProperty == null)
51                 throw new ArgumentNullException(nameof(targetProperty));
52             if (sourceProperty == null)
53                 throw new ArgumentNullException(nameof(sourceProperty));
54
55             Binding binding = Binding.Create(sourceProperty, mode, converter, stringFormat: stringFormat);
56             self.SetBinding(targetProperty, binding);
57         }
58     }
59 }