/* * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using System.ComponentModel; using Tizen.Applications; using Tizen.Applications.ComponentBased; using Tizen.Applications.ComponentBased.Common; using Tizen.NUI.BaseComponents; namespace Tizen.NUI { /// /// The class for supporting multi-components application model. /// [EditorBrowsable(EditorBrowsableState.Never)] public class NUIComponentApplication : CoreApplication { private Dictionary _componentFactories = new Dictionary(); /// /// Initializes the ComponentApplication class. /// /// The component type information. /// The key should be a class type of FrameComponent or SubComponent subclass. /// The value should be a component id which is declared in tizen-manifest.xml. /// [EditorBrowsable(EditorBrowsableState.Never)] public NUIComponentApplication(IDictionary typeInfo) : base(new NUIComponentCoreBackend()) { if (typeInfo != null) { foreach (var component in typeInfo) { RegisterComponent(component.Key, component.Value); } } (Backend as NUIComponentCoreBackend).ComponentFactories = _componentFactories; } /// /// Registers a component. /// /// Class type /// Component ID /// Thrown when component type is already added or not sub-class of FrameComponent or ServiceComponent [EditorBrowsable(EditorBrowsableState.Never)] public void RegisterComponent(Type compType, string compId) { if (_componentFactories.ContainsKey(compType)) { throw new ArgumentException("Already exist type"); } if (typeof(FrameComponent).IsAssignableFrom(compType)) { _componentFactories.Add(compType, new FrameComponentStateManager(compType, compId, null)); } else if (typeof(ServiceComponent).IsAssignableFrom(compType)) { _componentFactories.Add(compType, new ServiceComponentStateManager(compType, compId, null)); } else { throw new ArgumentException("compType must be sub type of FrameComponent or ServiceComponent", nameof(compType)); } } /// /// Runs the application's main loop. /// /// Arguments from commandline. /// Thrown when component type is already added to the component. [EditorBrowsable(EditorBrowsableState.Never)] public override void Run(string[] args) { //Register Callback. base.Run(args); } /// /// Exits the main loop of the application. /// [EditorBrowsable(EditorBrowsableState.Never)] public override void Exit() { base.Exit(); } /// /// This method will be called before running main-loop /// [EditorBrowsable(EditorBrowsableState.Never)] protected override void OnCreate() { base.OnCreate(); } /// /// This method will be called after exiting main-loop /// [EditorBrowsable(EditorBrowsableState.Never)] protected override void OnTerminate() { base.OnTerminate(); } } }