[NUI] Change GetDefaultWindow() to static func (#900)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / PlatformConfigurationRegistry.cs
1 using System;
2 using System.Collections.Generic;
3
4 namespace Tizen.NUI.Binding
5 {
6     /// <summary>
7     /// Helper that handles storing and lookup of platform specifics implementations
8     /// </summary>
9     /// <typeparam name="TElement">The Element type</typeparam>
10     internal class PlatformConfigurationRegistry<TElement> : IElementConfiguration<TElement>
11         where TElement : Element
12     {
13         readonly TElement _element;
14         readonly Dictionary<Type, object> _platformSpecifics = new Dictionary<Type, object>();
15
16         internal PlatformConfigurationRegistry(TElement element)
17         {
18             _element = element;
19         }
20
21
22         public IPlatformElementConfiguration<T, TElement> On<T>() where T : IConfigPlatform
23         {
24             if (_platformSpecifics.ContainsKey(typeof(T)))
25             {
26                 return (IPlatformElementConfiguration<T, TElement>)_platformSpecifics[typeof(T)];
27             }
28
29             var emptyConfig = Configuration<T, TElement>.Create(_element);
30
31             _platformSpecifics.Add(typeof(T), emptyConfig);
32
33             return emptyConfig;
34         }
35     }
36 }