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