[NUI] add support for parameterized constructor in xaml (#1998)
authorYeongJong Lee <cleanlyj@naver.com>
Thu, 10 Sep 2020 05:15:56 +0000 (14:15 +0900)
committerGitHub <noreply@github.com>
Thu, 10 Sep 2020 05:15:56 +0000 (14:15 +0900)
commitb3a19550d6278f2f32317c61f8ddf2da36f478d3
tree802f973b220f05e1bc85076f57a398f73548f354
parenta7746f04880e5a7e61c0d743c4b5bb03191168c5
[NUI] add support for parameterized constructor in xaml (#1998)

In xaml, root element is now able to be instantiated by parameterized
constructor.

 ### Sample
```cs
namespace NUIXamlTemplate1
{
    public class TestClass
    {
        public TestClass([Parameter(nameof(PropertyForConstructor))] string propertyForConstructor)
        {
            PropertyForConstructor = propertyForConstructor;
        }

        public string PropertyForConstructor { get; }
    }
}

```

```xaml
<local:TestClass
    xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
    xmlns:local="clr-namespace:NUIXamlTemplate1;assembly=NUIXamlTemplate1"
    PropertyForConstructor="test property"
    >

</local:TestClass>
```

```cs
protected override void OnCreate()
{
    base.OnCreate();
    Window.Instance.KeyEvent += OnKeyEvent;

    View root = new View();
    Window.Instance.GetDefaultLayer().Add(root);

    TestClass testClass;
    using (var reader = XmlReader.Create(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/TestXaml.xaml"))
    {
        testClass = XamlLoader.Create(reader) as TestClass;
    }
    string property = testClass.PropertyForConstructor;   //"test property"
}
```
src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs
src/Tizen.NUI/src/public/Xaml/XamlServiceProvider.cs