示例#1
0
 /// <summary>
 /// Private constructor(for singleton)
 /// </summary>
 private SystemLogicLayer()
 {
     _userInterface = null;
     UiNotification = new NotificationQueue();
     SllNotification = new NotificationQueue();
     UiPriorityNotification = new NotificationQueue();
     _pathTable = new PathTable();
     _switchingTable = new Dictionary<string, TagState>();
 }
示例#2
0
        /// <summary>
        /// Check the program folder if Syncless have write access.
        /// </summary>
        /// <param name="inf">The user interface.</param>
        /// <returns>true if Syncless have write access, otherwise false</returns>
        private bool CheckForWriteAccess(IUIInterface inf)
        {
            try
            {
                //Ensure the app folder have write access
                string path = Path.Combine(inf.getAppPath(), "temp.txt");
                FileStream stream = new FileStream(path, FileMode.Create);

                stream.Close();
                try
                {
                    FileInfo info = new FileInfo(path);
                    if (info.Exists)
                    {
                        info.Delete();
                    }
                }
                catch (Exception e)
                {
                    ServiceLocator.GetLogger(ServiceLocator.DEBUG_LOG).Write(e);
                }
            }
            catch (IOException)
            {
                return false;
            }
            return true;
        }
示例#3
0
 /// <summary>
 /// Initiate the program. This is the first command that needs to be run
 /// If this method is not run before any other method is call, the system might fail.
 /// </summary>
 /// <param name="inf">The User Interface that implements the <see cref="IUIInterface"/></param>
 /// <exception cref="UnhandledException">Unhandled Exception</exception>
 /// <returns>true if the Logic Layer successfully initialized. false if the program fail to initialize</returns>
 public bool Initiate(IUIInterface inf)
 {
     //Check if the program have write access to the root directory of The application folder.
     bool hasWriteAccess = CheckForWriteAccess(inf);
     //if does not have write access, return false.
     if (!hasWriteAccess)
     {
         return false;
     }
     try
     {
         _userInterface = inf;
         //call the internal save method.
         bool init = Initiate();
         InitiateSave();
         return init;
     }
     catch (Exception e)
     {
         //Handle some unexpected exception so that it does not hang the UI.
         ServiceLocator.GetLogger(ServiceLocator.DEBUG_LOG).Write(e);
         throw new UnhandledException(e);
     }
 }