Refactor Tizen.Applications
authorWonYoung Choi <wy80.choi@samsung.com>
Wed, 9 Mar 2016 13:53:29 +0000 (22:53 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Wed, 9 Mar 2016 13:54:56 +0000 (22:54 +0900)
- Rename ContextGroup to ActorGroup
- Manage Service in Application
- Manage ActorLifecycle in ActorGroup
- Apply CodeFormatter

Change-Id: I5f616979e0f34868ea5e5faacbe3aa7b9c0e19f5

19 files changed:
Tizen.Applications/Interop/Interop.AppControl.cs
Tizen.Applications/Interop/Interop.Application.cs
Tizen.Applications/Interop/Interop.Aul.cs
Tizen.Applications/Interop/Interop.Glib.cs
Tizen.Applications/Interop/Interop.Window.cs
Tizen.Applications/Tizen.Applications.csproj
Tizen.Applications/Tizen.Applications/Actor.cs
Tizen.Applications/Tizen.Applications/ActorGroup.cs [new file with mode: 0755]
Tizen.Applications/Tizen.Applications/AppControl.cs
Tizen.Applications/Tizen.Applications/AppControlFilter.cs
Tizen.Applications/Tizen.Applications/Application.cs
Tizen.Applications/Tizen.Applications/CodeExample.cs [deleted file]
Tizen.Applications/Tizen.Applications/Context.cs
Tizen.Applications/Tizen.Applications/ContextGroup.cs [deleted file]
Tizen.Applications/Tizen.Applications/Service.cs
Tizen.Applications/Tizen.Applications/TizenSynchronizationContext.cs
Tizen.Applications/Tizen.UI/Page.cs [new file with mode: 0755]
Tizen.Applications/Tizen.UI/Window.cs [moved from Tizen.Applications/Tizen.Applications/Window.cs with 73% similarity]
packaging/csapi-application.spec

index c5a6013..2f3ac14 100755 (executable)
@@ -6,6 +6,7 @@
 /// it only in accordance with the terms of the license agreement
 /// you entered into with Samsung.
 
+
 using System;
 using System.Runtime.InteropServices;
 
@@ -30,7 +31,7 @@ internal static partial class Interop
 
         [DllImport(Libraries.Application, EntryPoint = "app_control_get_mime", CallingConvention = CallingConvention.Cdecl)]
         internal static extern int GetMime(SafeAppControlHandle handle, out string mime);
-        
+
         internal sealed class SafeAppControlHandle : SafeHandle
         {
             public SafeAppControlHandle() : base(IntPtr.Zero, true)
index eee2c77..31e5304 100755 (executable)
@@ -6,6 +6,7 @@
 /// it only in accordance with the terms of the license agreement
 /// you entered into with Samsung.
 
+
 using System;
 using System.Runtime.InteropServices;
 
@@ -41,5 +42,7 @@ internal static partial class Interop
         [DllImport(Libraries.Application, EntryPoint = "ui_app_main", CallingConvention = CallingConvention.Cdecl)]
         internal static extern int UIAppMain(int argc, string[] argv, ref UIAppLifecycleCallbacks callback, IntPtr userData);
 
+        [DllImport(Libraries.Application, EntryPoint = "ui_app_exit", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern void UIAppExit();
     }
 }
index 260892a..439a35a 100755 (executable)
@@ -6,6 +6,7 @@
 /// it only in accordance with the terms of the license agreement
 /// you entered into with Samsung.
 
+
 using System.Text;
 using System.Runtime.InteropServices;
 
index 9104e63..57c6e85 100755 (executable)
@@ -6,6 +6,7 @@
 /// it only in accordance with the terms of the license agreement
 /// you entered into with Samsung.
 
+
 using System;
 using System.Text;
 using System.Runtime.InteropServices;
index 4c42d8c..30e8bd9 100755 (executable)
@@ -1,8 +1,10 @@
 using System;
 using System.Runtime.InteropServices;
 
-internal static partial class Interop {
-    internal static partial class Window {
+internal static partial class Interop
+{
+    internal static partial class Window
+    {
         [DllImport(Libraries.Elementary, CallingConvention = CallingConvention.Cdecl)]
         internal static extern IntPtr elm_win_add(IntPtr parent, string name, int type);
 
index 325cbe8..22e61c3 100755 (executable)
@@ -7,7 +7,8 @@
     <ProjectGuid>{663C5A3D-E631-4987-AEE7-F498C56A40FC}</ProjectGuid>
     <OutputType>Library</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace></RootNamespace>
+    <RootNamespace>
+    </RootNamespace>
     <AssemblyName>Tizen.Applications</AssemblyName>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
@@ -57,9 +58,8 @@
     <Compile Include="Tizen.Applications\AppControl.cs" />
     <Compile Include="Tizen.Applications\AppControlFilter.cs" />
     <Compile Include="Tizen.Applications\Application.cs" />
-    <Compile Include="Tizen.Applications\CodeExample.cs" />
     <Compile Include="Tizen.Applications\Context.cs" />
-    <Compile Include="Tizen.Applications\ContextGroup.cs" />
+    <Compile Include="Tizen.Applications\ActorGroup.cs" />
     <Compile Include="Tizen.Applications\Service.cs" />
     <Compile Include="Tizen.Applications\Window.cs" />
     <Compile Include="Tizen.Applications\TizenSynchronizationContext.cs" />
@@ -75,4 +75,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
+</Project>
\ No newline at end of file
index 4052cef..3886320 100755 (executable)
@@ -1,12 +1,46 @@
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
 using System;
 
+using Tizen.UI;
+
 namespace Tizen.Applications
 {
+    /// <summary>
+    /// 
+    /// </summary>
     public abstract class Actor : Context
     {
+        private ActorGroup _group;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        internal protected Page MainPage { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
         protected virtual void OnPaused() { }
+
+        /// <summary>
+        /// 
+        /// </summary>
         protected virtual void OnResumed() { }
 
+        internal void Create(ActorGroup group)
+        {
+            _group = group;
+            base.Create();
+        }
+
         internal void Pause()
         {
             OnPaused();
@@ -15,29 +49,36 @@ namespace Tizen.Applications
         internal void Resume()
         {
             OnResumed();
+            MainPage.Show();
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="actor"></param>
+        /// <param name="control"></param>
         protected void StartActor(Actor actor, AppControl control)
         {
-            Actor target = (Actor)CurrentGroup.MoveToTop(actor);
-            if (target != null)
-            {
-                Pause();
-                target.Start(control);
-                target.Resume();
-            }
+            _group.StartActor(actor, control);
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="actorType"></param>
+        /// <param name="control"></param>
         protected override void StartActor(Type actorType, AppControl control)
         {
-            Application.StartActor(CurrentGroup, actorType, control);
+            Application.StartActor(_group, actorType, control);
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
         protected override void Finish()
         {
-            Application.StopActor(CurrentGroup, this);
+            Application.StopActor(_group, this);
         }
-
     }
 }
 
diff --git a/Tizen.Applications/Tizen.Applications/ActorGroup.cs b/Tizen.Applications/Tizen.Applications/ActorGroup.cs
new file mode 100755 (executable)
index 0000000..f2efd86
--- /dev/null
@@ -0,0 +1,103 @@
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Tizen.Applications
+{
+    internal class ActorGroup
+    {
+        private readonly List<Actor> _actorList;
+
+        public bool IsEmpty
+        {
+            get
+            {
+                return _actorList.Count == 0;
+            }
+        }
+
+        public Actor TopActor
+        {
+            get
+            {
+                return _actorList.LastOrDefault(null);
+            }
+        }
+
+        public ActorGroup()
+        {
+            _actorList = new List<Actor>();
+        }
+
+        public void StartActor(Type actorType, AppControl control)
+        {
+            Actor actor = (Actor)Activator.CreateInstance(actorType);
+            actor.Create(this);
+            if (actor.MainPage == null)
+            {
+                throw new ArgumentNullException("Actor's MainPage is not set.");
+            }
+
+            Actor prevTop = TopActor;
+            _actorList.Add(actor);
+            if (prevTop != null)
+            {
+                prevTop.Pause();
+            }
+            actor.Start(control);
+            actor.Resume();
+        }
+
+        public void StartActor(Actor actor, AppControl control)
+        {
+            if (actor.MainPage == null)
+            {
+                throw new ArgumentNullException("Actor's MainPage is not set.");
+            }
+
+            Actor prevTop = TopActor;
+            _actorList.Remove(actor);
+            _actorList.Add(actor);
+            if (prevTop != actor)
+            {
+                prevTop.Pause();
+            }
+            actor.Start(control);
+            actor.Resume();
+        }
+
+        public void StopActor(Actor actor)
+        {
+            Actor prevTop = TopActor;
+            _actorList.Remove(actor);
+            actor.Pause();
+            actor.Terminate();
+            if (prevTop == actor)
+            {
+                if (TopActor != null)
+                {
+                    TopActor.Resume();
+                }
+            }
+        }
+
+        public Actor FindActor(Type type)
+        {
+            return _actorList.Find(s => s.GetType() == type);
+        }
+
+        public Actor FindActor(Actor actor)
+        {
+            return _actorList.Find(s => s == actor);
+        }
+    }
+}
index 17b507f..1eda855 100755 (executable)
@@ -1,15 +1,28 @@
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
 using System;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
 
 namespace Tizen.Applications
 {
+    /// <summary>
+    /// 
+    /// </summary>
     public class AppControl
     {
-        private string _operation;
-        private string _mime;
-        private string _uri;
+        private readonly string _operation;
+        private readonly string _mime;
+        private readonly string _uri;
 
+        /// <summary>
+        /// 
+        /// </summary>
         public static class Operations
         {
             public const string Main = "http://tizen.org/appcontrol/operation/main";
@@ -41,8 +54,19 @@ namespace Tizen.Applications
             public const string SettingWifi = "http://tizen.org/appcontrol/operation/setting/wifi";
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
         public string Operation { get { return _operation; } }
+
+        /// <summary>
+        /// 
+        /// </summary>
         public string Mime { get { return _mime; } }
+
+        /// <summary>
+        /// 
+        /// </summary>
         public string Uri { get { return _uri; } }
 
         internal AppControl(IntPtr appControlHandle)
@@ -53,11 +77,12 @@ namespace Tizen.Applications
             Interop.AppControl.GetUri(handle, out _uri);
         }
 
-        internal bool IsService
-        {
-            get { return false; }
-        }
-
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="operation"></param>
+        /// <param name="mime"></param>
+        /// <param name="uri"></param>
         public AppControl(string operation, string mime, string uri)
         {
             _operation = operation;
@@ -65,11 +90,15 @@ namespace Tizen.Applications
             _uri = uri;
         }
 
-        public bool IsLaunchOperation()
+        internal bool IsLaunchOperation()
         {
             if (_operation == null) return false;
             return (_operation == Operations.Main) || (_operation == Operations.Default);
         }
 
+        internal bool IsService
+        {
+            get { return false; }
+        }
     }
 }
index 38adcb3..2896c60 100755 (executable)
@@ -1,8 +1,20 @@
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
 using System;
 using System.Text.RegularExpressions;
 
 namespace Tizen.Applications
 {
+    /// <summary>
+    /// 
+    /// </summary>
     [AttributeUsage(AttributeTargets.Class)]
     public class AppControlFilter : Attribute
     {
@@ -10,10 +22,27 @@ namespace Tizen.Applications
         private readonly string _mime;
         private readonly string _uri;
 
+        /// <summary>
+        /// 
+        /// </summary>
         public string Operation { get { return _operation; } }
+
+        /// <summary>
+        /// 
+        /// </summary>
         public string Mime { get { return _mime; } }
+
+        /// <summary>
+        /// 
+        /// </summary>
         public string Uri { get { return _uri; } }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="operation"></param>
+        /// <param name="mime"></param>
+        /// <param name="uri"></param>
         public AppControlFilter(string operation, string mime = null, string uri = null)
         {
             _operation = operation;
@@ -21,6 +50,11 @@ namespace Tizen.Applications
             _uri = uri;
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns></returns>
         public override bool Equals(object obj)
         {
             AppControlFilter f = obj as AppControlFilter;
@@ -29,6 +63,10 @@ namespace Tizen.Applications
             return (_operation == f._operation) & (_mime == f._mime) & (_uri == f._uri);
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
         public override int GetHashCode()
         {
             int hash = 0;
@@ -83,7 +121,7 @@ namespace Tizen.Applications
             return _uri == uri;
         }
 
-        public bool IsMatch(AppControl e)
+        internal bool IsMatch(AppControl e)
         {
             string mime = e.Mime;
             if (String.IsNullOrEmpty(mime) && !String.IsNullOrEmpty(e.Uri))
@@ -93,5 +131,4 @@ namespace Tizen.Applications
             return _operation == e.Operation && IsMimeMatched(mime) && IsUriMatched(e.Uri);
         }
     }
-
 }
index 39dfca6..d7b224c 100755 (executable)
@@ -1,21 +1,33 @@
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Runtime.InteropServices;
+
+using Tizen.UI;
 
 namespace Tizen.Applications
 {
+    /// <summary>
+    /// Provides static methods and properties to manage an application, such as methods to register Actors and Services, 
+    /// to start an application.
+    /// </summary>
     public static class Application
     {
-        private static Dictionary<AppControlFilter, Type> s_filterMap = new Dictionary<AppControlFilter, Type>();
-        private static ContextGroup s_serviceGroup = new ContextGroup();
-        private static List<ContextGroup> s_actorGroupList = new List<ContextGroup>();
+        private static readonly Dictionary<AppControlFilter, Type> s_filterMap = new Dictionary<AppControlFilter, Type>();
+        private static readonly List<Service> s_serviceList = new List<Service>();
+        private static readonly List<ActorGroup> s_actorGroupList = new List<ActorGroup>();
 
-        private static Window s_window = null;
+        private static readonly Window s_window = null;
 
-        private static ContextGroup CurrentActorGroup
+        private static ActorGroup CurrentActorGroup
         {
             get
             {
@@ -23,10 +35,21 @@ namespace Tizen.Applications
             }
         }
 
+        /// <summary>
+        /// Occurs when the application starts.
+        /// </summary>
         public static event EventHandler Created = delegate { };
+
+        /// <summary>
+        /// Occurs when the application's main loop exits.
+        /// </summary>
         public static event EventHandler Exited = delegate { };
 
-        public static int Run(string[] args)
+        /// <summary>
+        /// Runs the application's main loop.
+        /// </summary>
+        /// <param name="args">The command-line arguments</param>
+        public static void Run(string[] args)
         {
             Interop.Application.UIAppLifecycleCallbacks ops;
             ops.OnCreate = (userData) =>
@@ -36,9 +59,9 @@ namespace Tizen.Applications
             };
             ops.OnPause = (userData) =>
             {
-                if (CurrentActorGroup != null && CurrentActorGroup.TopContext != null)
+                if (CurrentActorGroup != null && CurrentActorGroup.TopActor != null)
                 {
-                    Actor actor = CurrentActorGroup.TopContext as Actor;
+                    Actor actor = CurrentActorGroup.TopActor as Actor;
                     if (actor != null)
                     {
                         actor.Pause();
@@ -47,9 +70,9 @@ namespace Tizen.Applications
             };
             ops.OnResume = (userData) =>
             {
-                if (CurrentActorGroup != null && CurrentActorGroup.TopContext != null)
+                if (CurrentActorGroup != null && CurrentActorGroup.TopActor != null)
                 {
-                    Actor actor = CurrentActorGroup.TopContext as Actor;
+                    Actor actor = CurrentActorGroup.TopActor as Actor;
                     if (actor != null)
                     {
                         actor.Resume();
@@ -76,12 +99,6 @@ namespace Tizen.Applications
                     {
                         if (item.Key.IsMatch(appControl) && item.Value.IsSubclassOf(typeof(Actor)))
                         {
-                            // Window was created when the first UI Actor was created
-                            if (s_window == null)
-                            {
-                                s_window = new Window();
-                            }
-
                             if (CurrentActorGroup == null || !appControl.IsLaunchOperation())
                             {
                                 StartActor(null, item.Value, appControl);
@@ -98,69 +115,103 @@ namespace Tizen.Applications
 
             TizenSynchronizationContext.Initialize();
 
-            int ret = Interop.Application.UIAppMain(args.Length, args, ref ops, IntPtr.Zero);
-
-            return ret;
+            // TODO: check ret of UIAppMain and throw exceptions when errors are returned.
+            Interop.Application.UIAppMain(args.Length, args, ref ops, IntPtr.Zero);
         }
 
+        /// <summary>
+        /// Hides the application.
+        /// </summary>
         public static void Hide()
         {
             if (s_window != null)
                 s_window.InActive();
         }
 
+        /// <summary>
+        /// Exits the main loop of application.
+        /// </summary>
         public static void Exit()
         {
-            Exited(null, null);
-            throw new NotImplementedException();
+            Exited(null, null);            
+            // TODO: clear context and group
+            Interop.Application.UIAppExit();
         }
 
-        public static void RegisterActor(Type clazz)
+        /// <summary>
+        /// Registers an Actor class type.
+        /// </summary>
+        /// <param name="actorType">The type of Actor class.</param>
+        public static void RegisterActor(Type actorType)
         {
-            RegisterActor(clazz, new AppControlFilter[0] { });
+            RegisterActor(actorType, new AppControlFilter[0] { });
         }
 
-        public static void RegisterActor(Type clazz, AppControlFilter filter)
+        /// <summary>
+        /// Registers an Actor class type.
+        /// </summary>
+        /// <param name="actorType">The type of Actor class.</param>
+        /// <param name="filter">The filter to match Actor and AppControl.</param>
+        public static void RegisterActor(Type actorType, AppControlFilter filter)
         {
-            RegisterActor(clazz, new AppControlFilter[] { filter });
+            RegisterActor(actorType, new AppControlFilter[] { filter });
         }
 
-        public static void RegisterActor(Type clazz, AppControlFilter[] filters)
+        /// <summary>
+        /// Registers an Actor class type.
+        /// </summary>
+        /// <param name="actorType">The type of Actor class.</param>
+        /// <param name="filters">The array of filters to match Actor and AppControl.</param>
+        public static void RegisterActor(Type actorType, AppControlFilter[] filters)
         {
-            if (!clazz.IsSubclassOf(typeof(Actor)))
-                throw new ArgumentException(clazz.FullName + " is not a subclass of Actor.");
+            if (!actorType.IsSubclassOf(typeof(Actor)))
+                throw new ArgumentException(actorType.FullName + " is not a subclass of Actor.");
 
-            RegisterContext(clazz, filters);
+            RegisterContext(actorType, filters);
         }
 
-        public static void RegisterService(Type clazz)
+        /// <summary>
+        /// Registers an Service class type.
+        /// </summary>
+        /// <param name="serviceType">The type of Service class.</param>
+        public static void RegisterService(Type serviceType)
         {
-            RegisterService(clazz, new AppControlFilter[0] { });
+            RegisterService(serviceType, new AppControlFilter[0] { });
         }
 
-        public static void RegisterService(Type clazz, AppControlFilter filter)
+        /// <summary>
+        /// Registers an Service class type.
+        /// </summary>
+        /// <param name="serviceType">The type of Service class.</param>
+        /// <param name="filter">The filter to match Service and AppControl.</param>
+        public static void RegisterService(Type serviceType, AppControlFilter filter)
         {
-            RegisterService(clazz, new AppControlFilter[] { filter });
+            RegisterService(serviceType, new AppControlFilter[] { filter });
         }
 
-        public static void RegisterService(Type clazz, AppControlFilter[] filters)
+        /// <summary>
+        /// Registers an Service class type.
+        /// </summary>
+        /// <param name="serviceType">The type of Service class.</param>
+        /// <param name="filters">The array of filters to match Service and AppControl.</param>
+        public static void RegisterService(Type serviceType, AppControlFilter[] filters)
         {
-            if (!clazz.IsSubclassOf(typeof(Service)))
-                throw new ArgumentException(clazz.FullName + " is not a subclass of Service.");
+            if (!serviceType.IsSubclassOf(typeof(Service)))
+                throw new ArgumentException(serviceType.FullName + " is not a subclass of Service.");
 
-            RegisterContext(clazz, filters);
+            RegisterContext(serviceType, filters);
         }
 
-        private static void RegisterContext(Type clazz, AppControlFilter[] filters)
+        private static void RegisterContext(Type contextType, AppControlFilter[] filters)
         {
-            foreach (var prop in clazz.GetProperties())
+            foreach (var prop in contextType.GetProperties())
             {
                 foreach (var attr in prop.GetCustomAttributes(false))
                 {
                     var filter = attr as AppControlFilter;
                     if (filter != null)
                     {
-                        s_filterMap.Add(filter, clazz);
+                        s_filterMap.Add(filter, contextType);
                     }
                 }
             }
@@ -168,47 +219,48 @@ namespace Tizen.Applications
             {
                 foreach (var filter in filters)
                 {
-                    s_filterMap.Add(filter, clazz);
+                    s_filterMap.Add(filter, contextType);
                 }
             }
         }
 
-        internal static void StartActor(ContextGroup group, Type actorType, AppControl control)
+        internal static void StartActor(ActorGroup group, Type actorType, AppControl control)
         {
             if (!actorType.IsSubclassOf(typeof(Actor)))
             {
                 throw new ArgumentException(actorType.FullName + " is not a subclass of Actor.");
             }
 
-            Actor actor = (Actor)Activator.CreateInstance(actorType);
-            ContextGroup ctxGroup = group;
-            if (ctxGroup == null)
+            // Window was created when the first UI Actor was created
+            //if (s_window == null)
+            //{
+            //    s_window = new Window();
+            //}
+
+            ActorGroup actorGroup = group;
+            if (actorGroup == null)
             {
-                ctxGroup = new ContextGroup();
-                s_actorGroupList.Add(ctxGroup);
+                actorGroup = new ActorGroup();
+                s_actorGroupList.Add(actorGroup);
             }
-            ctxGroup.AddContext(actor);
-            actor.Create(ctxGroup);
-            actor.Start(control);
+            actorGroup.StartActor(actorType, control);
 
             // TODO: consider resume operation
-            if (!s_window.Visible)
-            {
-                s_window.Active();
-                s_window.Show();
-                actor.Resume();
-            }
+            //if (!s_window.Visible)
+            //{
+            //    s_window.Active();
+            //    s_window.Show();
+            //    actor.Resume();
+            //}
         }
 
-        internal static void StopActor(ContextGroup group, Actor actor)
+        internal static void StopActor(ActorGroup group, Actor actor)
         {
-            actor.Pause();
-            actor.Terminate();
-            group.RemoveContext(actor);
+            group.StopActor(actor);
             if (group.IsEmpty)
             {
                 s_actorGroupList.Remove(group);
-                if (s_actorGroupList.Count == 0 && s_serviceGroup.IsEmpty)
+                if (s_actorGroupList.Count == 0 && s_serviceList.Count == 0)
                 {
                     Exit();
                 }
@@ -217,14 +269,6 @@ namespace Tizen.Applications
                     Hide();
                 }
             }
-            else
-            {
-                Actor nextActor = group.TopContext as Actor;
-                if (nextActor != null)
-                {
-                    nextActor.Resume();
-                }
-            }
         }
 
         internal static void StartService(Type serviceType, AppControl control)
@@ -234,15 +278,14 @@ namespace Tizen.Applications
                 throw new ArgumentException(serviceType.FullName + " is not a subclass of Service.");
             }
 
-            Context ctx = s_serviceGroup.FindContext(serviceType);
-            if (ctx == null)
+            Service svc = s_serviceList.Find(s => s.GetType() == serviceType);
+            if (svc == null)
             {
-                // Register ContextRemoved Handler once
-                ctx = (Service)Activator.CreateInstance(serviceType);
-                s_serviceGroup.AddContext(ctx);
-                ctx.Create(s_serviceGroup);
+                svc = (Service)Activator.CreateInstance(serviceType);
+                s_serviceList.Add(svc);
+                svc.Create();
             }
-            ctx.Start(control);
+            svc.Start(control);
         }
 
         internal static void StopService(Type serviceType)
@@ -252,17 +295,14 @@ namespace Tizen.Applications
                 throw new ArgumentException(serviceType.FullName + " is not a subclass of Service.");
             }
 
-            Context ctx = s_serviceGroup.FindContext(serviceType);
-            if (ctx != null)
+            Service svc = s_serviceList.Find(s => s.GetType() == serviceType);
+            if (svc != null)
             {
-                ctx.Terminate();
-                s_serviceGroup.RemoveContext(ctx);
-                if (s_serviceGroup.IsEmpty)
+                svc.Terminate();
+                s_serviceList.Remove(svc);
+                if (s_actorGroupList.Count == 0 && s_serviceList.Count == 0)
                 {
-                    if (s_actorGroupList.Count == 0)
-                    {
-                        Exit();
-                    }
+                    Exit();
                 }
             }
         }
diff --git a/Tizen.Applications/Tizen.Applications/CodeExample.cs b/Tizen.Applications/Tizen.Applications/CodeExample.cs
deleted file mode 100755 (executable)
index 54d83a0..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Tizen.Applications
-{
-    public class ViewActor : Actor
-    {
-        public string Type { get; set; }
-        protected override void OnCreated()
-        {
-            Console.WriteLine();
-        }
-
-        protected override void OnStarted()
-        {
-        }
-
-        private void DoSomething()
-        {
-        }
-    }
-
-    [AppControlFilter("http://tizen.org/appcontrol/operation/default")]
-    public class DefaultActor : Actor
-    {
-        protected override void OnCreated()
-        {
-        }
-
-        protected override void OnStarted()
-        {
-        }
-    }
-
-    public class Test
-    {
-        static void test(string[] args) // main
-        {
-            Application.Created += Application_Create;
-            Application.Exited += Application_Terminate;
-            Application.RegisterActor(typeof(DefaultActor));
-            Application.RegisterActor(typeof(ViewActor), new AppControlFilter[] {
-                new AppControlFilter("http://tizen.org/appcontrol/view", "image/*"),
-                new AppControlFilter("http://tizen.org/appcontrol/view", "text/*")
-            });
-
-            Application.Run(args);
-        }
-
-        private static void Application_Create(object sender, EventArgs e)
-        {
-            Console.WriteLine("Hello Application!");
-        }
-
-        private static void Application_Terminate(object sender, EventArgs e)
-        {
-            Console.WriteLine("Goodbye Application!");
-        }
-    }
-
-
-}
index 9183239..e359bda 100755 (executable)
@@ -1,24 +1,26 @@
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace Tizen.Applications
 {
+    /// <summary>
+    /// 
+    /// </summary>
     public abstract class Context
     {
-        private ContextGroup _group;
         private AppControl _control;
 
-        internal ContextGroup CurrentGroup
-        {
-            get
-            {
-                return _group;
-            }
-        }
-
+        /// <summary>
+        /// 
+        /// </summary>
         protected AppControl ReceivedAppControl
         {
             get
@@ -27,13 +29,23 @@ namespace Tizen.Applications
             }
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
         protected virtual void OnCreated() { }
+
+        /// <summary>
+        /// 
+        /// </summary>
         protected virtual void OnStarted() { }
+
+        /// <summary>
+        /// 
+        /// </summary>
         protected virtual void OnTerminated() { }
 
-        internal void Create(ContextGroup group)
+        internal void Create()
         {
-            _group = group;
             OnCreated();
         }
 
@@ -48,20 +60,42 @@ namespace Tizen.Applications
             OnTerminated();
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="actorType"></param>
+        /// <param name="control"></param>
         protected abstract void StartActor(Type actorType, AppControl control);
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="serviceType"></param>
+        /// <param name="control"></param>
         protected void StartService(Type serviceType, AppControl control)
         {
             Application.StartService(serviceType, control);
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="serviceType"></param>
         protected void StopService(Type serviceType)
         {
             Application.StopService(serviceType);
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
         protected abstract void Finish();
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="control"></param>
+        /// <param name="destination"></param>
         protected void SendAppControl(AppControl control, string destination)
         {
             throw new NotImplementedException();
diff --git a/Tizen.Applications/Tizen.Applications/ContextGroup.cs b/Tizen.Applications/Tizen.Applications/ContextGroup.cs
deleted file mode 100755 (executable)
index afe0a59..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Tizen.Applications
-{
-    internal class ContextGroup
-    {
-        private List<Context> _contextList;
-
-        public bool IsEmpty
-        {
-            get
-            {
-                return _contextList.Count == 0;
-            }
-        }
-
-        public Context TopContext
-        {
-            get
-            {
-                return _contextList.LastOrDefault(null);
-            }
-        }
-
-        public ContextGroup()
-        {
-            _contextList = new List<Context>();
-        }
-
-        public void AddContext(Context ctx)
-        {
-            _contextList.Add(ctx);
-        }
-
-        public void RemoveContext(Context ctx)
-        {
-            _contextList.Remove(ctx);
-        }
-
-        public Context FindContext(Type type)
-        {
-            return _contextList.Find(s => s.GetType() == type);
-        }
-
-        public Context FindContext(Context ctx)
-        {
-            return _contextList.Find(s => s == ctx);
-        }
-
-        public Context MoveToTop(Context ctx)
-        {
-            var found = FindContext(ctx);
-            if (found != null)
-            {
-                _contextList.Remove(found);
-                _contextList.Add(found);
-            }
-            return found;
-        }
-    }
-}
index 07f926c..10c23cc 100755 (executable)
@@ -1,14 +1,34 @@
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
 using System;
 
 namespace Tizen.Applications
 {
+    /// <summary>
+    /// 
+    /// </summary>
     public abstract class Service : Context
     {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="actorType"></param>
+        /// <param name="control"></param>
         protected override void StartActor(Type actorType, AppControl control)
         {
             Application.StartActor(null, actorType, control);
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
         protected override void Finish()
         {
             Application.StopService(GetType());
index c1d9560..26da27f 100755 (executable)
@@ -1,3 +1,12 @@
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
 using System;
 using System.Collections.Generic;
 using System.Threading;
@@ -10,14 +19,14 @@ namespace Tizen.Applications
         {
             SetSynchronizationContext(new TizenSynchronizationContext());
         }
-        private Interop.Glib.GSourceFunc wrapperHandler;
-        private Object transactionLock = new Object();
-        private int transactionID = 0;
-        private Dictionary<int, Action> handlerMap = new Dictionary<int, Action>();
+        private Interop.Glib.GSourceFunc _wrapperHandler;
+        private Object _transactionLock = new Object();
+        private int _transactionID = 0;
+        private Dictionary<int, Action> _handlerMap = new Dictionary<int, Action>();
 
-        TizenSynchronizationContext()
+        private TizenSynchronizationContext()
         {
-            wrapperHandler = new Interop.Glib.GSourceFunc(Handler);
+            _wrapperHandler = new Interop.Glib.GSourceFunc(Handler);
         }
 
         public override void Post(SendOrPostCallback d, object state)
@@ -57,24 +66,23 @@ namespace Tizen.Applications
         public void Post(Action action)
         {
             int id = 0;
-            lock (transactionLock)
+            lock (_transactionLock)
             {
-                id = transactionID++;
+                id = _transactionID++;
             }
-            handlerMap.Add(id, action);
-            Interop.Glib.IdleAdd(wrapperHandler, (IntPtr)id);
+            _handlerMap.Add(id, action);
+            Interop.Glib.IdleAdd(_wrapperHandler, (IntPtr)id);
         }
 
         public bool Handler(IntPtr userData)
         {
             int key = (int)userData;
-            if (handlerMap.ContainsKey(key))
+            if (_handlerMap.ContainsKey(key))
             {
-                handlerMap[key]();
-                handlerMap.Remove(key);
+                _handlerMap[key]();
+                _handlerMap.Remove(key);
             }
             return false;
         }
-
     }
 }
diff --git a/Tizen.Applications/Tizen.UI/Page.cs b/Tizen.Applications/Tizen.UI/Page.cs
new file mode 100755 (executable)
index 0000000..390d5a7
--- /dev/null
@@ -0,0 +1,24 @@
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.UI
+{
+    public class Page
+    {
+        internal void Show()
+        {
+
+        }
+    }
+}
similarity index 73%
rename from Tizen.Applications/Tizen.Applications/Window.cs
rename to Tizen.Applications/Tizen.UI/Window.cs
index a2a61b6..e2e134b 100755 (executable)
@@ -1,8 +1,17 @@
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
 using System;
 
-namespace Tizen.Applications
+namespace Tizen.UI
 {
-    class Window : IDisposable
+    internal class Window : IDisposable
     {
         private IntPtr _native_window = IntPtr.Zero;
 
@@ -17,22 +26,27 @@ namespace Tizen.Applications
         {
             _native_window = Interop.Window.elm_win_add(IntPtr.Zero, "Window", 0);
         }
+
         ~Window()
         {
             Dispose();
         }
+
         public void Show()
         {
             Interop.Window.evas_object_show(_native_window);
         }
+
         public void Hide()
         {
             Interop.Window.evas_object_hide(_native_window);
         }
+
         public void Active()
         {
             Interop.Window.elm_win_activate(_native_window);
         }
+
         public void InActive()
         {
             Interop.Window.elm_win_lower(_native_window);
index c6acbc9..fa35b1f 100644 (file)
@@ -56,6 +56,7 @@ cp %{SOURCE1} .
 mcs -target:library -out:%{dllname} -keyfile:Tizen.Applications/Tizen.Applications.snk \
   Tizen.Applications/Properties/AssemblyInfo.cs \
   Tizen.Applications/Tizen.Applications/*.cs \
+  Tizen.Applications/Tizen.UI/*.cs \
   Tizen.Applications/Interop/*.cs
 
 # check p/invoke