public void InitSharpDevelopCore(SharpDevelopHost.CallbackHelper callback, StartupSettings properties) { LoggingService.Info("InitSharpDevelop..."); this.callback = callback; CoreStartup startup = new CoreStartup(properties.ApplicationName); if (properties.UseSharpDevelopErrorHandler) { this.useSharpDevelopErrorHandler = true; ExceptionBox.RegisterExceptionBoxForUnhandledExceptions(); } startup.ConfigDirectory = properties.ConfigDirectory; startup.DataDirectory = properties.DataDirectory; if (properties.PropertiesName != null) { startup.PropertiesName = properties.PropertiesName; } // disable RTL: translations for the RTL languages are inactive RightToLeftConverter.RightToLeftLanguages = new string[0]; if (properties.ApplicationRootPath != null) { FileUtility.ApplicationRootPath = properties.ApplicationRootPath; } startup.StartCoreServices(); Assembly exe = Assembly.Load(properties.ResourceAssemblyName); ResourceService.RegisterNeutralStrings(new ResourceManager("Resources.StringResources", exe)); ResourceService.RegisterNeutralImages(new ResourceManager("Resources.BitmapResources", exe)); MenuCommand.LinkCommandCreator = delegate(string link) { return(new LinkCommand(link)); }; StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider()); LoggingService.Info("Looking for AddIns..."); foreach (string file in properties.addInFiles) { startup.AddAddInFile(file); } foreach (string dir in properties.addInDirectories) { startup.AddAddInsFromDirectory(dir); } if (properties.AllowAddInConfigurationAndExternalAddIns) { startup.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml")); } if (properties.AllowUserAddIns) { startup.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"), Path.Combine(PropertyService.ConfigDirectory, "AddIns")); } LoggingService.Info("Loading AddInTree..."); startup.RunInitialization(); // Register events to marshal back Project.ProjectService.StartBuild += delegate { this.callback.StartBuild(); }; Project.ProjectService.EndBuild += delegate { this.callback.EndBuild(); }; Project.ProjectService.SolutionLoaded += delegate { this.callback.SolutionLoaded(); }; Project.ProjectService.SolutionClosed += delegate { this.callback.SolutionClosed(); }; Project.ProjectService.SolutionConfigurationChanged += delegate { this.callback.SolutionConfigurationChanged(); }; FileUtility.FileLoaded += delegate(object sender, FileNameEventArgs e) { this.callback.FileLoaded(e.FileName); }; FileUtility.FileSaved += delegate(object sender, FileNameEventArgs e) { this.callback.FileSaved(e.FileName); }; LoggingService.Info("InitSharpDevelop finished"); }
/// <summary> /// Initializes the application. /// </summary> /// <param name="startupSettings">The settings used for startup of the application.</param> public static void InitializeApplication(StartupSettings startupSettings) { // Initialize the most important services: var container = new AltaxoServiceContainer(); container.AddFallbackProvider(Current.FallbackServiceProvider); container.AddService(typeof(IMessageService), new Altaxo.Main.Services.MessageServiceImpl()); // container.AddService(typeof(ILoggingService), new log4netLoggingService()); Current.Services = container; Current.Log.Info("Initialize application..."); var startup = new CoreStartup(startupSettings.ApplicationName); if (startupSettings.UseExceptionBoxForErrorHandler) { ExceptionBox.RegisterExceptionBoxForUnhandledExceptions(); } string configDirectory = startupSettings.ConfigDirectory; string dataDirectory = startupSettings.DataDirectory; string propertiesName; if (startupSettings.PropertiesName != null) { propertiesName = startupSettings.PropertiesName; } else { propertiesName = startupSettings.ApplicationName + "Properties"; } if (startupSettings.ApplicationRootPath != null) { FileUtility.ApplicationRootPath = startupSettings.ApplicationRootPath; } if (configDirectory == null) { configDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), startupSettings.ApplicationName); } var propertyService = new Altaxo.Main.Services.PropertyService( DirectoryName.Create(configDirectory), DirectoryName.Create(dataDirectory ?? Path.Combine(FileUtility.ApplicationRootPath, "data")), propertiesName); startup.StartCoreServices(propertyService, startupSettings); var exe = Assembly.Load(startupSettings.ResourceAssemblyName); Current.ResourceService.RegisterNeutralStrings(new ResourceManager("Altaxo.Resources.StringResources", exe)); Current.ResourceService.RegisterNeutralImages(new ResourceManager("Altaxo.Resources.BitmapResources", exe)); Current.ResourceService.RegisterNeutralStrings(new ResourceManager("Altaxo.Resources.AltaxoString", exe)); Current.ResourceService.RegisterNeutralImages(new ResourceManager("Altaxo.Resources.AltaxoBitmap", exe)); CommandWrapper.LinkCommandCreator = (link => new LinkCommand(link)); // creation of command for opening web sites CommandWrapper.WellKnownCommandCreator = MenuService.GetKnownCommand; // creation of all other commands CommandWrapper.RegisterConditionRequerySuggestedHandler = (eh => CommandManager.RequerySuggested += eh); // CommandWrapper has to know how to subscribe to the RequerySuggested event of the command manager CommandWrapper.UnregisterConditionRequerySuggestedHandler = (eh => CommandManager.RequerySuggested -= eh); // CommandWrapper must know how to unsubscribe to the RequerySuggested event of the command manager Current.Log.Info("Looking for AddIns..."); foreach (string file in startupSettings._addInFiles) { startup.AddAddInFile(file); } foreach (string dir in startupSettings._addInDirectories) { startup.AddAddInsFromDirectory(dir); } if (startupSettings.AllowAddInConfigurationAndExternalAddIns) { startup.ConfigureExternalAddIns(Path.Combine(configDirectory, "AddIns.xml")); } if (startupSettings.AllowUserAddIns) { startup.ConfigureUserAddIns(Path.Combine(configDirectory, "AddInInstallTemp"), Path.Combine(configDirectory, "AddIns")); } Current.Log.Info("Loading AddInTree..."); startup.RunInitialization(); Current.Log.Info("Init application finished"); }
public void InitMESCore(SolarViewerHost.CallbackHelper callback, StartupSettings properties) { //初始化ILoggingService接口 FanHai.Gui.Core.Services.ServiceManager.LoggingService = new log4netLoggingService(); //初始化IMessageService接口 FanHai.Gui.Core.Services.ServiceManager.MessageService = WinFormsMessageService.Instance; //记录字符串信息 LoggingService.Info("Init FanHai Framework Core..."); this.callback = callback; CoreStartup startup = new CoreStartup(properties.ApplicationName); if (properties.UseSolarViewerFrameworkErrorHandler) { this.useSolarViewerFrameworkErrorHandler = true; ExceptionBox.RegisterExceptionBoxForUnhandledExceptions(); } //设定启动路径 startup.ConfigDirectory = properties.ConfigDirectory; //设定数据路径 startup.DataDirectory = properties.DataDirectory; if (properties.PropertiesName != null) { //把StarupSettings类中PropertiesName属性传递给CoreStartup startup.PropertiesName = properties.PropertiesName; } //ParserService.DomPersistencePath = properties.DomPersistencePath; // disable RTL: translations for the RTL languages are inactive RightToLeftConverter.RightToLeftLanguages = new string[0]; //设定App启动路径 if (properties.ApplicationRootPath != null) { FileUtility.ApplicationRootPath = properties.ApplicationRootPath; } startup.StartCoreServices(); Assembly exe = Assembly.Load(properties.ResourceAssemblyName); ResourceService.RegisterNeutralStrings(new ResourceManager("FanHai.Gui.Framework.StartUp.Resources.StringResources", exe)); ResourceService.RegisterNeutralImages(new ResourceManager("FanHai.Gui.Framework.StartUp.Resources.BitmapResources", exe)); LoggingService.Info("Looking for AddIns..."); foreach (string file in properties.addInFiles) { startup.AddAddInFile(file); } foreach (string dir in properties.addInDirectories) { startup.AddAddInsFromDirectory(dir); } if (properties.AllowAddInConfigurationAndExternalAddIns) { startup.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml")); } if (properties.AllowUserAddIns) { startup.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"), Path.Combine(PropertyService.ConfigDirectory, "AddIns")); } LoggingService.Info("Loading AddInTree..."); startup.RunInitialization(); LoggingService.Info("Init FanHai Framework Core finished"); }
public void InitSharpDevelopCore(SharpDevelopHost.CallbackHelper callback, StartupSettings properties) { // Initialize the most important services: var container = new SharpDevelopServiceContainer(); container.AddFallbackProvider(ServiceSingleton.FallbackServiceProvider); container.AddService(typeof(IMessageService), new SDMessageService()); container.AddService(typeof(ILoggingService), new log4netLoggingService()); ServiceSingleton.ServiceProvider = container; LoggingService.Info("InitSharpDevelop..."); this.callback = callback; CoreStartup startup = new CoreStartup(properties.ApplicationName); if (properties.UseSharpDevelopErrorHandler) { this.useSharpDevelopErrorHandler = true; ExceptionBox.RegisterExceptionBoxForUnhandledExceptions(); } string configDirectory = properties.ConfigDirectory; string dataDirectory = properties.DataDirectory; string propertiesName; if (properties.PropertiesName != null) { propertiesName = properties.PropertiesName; } else { propertiesName = properties.ApplicationName + "Properties"; } if (properties.ApplicationRootPath != null) { FileUtility.ApplicationRootPath = properties.ApplicationRootPath; } if (configDirectory == null) { configDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), properties.ApplicationName); } var propertyService = new PropertyService( DirectoryName.Create(configDirectory), DirectoryName.Create(dataDirectory ?? Path.Combine(FileUtility.ApplicationRootPath, "data")), propertiesName); startup.StartCoreServices(propertyService); Assembly exe = Assembly.Load(properties.ResourceAssemblyName); SD.ResourceService.RegisterNeutralStrings(new ResourceManager("ICSharpCode.SharpDevelop.Resources.StringResources", exe)); SD.ResourceService.RegisterNeutralImages(new ResourceManager("ICSharpCode.SharpDevelop.Resources.BitmapResources", exe)); CommandWrapper.LinkCommandCreator = (link => new LinkCommand(link)); CommandWrapper.WellKnownCommandCreator = Core.Presentation.MenuService.GetKnownCommand; CommandWrapper.RegisterConditionRequerySuggestedHandler = (eh => CommandManager.RequerySuggested += eh); CommandWrapper.UnregisterConditionRequerySuggestedHandler = (eh => CommandManager.RequerySuggested -= eh); StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider()); LoggingService.Info("Looking for AddIns..."); foreach (string file in properties.addInFiles) { startup.AddAddInFile(file); } foreach (string dir in properties.addInDirectories) { startup.AddAddInsFromDirectory(dir); } if (properties.AllowAddInConfigurationAndExternalAddIns) { startup.ConfigureExternalAddIns(Path.Combine(configDirectory, "AddIns.xml")); } if (properties.AllowUserAddIns) { startup.ConfigureUserAddIns(Path.Combine(configDirectory, "AddInInstallTemp"), Path.Combine(configDirectory, "AddIns")); } LoggingService.Info("Loading AddInTree..."); startup.RunInitialization(); ((AssemblyParserService)SD.AssemblyParserService).DomPersistencePath = properties.DomPersistencePath; // Register events to marshal back Project.ProjectService.BuildStarted += delegate { this.callback.StartBuild(); }; Project.ProjectService.BuildFinished += delegate { this.callback.EndBuild(); }; Project.ProjectService.SolutionLoaded += delegate { this.callback.SolutionLoaded(); }; Project.ProjectService.SolutionClosed += delegate { this.callback.SolutionClosed(); }; FileUtility.FileLoaded += delegate(object sender, FileNameEventArgs e) { this.callback.FileLoaded(e.FileName); }; FileUtility.FileSaved += delegate(object sender, FileNameEventArgs e) { this.callback.FileSaved(e.FileName); }; LoggingService.Info("InitSharpDevelop finished"); }
public void InitSharpDevelopCore(StartUpHost.CallbackHelper callback, StartupSettings properties) { // creating the service manager initializes the logging service etc. ICSharpCode.Core.Services.ServiceManager.Instance = new FWServiceManager(); LoggingService.Info("InitFrameWork..."); this.callback = callback; CoreStartup startup = new CoreStartup(properties.ApplicationName); if (properties.UseSharpDevelopErrorHandler) { this.useSharpDevelopErrorHandler = true; ExceptionBox.RegisterExceptionBoxForUnhandledExceptions(); } startup.ConfigDirectory = properties.ConfigDirectory; startup.DataDirectory = properties.DataDirectory; if (properties.PropertiesName != null) { startup.PropertiesName = properties.PropertiesName; } //AssemblyParserService.DomPersistencePath = properties.DomPersistencePath;//by hanz if (properties.ApplicationRootPath != null) { FileUtility.ApplicationRootPath = properties.ApplicationRootPath; } startup.StartCoreServices(); Assembly exe = Assembly.Load(properties.ResourceAssemblyName); ResourceService.RegisterNeutralStrings(new ResourceManager("StartUp.Resources.StringResources", exe)); ResourceService.RegisterNeutralImages(new ResourceManager("StartUp.Resources.BitmapResources", exe)); MenuCommand.LinkCommandCreator = delegate(string link) { return(new LinkCommand(link)); }; MenuCommand.KnownCommandCreator = CreateICommandForWPFCommand; ICSharpCode.Core.Presentation.MenuService.LinkCommandCreator = MenuCommand.LinkCommandCreator; //StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider());//by hanz LoggingService.Info("Looking for AddIns..."); foreach (string file in properties.addInFiles) { startup.AddAddInFile(file); } foreach (string dir in properties.addInDirectories) { startup.AddAddInsFromDirectory(dir); } if (properties.AllowAddInConfigurationAndExternalAddIns) { startup.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml")); } if (properties.AllowUserAddIns) { startup.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"), Path.Combine(PropertyService.ConfigDirectory, "AddIns")); } LoggingService.Info("Loading AddInTree..."); startup.RunInitialization(); LoggingService.Info("InitFrameWork finished"); }