2 * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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;
29 /// The class for supporting multi-components application model.
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public class NUIComponentApplication : CoreApplication
34 private Dictionary<Type, ComponentStateManger> _componentFactories = new Dictionary<Type, ComponentStateManger>();
37 /// Initializes the ComponentApplication class.
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.
43 [EditorBrowsable(EditorBrowsableState.Never)]
44 public NUIComponentApplication(IDictionary<Type, string> typeInfo) : base(new NUIComponentCoreBackend())
48 foreach (var component in typeInfo)
50 RegisterComponent(component.Key, component.Value);
53 (Backend as NUIComponentCoreBackend).ComponentFactories = _componentFactories;
57 /// Registers a component.
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)
65 if (_componentFactories.ContainsKey(compType))
67 throw new ArgumentException("Already exist type");
70 if (typeof(FrameComponent).IsAssignableFrom(compType))
72 _componentFactories.Add(compType, new FrameComponentStateManager(compType, compId, null));
74 else if (typeof(ServiceComponent).IsAssignableFrom(compType))
76 _componentFactories.Add(compType, new ServiceComponentStateManager(compType, compId, null));
80 throw new ArgumentException("compType must be sub type of FrameComponent or ServiceComponent", nameof(compType));
86 /// Runs the application's main loop.
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)
98 /// Exits the main loop of the application.
100 [EditorBrowsable(EditorBrowsableState.Never)]
101 public override void Exit()
107 /// This method will be called before running main-loop
109 [EditorBrowsable(EditorBrowsableState.Never)]
110 protected override void OnCreate()
116 /// This method will be called after exiting main-loop
118 [EditorBrowsable(EditorBrowsableState.Never)]
119 protected override void OnTerminate()