[NUI] Fix to disable ThemeManager in tv profile
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Application / NUIComponentApplication.cs
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
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 using System;
18 using System.Collections.Generic;
19 using System.ComponentModel;
20 using Tizen.Applications;
21 using Tizen.Applications.ComponentBased.Common;
22
23 namespace Tizen.NUI
24 {
25     /// <summary>
26     /// The class for supporting multi-components application model.
27     /// </summary>
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class NUIComponentApplication : CoreApplication
30     {
31         private Dictionary<Type, ComponentStateManger> componentFactories = new Dictionary<Type, ComponentStateManger>();
32
33         /// <summary>
34         /// Initializes the ComponentApplication class.
35         /// </summary>
36         /// <param name="typeInfo">The component type information.
37         /// The key should be a class type of FrameComponent or SubComponent subclass.
38         /// The value should be a component id which is declared in tizen-manifest.xml.
39         /// </param>
40         [EditorBrowsable(EditorBrowsableState.Never)]
41         public NUIComponentApplication(IDictionary<Type, string> typeInfo) : base(new NUIComponentCoreBackend())
42         {
43             if (typeInfo != null)
44             {
45                 foreach (var component in typeInfo)
46                 {
47                     RegisterComponent(component.Key, component.Value);
48                 }
49             }
50             (Backend as NUIComponentCoreBackend).ComponentFactories = componentFactories;
51         }
52
53         /// <summary>
54         /// Registers a component.
55         /// </summary>
56         /// <param name="compType">Class type</param>
57         /// <param name="compId">Component ID</param>
58         /// <exception cref="ArgumentException">Thrown when component type is already added or not sub-class of FrameComponent or ServiceComponent</exception>
59         [EditorBrowsable(EditorBrowsableState.Never)]
60         public void RegisterComponent(Type compType, string compId)
61         {
62             if (componentFactories.ContainsKey(compType))
63             {
64                 throw new ArgumentException("Already exist type");
65             }
66
67             if (typeof(FrameComponent).IsAssignableFrom(compType))
68             {
69                 componentFactories.Add(compType, new FrameComponentStateManager(compType, compId, null));
70             }
71             else if (typeof(ServiceComponent).IsAssignableFrom(compType))
72             {
73                 componentFactories.Add(compType, new ServiceComponentStateManager(compType, compId, null));
74             }
75             else
76             {
77                 throw new ArgumentException("compType must be sub type of FrameComponent or ServiceComponent", nameof(compType));
78             }
79         }
80
81         /// <summary>
82         /// Runs the application's main loop.
83         /// </summary>
84         /// <param name="args">Arguments from commandline.</param>
85         /// <exception cref="InvalidOperationException">Thrown when component type is already added to the component.</exception>
86         [EditorBrowsable(EditorBrowsableState.Never)]
87         public override void Run(string[] args)
88         {
89             //Register Callback.
90             base.Run(args);
91         }
92
93         /// <summary>
94         /// Exits the main loop of the application.
95         /// </summary>
96         [EditorBrowsable(EditorBrowsableState.Never)]
97         public override void Exit()
98         {
99             base.Exit();
100         }
101
102         /// <summary>
103         /// This method will be called before running main-loop
104         /// </summary>
105         [EditorBrowsable(EditorBrowsableState.Never)]
106         protected override void OnCreate()
107         {
108             base.OnCreate();
109         }
110
111         /// <summary>
112         /// This method will be called after exiting main-loop
113         /// </summary>
114         [EditorBrowsable(EditorBrowsableState.Never)]
115         protected override void OnTerminate()
116         {
117             base.OnTerminate();
118         }
119     }
120 }
121