Refactor Lifecycles
authorWonYoung Choi <wy80.choi@samsung.com>
Wed, 16 Mar 2016 04:48:04 +0000 (13:48 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Wed, 16 Mar 2016 04:50:08 +0000 (13:50 +0900)
- Rename Actor to UIController
- Rename Service to ServiceController

Change-Id: I19f5365dd8fa80626c4c376324d3936dfaecdc5d

15 files changed:
Tizen.Applications/Interop/Interop.AppControl.cs
Tizen.Applications/Tizen.Applications.csproj
Tizen.Applications/Tizen.Applications/Actor.cs [deleted file]
Tizen.Applications/Tizen.Applications/AppControlFilter.cs
Tizen.Applications/Tizen.Applications/Application.cs
Tizen.Applications/Tizen.Applications/Context.cs
Tizen.Applications/Tizen.Applications/Controller.cs [new file with mode: 0755]
Tizen.Applications/Tizen.Applications/Service.cs [deleted file]
Tizen.Applications/Tizen.Applications/ServiceController.cs [new file with mode: 0755]
Tizen.Applications/Tizen.Applications/UIController.cs [new file with mode: 0755]
Tizen.Applications/Tizen.UI/IUIContext.cs [new file with mode: 0755]
Tizen.Applications/Tizen.UI/Window.cs
Tizen.UI/Properties/AssemblyInfo.cs [new file with mode: 0755]
Tizen.UI/Tizen.UI.csproj [new file with mode: 0755]
Tizen.UI/Tizen.UI/Window.cs [new file with mode: 0755]

index 69f10d0..84ff6c9 100755 (executable)
@@ -14,7 +14,7 @@ internal static partial class Interop
 {
     internal static partial class AppControl
     {
-        [DllImport(Libraries.Application, EntryPoint = "app_control_create", CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(Libraries.Application, EntryPoint = "app_control_create")]
         internal static extern int Create(out SafeAppControlHandle handle);
 
         [DllImport(Libraries.Application, EntryPoint = "app_control_get_app_id", CallingConvention = CallingConvention.Cdecl)]
index 489d94d..8e471b3 100755 (executable)
     <Compile Include="Interop\Interop.Libraries.cs" />
     <Compile Include="Interop\Interop.Window.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Tizen.Applications\Actor.cs" />
+    <Compile Include="Tizen.Applications\Context.cs" />
+    <Compile Include="Tizen.Applications\UIController.cs" />
     <Compile Include="Tizen.Applications\AppControl.cs" />
     <Compile Include="Tizen.Applications\AppControlFilter.cs" />
     <Compile Include="Tizen.Applications\Application.cs" />
     <Compile Include="Tizen.Applications\Bundle.cs" />
-    <Compile Include="Tizen.Applications\Context.cs" />
-    <Compile Include="Tizen.Applications\Service.cs" />
+    <Compile Include="Tizen.Applications\Controller.cs" />
+    <Compile Include="Tizen.Applications\ServiceController.cs" />
+    <Compile Include="Tizen.UI\IUIContext.cs" />
     <Compile Include="Tizen.UI\Page.cs" />
     <Compile Include="Tizen.UI\Window.cs" />
     <Compile Include="Tizen.Applications\TizenSynchronizationContext.cs" />
diff --git a/Tizen.Applications/Tizen.Applications/Actor.cs b/Tizen.Applications/Tizen.Applications/Actor.cs
deleted file mode 100755 (executable)
index fe4b8a1..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/// 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 ActorState _state = ActorState.None;
-
-        /// <summary>
-        /// 
-        /// </summary>
-        public event EventHandler Created;
-
-        /// <summary>
-        /// 
-        /// </summary>
-        public event EventHandler Started;
-
-        /// <summary>
-        /// 
-        /// </summary>
-        public event EventHandler Resumed;
-
-        /// <summary>
-        /// 
-        /// </summary>
-        public event EventHandler Paused;
-
-        /// <summary>
-        /// 
-        /// </summary>
-        public event EventHandler Destroyed;
-
-        private enum ActorState
-        {
-            None = 0,
-            Created = 1,
-            Started = 2,
-            Resumed = 3,
-            Pasued = 4
-        }
-
-        internal Guid TaskId { get; set; }
-
-        /// <summary>
-        /// 
-        /// </summary>
-        internal protected Page MainPage { get; set; }
-        
-        internal void OnCreate(Guid taskId, AppControl control)
-        {
-            if (_state != ActorState.Created)
-            {
-                TaskId = taskId;
-                _control = control;
-                _state = ActorState.Created;
-                if (Created != null)
-                {
-                    Created(this, EventArgs.Empty);
-                }
-            }
-        }
-
-        internal void OnStart()
-        {
-            if (_state != ActorState.Started)
-            {
-                _state = ActorState.Started;
-                if (Started != null)
-                {
-                    Started(this, EventArgs.Empty);
-                }
-            }
-        }
-
-        internal void OnPause()
-        {
-            if (_state != ActorState.Pasued)
-            {
-                _state = ActorState.Pasued;
-                if (Paused != null)
-                {
-                    Paused(this, EventArgs.Empty);
-                }
-            }
-        }
-
-        internal void OnResume()
-        {
-            if (_state != ActorState.Resumed)
-            {
-                _state = ActorState.Resumed;
-                if (Resumed != null)
-                {
-                    Resumed(this, EventArgs.Empty);
-                }
-                MainPage.Show();
-            }
-        }
-
-        internal void OnDestroy()
-        {
-            if (_state != ActorState.None)
-            {
-                _state = ActorState.None;
-                if (Destroyed != null)
-                {
-                    Destroyed(this, EventArgs.Empty);
-                }
-            }
-        }
-    }
-}
-
index 3b2ded9..01e5c6a 100755 (executable)
@@ -59,7 +59,7 @@ namespace Tizen.Applications
         {
             AppControlFilter f = obj as AppControlFilter;
             if (f == null) return false;
-
+            
             return (_operation == f._operation) & (_mime == f._mime) & (_uri == f._uri);
         }
 
index 0f1559e..a926fb3 100755 (executable)
@@ -22,9 +22,9 @@ namespace Tizen.Applications
     public static class Application
     {
         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 ActorStack s_actorStack = new ActorStack();
-        private static Window s_window = null;
+        private static readonly List<ServiceController> s_serviceControllerList = new List<ServiceController>();
+        private static readonly UIControllerStack s_uiControllerStack = new UIControllerStack();
+        private static Window s_defaultWindow = null;
 
         /// <summary>
         /// Occurs when the application starts.
@@ -36,11 +36,11 @@ namespace Tizen.Applications
         /// </summary>
         public static event EventHandler Exited = delegate { };
 
-        private static Actor ForegroundActor
+        private static UIController Foreground
         {
             get
             {
-                return s_actorStack.Peek();
+                return s_uiControllerStack.Peek();
             }
         }
 
@@ -58,37 +58,22 @@ namespace Tizen.Applications
             };
             ops.OnPause = (userData) =>
             {
-                if (ForegroundActor != null)
+                if (Foreground != null)
                 {
-                    ForegroundActor.OnPause();
+                    Foreground.SendPause();
                 }
             };
             ops.OnResume = (userData) =>
             {
-                if (ForegroundActor != null)
+                if (Foreground != null)
                 {
-                    ForegroundActor.OnResume();
+                    Foreground.SendResume();
                 }
             };
             ops.OnAppControl = (appControlHandle, userData) =>
             {
                 AppControl control = new AppControl(appControlHandle);
-                if (control.IsService)
-                {
-                    Type found = FindServiceInFilters(control);
-                    if (found != null)
-                    {
-                        StartService(found, control);
-                    }
-                }
-                else
-                {
-                    Type found = FindActorInFilters(control);
-                    if (found != null)
-                    {
-                        StartActor(null, found, Context.ActorFlags.NewInstance, control);
-                    }
-                }
+                StartController(null, null, control, Controller.ControlFlags.NewInstance);
             };
             ops.OnTerminate = (userData) =>
             {
@@ -112,332 +97,279 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Registers an Actor class type.
-        /// </summary>
-        /// <param name="actorType">The type of Actor class.</param>
-        public static void RegisterActor(Type actorType)
-        {
-            RegisterActor(actorType, new AppControlFilter[0] { });
-        }
-
-        /// <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(actorType, new AppControlFilter[] { filter });
-        }
-
-        /// <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)
+        /// <param name="controllerType"></param>
+        public static void RegisterController(Type controllerType)
         {
-            if (!actorType.IsSubclassOf(typeof(Actor)))
-                throw new ArgumentException(actorType.FullName + " is not a subclass of Actor.");
-
-            RegisterContext(actorType, filters);
+            RegisterController(controllerType, new AppControlFilter[0] { });
         }
 
         /// <summary>
-        /// Registers an Service class type.
+        /// 
         /// </summary>
-        /// <param name="serviceType">The type of Service class.</param>
-        public static void RegisterService(Type serviceType)
+        /// <param name="controllerType"></param>
+        /// <param name="filter"></param>
+        public static void RegisterController(Type controllerType, AppControlFilter filter)
         {
-            RegisterService(serviceType, new AppControlFilter[0] { });
+            RegisterController(controllerType, new 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)
+        /// <param name="controllerType"></param>
+        /// <param name="filters"></param>
+        public static void RegisterController(Type controllerType, AppControlFilter[] filters)
         {
-            RegisterService(serviceType, new AppControlFilter[] { filter });
-        }
-
-        /// <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 (!serviceType.IsSubclassOf(typeof(Service)))
-                throw new ArgumentException(serviceType.FullName + " is not a subclass of Service.");
-
-            RegisterContext(serviceType, filters);
-        }
-
-        internal static void StartActor(Context caller, Type actorType, Context.ActorFlags flags, AppControl control)
-        {
-            if (caller == null && actorType == null)
+            if (controllerType == null)
             {
-                throw new ArgumentNullException("actorType");
+                throw new ArgumentNullException("controllerType");
             }
 
-            Actor targetActor = null;
-
-            Actor callerActor = caller as Actor;
-            if (callerActor != null && ForegroundActor != callerActor)
-            {
-                throw new InvalidOperationException("StartActor() should be called from the foreground Actor.");
+            if (!controllerType.IsSubclassOf(typeof(UIController)) || !controllerType.IsSubclassOf(typeof(ServiceController)))
+            {                
+                throw new ArgumentException(controllerType.FullName + " is not a sub class of UIController or ServiceController.", "controllerType");
             }
 
-            if (actorType == null)
+            foreach (var prop in controllerType.GetProperties())
             {
-                actorType = FindActorInFilters(control);
-                if (actorType == null)
+                foreach (var attr in prop.GetCustomAttributes(false))
                 {
-                    throw new ArgumentException("Could not find the matched Actor.", "control");
+                    var filter = attr as AppControlFilter;
+                    if (filter != null)
+                    {
+                        s_filterMap.Add(filter, controllerType);
+                    }
                 }
             }
-
-            if (callerActor != null && !IsFlagSet(flags, Context.ActorFlags.NewInstance))
+            if (filters != null)
             {
-                targetActor = s_actorStack.FindInForegroundTask(actorType);
+                foreach (var filter in filters)
+                {
+                    s_filterMap.Add(filter, controllerType);
+                }
             }
-
-            if (s_window == null)
+        }
+        
+        internal static void StartController(Controller caller, Type controllerType, AppControl control, Controller.ControlFlags flags)
+        {
+            if (control == null)
             {
-                s_window = new Window();
+                throw new ArgumentNullException("control");
             }
 
-            if (!s_window.Visible)
+            if (controllerType == null)
             {
-                s_window.Active();
-                s_window.Show();
+                controllerType = FindControllerInFilterMap(control);
+                if (controllerType == null)
+                {
+                    throw new ArgumentException("Could not find any matched controller.", "controllerType");
+                }
             }
 
-            if (targetActor == null)
-            {
-                targetActor = (Actor)Activator.CreateInstance(actorType);
-                targetActor.OnCreate(callerActor != null ? callerActor.TaskId : Guid.NewGuid(), control);
-                s_actorStack.Push(targetActor);
-            }
-            else
+            if (controllerType.IsSubclassOf(typeof(UIController)))
             {
-                if (IsFlagSet(flags, Context.ActorFlags.ClearTop))
+                UIController target = null;
+                UIController uiCaller = caller as UIController;
+                if (uiCaller != null && uiCaller != Foreground)
                 {
-                    while (targetActor != ForegroundActor)
-                    {
-                        Actor popped = s_actorStack.Pop();
-                        popped.OnPause();
-                        popped.OnDestroy();
-                    }
+                    throw new InvalidOperationException("Starting UIController should be called from the foreground.");
                 }
-                else if (IsFlagSet(flags, Context.ActorFlags.MoveToTop))
+                if (uiCaller != null && !IsFlagSet(flags, Controller.ControlFlags.NewInstance))
                 {
-                    if (ForegroundActor != targetActor)
-                    {
-                        ForegroundActor.OnPause();
-                        s_actorStack.MoveToTop(targetActor);
-                    }
+                    target = s_uiControllerStack.FindInForegroundTask(controllerType);
                 }
-            }
-            ForegroundActor.OnStart();
-            ForegroundActor.OnResume();
-        }
 
-        internal static void StopActor(Actor actor)
-        {
-            if (ForegroundActor == null)
-            {
-                throw new InvalidOperationException("The Actor stack is empty.");
-            }
 
-            Guid prevForegroundTaskId = ForegroundActor.TaskId;
+                if (s_defaultWindow == null)
+                {
+                    s_defaultWindow = new Window();
+                }
 
-            s_actorStack.Remove(actor);
-            actor.OnPause();
-            actor.OnDestroy();
+                if (!s_defaultWindow.Visible)
+                {
+                    s_defaultWindow.Active();
+                    s_defaultWindow.Show();
+                }
 
-            if (actor.TaskId == prevForegroundTaskId)
-            {
-                if (ForegroundActor.TaskId == actor.TaskId)
+                if (target == null)
                 {
-                    ForegroundActor.OnResume();
+                    target = (UIController)Activator.CreateInstance(controllerType);
+                    target.TaskId = uiCaller == null ? Guid.NewGuid() : uiCaller.TaskId;
+                    target.Window = s_defaultWindow;
+                    target.SendCreate();
+                    s_uiControllerStack.Push(target);
                 }
                 else
                 {
-                    if (s_actorStack.Count == 0 && s_serviceList.Count == 0)
+                    if (IsFlagSet(flags, Controller.ControlFlags.ClearTop))
                     {
-                        Exit();
+                        while (target != Foreground)
+                        {
+                            UIController popped = s_uiControllerStack.Pop();
+                            popped.SendPause();
+                            popped.SendDestroy();
+                        }
                     }
-                    else
+                    else if (IsFlagSet(flags, Controller.ControlFlags.MoveToTop))
                     {
-                        s_window.Hide();
+                        if (Foreground != target)
+                        {
+                            Foreground.SendPause();
+                            s_uiControllerStack.MoveToTop(target);
+                        }
                     }
                 }
+                Foreground.SendStart(control);
+                Foreground.SendResume();
             }
-        }
-
-        internal static void StartService(Type serviceType, AppControl control)
-        {
-            if (serviceType == null)
+            else if (controllerType.IsSubclassOf(typeof(ServiceController)))
             {
-                serviceType = FindServiceInFilters(control);
-                if (serviceType == null)
+                ServiceController svc = s_serviceControllerList.Find(s => s.GetType() == controllerType);
+                if (svc == null)
                 {
-                    throw new ArgumentException("Could not find the matched Service.", "control");
+                    svc = (ServiceController)Activator.CreateInstance(controllerType);
+                    s_serviceControllerList.Add(svc);
+                    svc.SendCreate();
                 }
+                svc.SendStart(control);
             }
             else
             {
-                if (!serviceType.IsSubclassOf(typeof(Service)))
-                {
-                    throw new ArgumentException(serviceType.FullName + " is not a subclass of Service.", "serviceType");
-                }
+                throw new ArgumentException("Invalid controller type.", "controllerType");
             }
-
-            Service svc = s_serviceList.Find(s => s.GetType() == serviceType);
-            if (svc == null)
-            {
-                svc = (Service)Activator.CreateInstance(serviceType);
-                s_serviceList.Add(svc);
-                svc.OnCreate(control);
-            }
-            svc.OnStart();
         }
 
-        internal static void StopService(Type serviceType)
+        internal static void StopController(UIController target)
         {
-            if (!serviceType.IsSubclassOf(typeof(Service)))
+            if (Foreground == null)
             {
-                throw new ArgumentException(serviceType.FullName + " is not a subclass of Service.");
+                throw new InvalidOperationException("The UIController stack is empty.");
             }
 
-            Service svc = s_serviceList.Find(s => s.GetType() == serviceType);
-            if (svc != null)
+            Guid prevForegroundTaskId = Foreground.TaskId;
+
+            s_uiControllerStack.Remove(target);
+            target.SendPause();
+            target.SendDestroy();
+            if (target.TaskId == prevForegroundTaskId)
             {
-                svc.OnDestroy();
-                s_serviceList.Remove(svc);
-                if (ForegroundActor == null && s_serviceList.Count == 0)
+                if (Foreground.TaskId == target.TaskId)
                 {
-                    Exit();
+                    Foreground.SendResume();
                 }
-            }
-        }
-
-        internal static void Finish(Context caller)
-        {
-            if (caller is Actor)
-            {
-                StopActor(caller as Actor);
-            }
-            else if (caller is Service)
-            {
-                // TODO: check the value of GetType()
-                StopService(caller.GetType());
-            }
-        }
-
-        private static Type FindActorInFilters(AppControl control)
-        {
-            foreach (var item in s_filterMap)
-            {
-                if (item.Key.IsMatch(control) && item.Value.IsSubclassOf(typeof(Actor)))
+                else
                 {
-                    return item.Value;
+                    if (s_uiControllerStack.Count == 0 && s_serviceControllerList.Count == 0)
+                    {
+                        Exit();
+                    }
+                    else
+                    {
+                        s_defaultWindow.Hide();
+                    }
                 }
             }
-            return null;
         }
 
-        private static Type FindServiceInFilters(AppControl control)
+        internal static void StopController(Type controllerType)
         {
-            foreach (var item in s_filterMap)
-            {
-                if (item.Key.IsMatch(control) && item.Value.IsSubclassOf(typeof(Service)))
+            if (controllerType.IsSubclassOf(typeof(UIController)))
+            {                
+                UIController target = s_uiControllerStack.Find(controllerType);
+                if (target == null)
                 {
-                    return item.Value;
+                    throw new InvalidOperationException("Could not find the UIController to stop.");
                 }
+                StopController(target);
             }
-            return null;
-        }
-
-        private static void RegisterContext(Type contextType, AppControlFilter[] filters)
-        {
-            foreach (var prop in contextType.GetProperties())
+            else if (controllerType.IsSubclassOf(typeof(ServiceController)))
             {
-                foreach (var attr in prop.GetCustomAttributes(false))
+                ServiceController svc = s_serviceControllerList.Find(s => s.GetType() == controllerType);
+                if (svc != null)
                 {
-                    var filter = attr as AppControlFilter;
-                    if (filter != null)
+                    svc.SendDestroy();
+                    s_serviceControllerList.Remove(svc);
+                    if (s_uiControllerStack.Count == 0 && s_serviceControllerList.Count == 0)
                     {
-                        s_filterMap.Add(filter, contextType);
+                        Exit();
                     }
                 }
             }
-            if (filters != null)
+        }
+        
+        private static Type FindControllerInFilterMap(AppControl control)
+        {            
+            foreach (var item in s_filterMap)
             {
-                foreach (var filter in filters)
+                if (item.Key.IsMatch(control))
                 {
-                    s_filterMap.Add(filter, contextType);
+                    return item.Value;
                 }
             }
+            return null;
         }
-
-        private static bool IsFlagSet(Context.ActorFlags flags, Context.ActorFlags values)
+        
+        private static bool IsFlagSet(Controller.ControlFlags flags, Controller.ControlFlags values)
         {
             return (values & flags) == values;
         }
 
 
-        private class ActorStack
+        private class UIControllerStack
         {
-            private readonly List<Actor> _actorList;
+            private readonly List<UIController> _uiControllerList;
 
             public int Count
             {
                 get
                 {
-                    return _actorList.Count;
+                    return _uiControllerList.Count;
                 }
             }
 
-            public ActorStack()
+            public UIControllerStack()
             {
-                _actorList = new List<Actor>();
+                _uiControllerList = new List<UIController>();
             }
 
-            public Actor Peek()
+            public UIController Peek()
             {
-                return _actorList.LastOrDefault(null);
+                return _uiControllerList.LastOrDefault(null);
             }
 
-            public void Push(Actor item)
+            public void Push(UIController item)
             {
-                _actorList.Add(item);
+                _uiControllerList.Add(item);
             }
 
-            public Actor Pop()
+            public UIController Pop()
             {
-                Actor last = Peek();
-                _actorList.Remove(last);
+                UIController last = Peek();
+                _uiControllerList.Remove(last);
                 return last;
             }
 
-            public void Remove(Actor actor)
+            public void Remove(UIController actor)
+            {
+                _uiControllerList.Remove(actor);
+            }
+
+            public UIController Find(Type controllerType)
             {
-                _actorList.Remove(actor);
+                return _uiControllerList.Find(s => s.GetType() == controllerType);
             }
 
-            public Actor FindInForegroundTask(Type actorType)
+            public UIController FindInForegroundTask(Type controllerType)
             {
-                return _actorList.Find(s => s.GetType() == actorType && s.TaskId == Peek().TaskId);
+                return _uiControllerList.Find(s => s.GetType() == controllerType && s.TaskId == Peek().TaskId);
             }
 
-            public void MoveToTop(Actor actor)
+            public void MoveToTop(UIController actor)
             {
-                _actorList.Remove(actor);
-                _actorList.Add(actor);
+                _uiControllerList.Remove(actor);
+                _uiControllerList.Add(actor);
             }
         }
     }
index 7e0a786..2e28752 100755 (executable)
@@ -1,13 +1,9 @@
-/// 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.IO;
 
 namespace Tizen.Applications
 {
@@ -16,91 +12,48 @@ namespace Tizen.Applications
     /// </summary>
     public abstract class Context
     {
-        internal AppControl _control;
-        
-        [Flags]
-        public enum ActorFlags
-        {
-            NewInstance = 1,
-            ClearTop = 2,
-            MoveToTop = 4,
-        }
-
         /// <summary>
         /// 
         /// </summary>
-        protected AppControl AppControl
+        public string ApplicationId
         {
             get
             {
-                return _control;
+                throw new NotImplementedException();
             }
         }
 
         /// <summary>
         /// 
         /// </summary>
-        /// <param name="actorType"></param>
-        /// <param name="control"></param>
-        protected void StartActor(Type actorType, AppControl control, ActorFlags flags = ActorFlags.NewInstance)
-        {
-            Application.StartActor(this, actorType, ActorFlags.NewInstance, control);
-        }
-
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="control"></param>
-        /// <param name="flags"></param>
-        protected void StartActor(AppControl control, ActorFlags flags = ActorFlags.NewInstance)
-        {
-            Application.StartActor(this, null, ActorFlags.NewInstance, 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="control"></param>
-        protected void StartService(AppControl control)
-        {
-            Application.StartService(null, control);
-        }
-
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="serviceType"></param>
-        protected void StopService(Type serviceType)
+        public string ApplicationName
         {
-            Application.StopService(serviceType);
+            get
+            {
+                throw new NotImplementedException();
+            }
         }
 
         /// <summary>
         /// 
         /// </summary>
-        protected void Finish()
+        public string ApplicationVersion
         {
-            Application.Finish(this);
+            get
+            {
+                throw new NotImplementedException();
+            }
         }
 
         /// <summary>
         /// 
         /// </summary>
-        /// <param name="control"></param>
-        /// <param name="destination"></param>
-        protected void SendAppControl(AppControl control, string destination)
+        public IReadOnlyDictionary<string, string> ApplicationPath
         {
-            throw new NotImplementedException();
+            get
+            {
+                throw new NotImplementedException();
+            }
         }
     }
 }
diff --git a/Tizen.Applications/Tizen.Applications/Controller.cs b/Tizen.Applications/Tizen.Applications/Controller.cs
new file mode 100755 (executable)
index 0000000..6319dc0
--- /dev/null
@@ -0,0 +1,117 @@
+/// 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 Controller : Context
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        [Flags]
+        public enum ControlFlags
+        {
+            NewInstance = 1,
+            ClearTop = 2,
+            MoveToTop = 4,
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        protected AppControl AppControl { get; private set; }
+
+        internal virtual void SendCreate()
+        {
+            AppControl = null;
+            OnCreate();
+        }
+
+        internal virtual void SendStart(AppControl control)
+        {
+            AppControl = control;
+            OnStart();
+        }
+
+        internal virtual void SendDestroy()
+        {
+            OnDestroy();
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        protected virtual void OnCreate()
+        {
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        protected virtual void OnStart()
+        {
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        protected virtual void OnDestroy()
+        {
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="control"></param>
+        /// <param name="flags"></param>
+        protected void StartController(AppControl control, ControlFlags flags = ControlFlags.NewInstance)
+        {
+            Application.StartController(this, null, control, flags);
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="controllerType"></param>
+        /// <param name="control"></param>
+        /// <param name="flags"></param>
+        protected void StartController(Type controllerType, AppControl control, ControlFlags flags = ControlFlags.NewInstance)
+        {
+            Application.StartController(this, controllerType, control, flags);
+        }
+
+        protected void StopController(Type controllerType)
+        {
+            Application.StopController(controllerType);
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        protected virtual void Finish()
+        {
+            Application.StopController(GetType());
+        }
+
+        /// <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/Service.cs b/Tizen.Applications/Tizen.Applications/Service.cs
deleted file mode 100755 (executable)
index de274c8..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/// 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>
-        public event EventHandler Created;
-
-        /// <summary>
-        /// 
-        /// </summary>
-        public event EventHandler Started;
-
-        /// <summary>
-        /// 
-        /// </summary>
-        public event EventHandler Destroyed;
-
-        internal void OnCreate(AppControl control)
-        {
-            _control = control;
-            if (Created != null)
-            {
-                Created(this, EventArgs.Empty);
-            }
-        }
-
-        internal void OnStart()
-        {
-            if (Started != null)
-            {
-                Started(this, EventArgs.Empty);
-            }
-        }
-
-        internal void OnDestroy()
-        {
-            if (Destroyed != null)
-            {
-                Destroyed(this, EventArgs.Empty);
-            }
-        }
-    }
-}
diff --git a/Tizen.Applications/Tizen.Applications/ServiceController.cs b/Tizen.Applications/Tizen.Applications/ServiceController.cs
new file mode 100755 (executable)
index 0000000..906de6e
--- /dev/null
@@ -0,0 +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;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public abstract class ServiceController : Controller
+    {
+    }
+}
diff --git a/Tizen.Applications/Tizen.Applications/UIController.cs b/Tizen.Applications/Tizen.Applications/UIController.cs
new file mode 100755 (executable)
index 0000000..a7f56c3
--- /dev/null
@@ -0,0 +1,101 @@
+/// 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 UIController : Controller, IUIContext
+    {
+        private bool _isResumed = false;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public event EventHandler Resumed;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public event EventHandler Paused;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public Window Window { get; internal set; }
+
+        internal Guid TaskId { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        protected internal Page MainPage { get; set; }
+
+        public string ResolveResourcePath(string res)
+        {
+            throw new NotImplementedException();
+        }
+
+        internal override void SendCreate()
+        {
+            Window = OnPrepareWindow();
+            base.SendCreate();
+        }
+
+        internal void SendPause()
+        {
+            if (_isResumed)
+            {
+                if (Paused != null)
+                {
+                    OnPause();
+                    Paused(this, EventArgs.Empty);
+                }
+                _isResumed = false;
+            }
+        }
+
+        internal void SendResume()
+        {
+            if (!_isResumed)
+            {
+                if (Resumed != null)
+                {
+                    OnResume();
+                    Resumed(this, EventArgs.Empty);
+                }
+                _isResumed = true;
+                MainPage.Show();
+            }
+        }
+
+        protected virtual Window OnPrepareWindow()
+        {
+            return Window;
+        }
+
+        protected virtual void OnResume()
+        {
+        }
+
+        protected virtual void OnPause()
+        {
+        }
+
+        protected override void Finish()
+        {
+            Application.StopController(this);
+        }
+    }
+}
+
diff --git a/Tizen.Applications/Tizen.UI/IUIContext.cs b/Tizen.Applications/Tizen.UI/IUIContext.cs
new file mode 100755 (executable)
index 0000000..c676f6a
--- /dev/null
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.UI
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    interface IUIContext
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        Window Window { get; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="res"></param>
+        /// <returns></returns>
+        string ResolveResourcePath(string res);
+    }
+}
index e2e134b..3fd9a20 100755 (executable)
@@ -11,7 +11,7 @@ using System;
 
 namespace Tizen.UI
 {
-    internal class Window : IDisposable
+    public class Window : IDisposable
     {
         private IntPtr _native_window = IntPtr.Zero;
 
diff --git a/Tizen.UI/Properties/AssemblyInfo.cs b/Tizen.UI/Properties/AssemblyInfo.cs
new file mode 100755 (executable)
index 0000000..5c1dc2b
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 
+// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
+// 이러한 특성 값을 변경하세요.
+[assembly: AssemblyTitle("Tizen.UI")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("Tizen.UI")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 
+// 표시되지 않습니다.  COM에서 이 어셈블리의 형식에 액세스하려면 
+// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
+[assembly: ComVisible(false)]
+
+// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
+[assembly: Guid("729a2031-f2bd-4784-9ba1-ebd057add72c")]
+
+// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
+//
+//      주 버전
+//      부 버전 
+//      빌드 번호
+//      수정 버전
+//
+// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 
+// 지정되도록 할 수 있습니다.
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tizen.UI/Tizen.UI.csproj b/Tizen.UI/Tizen.UI.csproj
new file mode 100755 (executable)
index 0000000..3f0415a
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{729A2031-F2BD-4784-9BA1-EBD057ADD72C}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Tizen.UI</RootNamespace>
+    <AssemblyName>Tizen.UI</AssemblyName>
+    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Tizen.UI\Window.cs" />
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
diff --git a/Tizen.UI/Tizen.UI/Window.cs b/Tizen.UI/Tizen.UI/Window.cs
new file mode 100755 (executable)
index 0000000..d23339f
--- /dev/null
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.UI
+{
+    public class Window : Tizen.Applications.IWindow
+    {
+    }
+}