// ======================================== // static method // ======================================== static MemopadConstsV2() { var localAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); var appDataRoot = Path.Combine(localAppDataFolder, @"mocha\MochaNote\2.0"); BootstrapSettingsFilePath = Path.Combine(appDataRoot, @"bootstrap.xml"); BootstrapSettings = BootstrapSettings.LoadBootstrapSettings(BootstrapSettingsFilePath); /// MemoRootの初期化 /// bootstrap.xmlからMemoRoot取得 if (string.IsNullOrEmpty(BootstrapSettings.MemoRoot)) { BootstrapSettings.MemoRoot = Path.Combine(appDataRoot, @"note"); } MemoRoot = BootstrapSettings.MemoRoot; try { PathUtil.EnsureDirectoryExists(MemoRoot); } catch (Exception e) { Logger.Error("Can't create MemoRoot folder", e); try { /// デフォルトの設定でやり直す BootstrapSettings.MemoRoot = Path.Combine(appDataRoot, @"note"); MemoRoot = BootstrapSettings.MemoRoot; //UseCommandLineMemoRoot = false; PathUtil.EnsureDirectoryExists(MemoRoot); } catch (Exception ex) { Logger.Error("Can't create Default MemoRoot folder", ex); throw; } } LockFileName = "lock"; LockFilePath = Path.Combine(MemoRoot, LockFileName); LogRoot = Path.Combine(MemoRoot, LogRootName); EmbeddedRoot = Path.Combine(MemoRoot, EmbeddedRootName); EmbeddedFileRoot = Path.Combine(EmbeddedRoot, "file"); EmbeddedImageRoot = Path.Combine(EmbeddedRoot, "image"); MemoFilePath = Path.Combine(MemoRoot, MemoFileName); ExtendedDataFilePath = Path.Combine(MemoRoot, ExtendedDataFileName); SettingsFilePath = Path.Combine(MemoRoot, "settings.xml"); WindowSettingsFilePath = Path.Combine(MemoRoot, "window." + Environment.MachineName + ".xml"); RecentlyClosedMemoIdsFilePath = Path.Combine(MemoRoot, "recentlyclosed.xml"); RecentlyCreatedMemoIdsFilePath = Path.Combine(MemoRoot, "recentlycreated.xml"); RecentlyModifiedMemoIdsFilePath = Path.Combine(MemoRoot, "recentlymodified.xml"); }
static void OnRuntimeInitializedBeforeSceneLoad() { BootstrapSettings bootstrapSettings = Resources.Load <BootstrapSettings>(BOOTSTRAP_SETTINGS); if (bootstrapSettings == null) { Debug.LogError("Bootstrap Settings can't be found in any Resources folder"); return; } Debug.Log("Bootstrap.OnRuntimeInitializedBeforeSceneLoad"); Debug.Log("Cloning preload global objects"); foreach (GameObject o in bootstrapSettings.preloadObjects) { DontDestroyOnLoad(Instantiate(o)); } SceneManager.LoadScene(bootstrapSettings.firstSceneName); }
// ======================================== // constructor // ======================================== public FolderSettingsDetailPage(BootstrapSettings bootstrapSettings, MemopadWindowSettings windowSettings) { InitializeComponent(); _bootstrapSettings = bootstrapSettings; _windowSettings = windowSettings; _memoRootTextBox.Text = _bootstrapSettings.MemoRoot; _backupRootTextBox.Text = _windowSettings.BackupRoot; _memoRootTextBox.TextChanged += HandleTextBoxTextChanged; _backupRootTextBox.TextChanged += HandleTextBoxTextChanged; _isModified = false; if (MemopadConsts.UseCommandLineMemoRoot) { _memoRootLabel.Enabled = false; _memoRootTextBox.Enabled = false; _memoRootButton.Enabled = false; } }
//internal static readonly string TutorialPath = Path.Combine(Application.StartupPath, @"Help\Tutorial\start_tutorial.html"); //#if DEBUG // internal static readonly string LatestUrl = "http://www.confidante.jp/file/latest_debug.txt"; //#else // internal static readonly string LatestUrl = "http://www.confidante.jp/file/latest.txt"; //#endif /// MemoTextの図形のLocationと一番最初の文字の左上の点との差 /// MemoTextのPaddingとBlockのMargin/Paddingで値を足したものの符号をマイナスにしたもの /// BlockのLineSpaceはひかない? //internal static readonly Size MemoTextFirstCharDelta = new Size(-4, -4); //internal static readonly int BlockLineSpace = 2; /// <summary> /// caret初期位置. /// </summary> //internal static readonly Point DefaultCaretPosition = new Point(16, 16); /// <summary> /// caret移動量 /// </summary> //internal const int CaretMoveDelta = 16; // ======================================== // static method // ======================================== static MemopadConstsV1() { var localAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); var appDataRoot = Path.Combine(localAppDataFolder, @"mkamo\Confidante\1.0"); BootstrapSettingsFilePath = Path.Combine(appDataRoot, @"bootstrap.xml"); BootstrapSettings = BootstrapSettings.LoadBootstrapSettings(BootstrapSettingsFilePath); /// MemoRootの初期化 //var clArgs = System.Environment.GetCommandLineArgs(); //if (clArgs != null && clArgs.Length > 1) { // /// コマンドライン引数からMemoRoot取得 // MemoRoot = clArgs[1]; // UseCommandLineMemoRoot = true; //} else { /// bootstrap.xmlからMemoRoot取得 if (string.IsNullOrEmpty(BootstrapSettings.MemoRoot)) { BootstrapSettings.MemoRoot = Path.Combine(appDataRoot, @"memo"); } MemoRoot = BootstrapSettings.MemoRoot; //UseCommandLineMemoRoot = false; //} //try { // PathUtil.EnsureDirectoryExists(MemoRoot); //} catch (Exception e) { // Logger.Error("Can't create MemoRoot folder", e); // try { // /// デフォルトの設定でやり直す // BootstrapSettings.MemoRoot = Path.Combine(appDataRoot, @"memo"); // MemoRoot = BootstrapSettings.MemoRoot; // //UseCommandLineMemoRoot = false; // PathUtil.EnsureDirectoryExists(MemoRoot); // } catch (Exception ex) { // Logger.Error("Can't create Default MemoRoot folder", ex); // throw; // } //} LockFileName = "lock"; LockFilePath = Path.Combine(MemoRoot, LockFileName); ModelRoot = Path.Combine(MemoRoot, ModelRootName); MementoRoot = Path.Combine(MemoRoot, MementoRootName); LogRoot = Path.Combine(MemoRoot, LogRootName); EmbeddedRoot = Path.Combine(MemoRoot, EmbeddedRootName); EmbeddedFileRoot = Path.Combine(EmbeddedRoot, "file"); SettingsFilePath = Path.Combine(MemoRoot, "settings.xml"); WindowSettingsFilePath = Path.Combine(MemoRoot, "window." + Environment.MachineName + ".xml"); MemoInfosFilePath = Path.Combine(MemoRoot, MemoInfosFileName); RemovedMemoInfosFilePath = Path.Combine(MemoRoot, RemovedMemoInfosFileName); RemovedEmbeddedFileIdsFilePath = Path.Combine(MemoRoot, RemovedEmbeddedFileIdsFileName); RecentlyClosedMemoIdsFilePath = Path.Combine(MemoRoot, "recentlyclosed.xml"); RecentlyCreatedMemoIdsFilePath = Path.Combine(MemoRoot, "recentlycreated.xml"); RecentlyModifiedMemoIdsFilePath = Path.Combine(MemoRoot, "recentlymodified.xml"); ProxyRoot = Path.Combine(appDataRoot, "proxy"); ProxyAssemblyFilePath = Path.Combine(ProxyRoot, ProxyAssemblyName + ".dll"); //BackupRoot = Path.Combine(appDataRoot, "backup"); StartUpShortcutFilePath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Startup), "Confidante.lnk" ); }
public static T Prepare <T>(this IRegistry registry, IFrontendNotifier frontendNotifier, Func <string, IErrorsInbox, IVisibilityPersistor, IBackendNotifier> frontendBackendNotifierCreator, Func <IBackendNotifier> backendFrontendNotifierCreator, Func <IFrontendQueriesFactory, IBackendQueriesFactory, IErrorsInbox, IVisibilityPersistor, IBackendNotifier, T> resultor, IIdentityProvider identityProvider, BootstrapSettings settings) { var ebl = new InMemoryErrorsBacklog(); var fei = new QueuedErrorsInbox(ebl); var bei = new QueuedErrorsInbox(); //for backend only var ds = settings.VisibilityStoreBuilder != null ? settings.VisibilityStoreBuilder() : new InMemoryVisibilityStore(); var dh = new VisibilityHolder(ds); var fqf = new FrontendQueriesFactory(fei, bei, ebl, ebl, dh, dh, frontendNotifier, () => new FrontendErrorsQuery(), () => new RecapsQuery()); var ben = settings.Side == Side.Frontend && !string.IsNullOrWhiteSpace(settings.TargetBackendEndpoint) ? frontendBackendNotifierCreator(settings.TargetBackendEndpoint, bei, dh) : settings.Side == Side.Backend ? backendFrontendNotifierCreator() : NullBackendNotifier.Instance; var bqf = new BackendQueriesFactory(fei, ebl, ebl, dh, dh, ben, () => new BackendErrorsQuery(), () => new VisibilityQuery(settings.Side == Side.Frontend)); //Infrastructure registry.Register(typeof(IErrorsBacklog), () => ebl); registry.Register(typeof(IErrorsInbox), () => fei); registry.Register(typeof(IVisibilityPublisher), () => dh); registry.Register(typeof(IVisibilityPersistor), () => dh); registry.Register(typeof(IVisibilityStore), () => ds); registry.Register(typeof(IFrontendQueriesFactory), () => fqf); registry.Register(typeof(IBackendQueriesFactory), () => bqf); return(resultor(fqf, bqf, fei, dh, ben)); }
/// <summary>Starts CouchDB initialization task.</summary> public static Task<CouchDBWatchdog> Start() { if (!RoleEnvironment.IsAvailable) throw new InvalidOperationException( "This should be used in Windows Azure role environment only"); // Reading and validating all configuration var couchDBDistributive = RoleEnvironment.GetConfigurationSettingValue(CouchDBDistributiveConfigOption); var couchDBLuceneDistributive = RoleEnvironment.GetConfigurationSettingValue(CouchDBLuceneDistributiveConfigOption); var jreDistributive = RoleEnvironment.GetConfigurationSettingValue(JreDistributiveConfigOption); var localIPEndPoint = GetLocalIPEndPoint(); var endpointsToReplicateTo = GetCouchDBEndpoints(localIPEndPoint.Port).ToArray(); var databasesToReplicate = RoleEnvironment .GetConfigurationSettingValue(DatabasesToReplicateConfigOption) .Split(new []{';'}, StringSplitOptions.RemoveEmptyEntries); var binariesResource = RoleEnvironment.GetLocalResource(BinariesResourceName); var logResource = RoleEnvironment.GetLocalResource(LogResourceName); var tempResource = RoleEnvironment.GetLocalResource(TempResourceName); var tempDir = new DirectoryInfo(tempResource.RootPath); var useCloudDrive = bool.Parse(RoleEnvironment.GetConfigurationSettingValue(UseCloudDriveConfigOption)); CloudDriveSettings cloudDriveSettings = null; LocalResource dataResource = null; if (useCloudDrive) cloudDriveSettings = CloudDriveSettings.Read(); else dataResource = RoleEnvironment.GetLocalResource(DataResourceName); return Task.Factory.StartNew( () => { // Preparing environment var logDir = new DirectoryInfo(logResource.RootPath); var binDir = new DirectoryInfo(binariesResource.RootPath); var getCouchDBDistributiveTask = GetFileTask.Start(tempDir, couchDBDistributive); var getCouchDBLuceneDistributiveTask = GetFileTask.Start(tempDir, couchDBLuceneDistributive); var getJreDistributiveTask = GetFileTask.Start(tempDir, jreDistributive); var getDataDirTask = useCloudDrive ? Task.Factory.StartNew(() => InitCloudDrive(cloudDriveSettings)) : Task.Factory.StartNew(() => new DirectoryInfo(dataResource.RootPath)); // Waiting for all prepare tasks to finish Task.WaitAll( getCouchDBDistributiveTask, getCouchDBLuceneDistributiveTask, getJreDistributiveTask, getDataDirTask); var bootstrapSettings = new BootstrapSettings { CouchDBDistributive = getCouchDBDistributiveTask.Result, CouchDBLuceneDistributive = getCouchDBLuceneDistributiveTask.Result, JavaDistributive = getJreDistributiveTask.Result, CouchDBLucenePort = localIPEndPoint.Port + 42, // hardcoded, but it's only matter within instance BinDirectory = binDir, DataDirectory = getDataDirTask.Result, LogDirectory = logDir, EndpointToListenOn = localIPEndPoint, SetupCouchDBLucene = true, // For some reason this is requried to run CouchDB in Azure or even devfabric UseShellExecute = true }; bootstrapSettings.ReplicationSettings.DatabasesToReplicate = databasesToReplicate; bootstrapSettings.ReplicationSettings.EndPointsToReplicateTo = endpointsToReplicateTo; return CouchDBBootstraper.Bootstrap(bootstrapSettings); }) .ContinueWith(t => { if(t.IsFaulted && t.Exception != null) { const string errorDescription = "Error occured initializing CouchDB"; WriteBackupFile(errorDescription, t.Exception); Log.Error(errorDescription, t.Exception); } else Log.Info("CouchDB started"); return t.Result; }); }
private static ChefBootstrapper CreateChefBootstrapper(string config, string validator, BootstrapSettings bootstrapSettings) { return(new ChefBootstrapper(StructureMapResolver.Container.GetInstance <IFileSystemCommands>(), config, validator, bootstrapSettings)); }