public static void EnsureRunning(int timeoutInMilliseconds) { if (EmulatorProcessController.IsRunning()) { EmulatorProcessController.InternalWaitForStorageEmulator(timeoutInMilliseconds); throw new EmulatorException(EmulatorErrorCode.AlreadyRunning); } ProcessWrapper processWrapper = new ProcessWrapper("AzureStorageEmulator.exe", "start /InProcess"); if (timeoutInMilliseconds == 0) { processWrapper.EnsureStarted(); return; } bool flag = false; StringBuilder stringBuilder = new StringBuilder(); if (!CheckStoragePrerequisites.CheckPrerequisites((string msg) => stringBuilder.Append(msg), out flag)) { if (!flag) { string str = stringBuilder.ToString(); if (!string.IsNullOrEmpty(str)) { throw new EmulatorException(EmulatorErrorCode.StartFailed, str); } throw new EmulatorException(EmulatorErrorCode.StartFailed); } try { Initialization initialization = new Initialization(false, false, true, null, null, false, false); initialization.PerformEmulatorInitialization(); } catch (Exception exception) { throw new EmulatorException(EmulatorErrorCode.InitializationRequired, exception); } } processWrapper.EnsureStarted(); EmulatorProcessController.InternalWaitForStorageEmulator(timeoutInMilliseconds); }
public static bool CheckPrerequisites(Action <string> showErrorMessage, out bool fixWithInit) { string str; fixWithInit = false; PrerequisiteCheckResult prerequisiteCheckResult = CheckStoragePrerequisites.CheckSqlInstanceAndDatabase(out str); if (prerequisiteCheckResult == PrerequisiteCheckResult.DatabaseNotInstalledOrLoginFailed || prerequisiteCheckResult == PrerequisiteCheckResult.SqlExpressInstanceNotInstalledOrRunning) { fixWithInit = true; return(false); } prerequisiteCheckResult = PrerequisiteCheckResult.None; prerequisiteCheckResult = CheckStoragePrerequisites.CheckDbAccess(str); if (prerequisiteCheckResult == PrerequisiteCheckResult.NoDatabaseAccess) { fixWithInit = true; return(false); } fixWithInit = false; return(CheckStoragePrerequisites.CheckPortReservation(showErrorMessage)); }