Example #1
0
 /// <summary>
 /// Clear the current instance of the AutomationSession object
 /// </summary>
 /// <exception cref="A11yAutomationException">Thrown if session object does not exist</exception>
 internal static void ClearInstance()
 {
     lock (lockObject)
     {
         if (instance == null)
         {
             throw new A11yAutomationException(DisplayStrings.ErrorNotStarted_Clear);
         }
         instance.Cleanup();
         instance = null;
     }
 }
Example #2
0
        /// <summary>
        /// Obtain a new instance of the AutomationSession object. Only one can exist at a time
        /// </summary>
        /// <param name="parameters">The parameters to associate with the object</param>
        /// <param name="customAssemblyResolver">The custom assembly resolver</param>
        /// <exception cref="A11yAutomationException">Thrown if session already exists</exception>
        /// <returns>The current AutomationSession object</returns>
        internal static AutomationSession NewInstance(CommandParameters parameters, IDisposable customAssemblyResolver)
        {
            lock (lockObject)
            {
                if (instance != null)
                {
                    throw new A11yAutomationException(DisplayStrings.ErrorAlreadyStarted);
                }

                instance = new AutomationSession(parameters, customAssemblyResolver);
                instance.SessionParameters = parameters;

                return(instance);
            }
        }
Example #3
0
 internal static StartCommandResult Execute(Dictionary <string, string> primaryConfig, string configFile, bool isPowerShell)
 {
     return(ExecutionWrapper.ExecuteCommand(() =>
     {
         // Custom assembly resolver needs to be created before anything else, but only for PowerShell
         IDisposable customAssemblyResolver = isPowerShell ? new CustomAssemblyResolver() : null;
         CommandParameters parameters = new CommandParameters(primaryConfig, configFile);
         AutomationSession.NewInstance(parameters, customAssemblyResolver);
         return new StartCommandResult
         {
             Completed = true,
             SummaryMessage = DisplayStrings.SuccessStart,
             Succeeded = true,
         };
     }, ErrorCommandResultFactory));
 }