Example #1
0
 /// <summary>
 /// Create a new AppDomain to host FanHai GUI Framework.
 /// </summary>
 public SolarViewerHost(StartupSettings startup)
 {
     if (startup == null)
     {
         throw new ArgumentNullException("startup");
     }
     this.appDomain = CreateDomain();
     helper         = (CallHelper)appDomain.CreateInstanceAndUnwrap(SmfaAssembly.FullName, typeof(CallHelper).FullName);
     helper.InitMESCore(new CallbackHelper(this), startup);
     initStatus = SMFInitStatus.CoreInitialized;
 }
Example #2
0
        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");
        }