2 * Copyright (c) 2016 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 Tizen.Applications.CoreBackend;
21 namespace Tizen.Applications
24 /// Represents a widget application.
26 public class WidgetApplication : CoreApplication
29 /// Initializes the WidgetApplication class with the type and application ID.
31 /// <param name="typeInfo">Map structure for the derived class type and widget ID.</param>
32 public WidgetApplication(IDictionary<Type, string> typeInfo) : base(new WidgetCoreBackend())
34 WidgetCoreBackend core = Backend as WidgetCoreBackend;
36 core?.CreateWidgetTypes(typeInfo);
40 /// Initializes the WidgetApplication class with the type.
42 /// <remarks>Widget ID will be replaced as the application ID.</remarks>
43 /// <param name="type">Derived class type.</param>
44 public WidgetApplication(Type type) : base(new WidgetCoreBackend())
46 WidgetCoreBackend core = Backend as WidgetCoreBackend;
48 core?.CreateWidgetTypes(new Dictionary<Type, string>() { {type, ApplicationInfo.ApplicationId } });
52 /// Gets all instances of the widget associated with the type.
54 /// <param name="type">Class type for the widget.</param>
55 public IEnumerable<WidgetBase> GetInstances(Type type)
57 WidgetCoreBackend core = Backend as WidgetCoreBackend;
62 foreach (WidgetType w in core.WidgetTypes)
64 if (w.ClassType == type)
66 return w.WidgetInstances;
74 /// Runs the widget application's main loop.
76 /// <param name="args">Arguments from the commandline.</param>
77 public override void Run(string[] args)