/*
* Copyright (c) 2016 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 Tizen.Applications.CoreBackend;
namespace Tizen.Applications
{
///
/// Represents a widget application.
///
/// 3
public class WidgetApplication : CoreApplication
{
///
/// Initializes the WidgetApplication class with the type and application ID.
///
/// Map structure for the derived class type and widget ID.
/// 3
public WidgetApplication(IDictionary typeInfo) : base(new WidgetCoreBackend())
{
WidgetCoreBackend core = Backend as WidgetCoreBackend;
core?.CreateWidgetTypes(typeInfo);
}
///
/// Initializes the WidgetApplication class with the type.
///
/// Widget ID will be replaced as the application ID.
/// Derived class type.
/// 3
public WidgetApplication(Type type) : base(new WidgetCoreBackend())
{
WidgetCoreBackend core = Backend as WidgetCoreBackend;
core?.CreateWidgetTypes(new Dictionary() { {type, ApplicationInfo.ApplicationId } });
}
///
/// Gets all instances of the widget associated with the type.
///
/// Class type for the widget.
/// 3
public IEnumerable GetInstances(Type type)
{
WidgetCoreBackend core = Backend as WidgetCoreBackend;
if (core == null)
return null;
foreach (WidgetType w in core.WidgetTypes)
{
if (w.ClassType == type)
{
return w.WidgetInstances;
}
}
return null;
}
///
/// Runs the widget application's main loop.
///
/// Arguments from the commandline.
/// 3
public override void Run(string[] args)
{
base.Run(args);
}
}
}