コード例 #1
0
        private void InitializeMefHostingService(ICommandLineService commandLineService)
        {
            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.MefInitialization);
            IExpressionMefHostingService service = this.Services.GetService <IExpressionMefHostingService>();

            string[] arguments = commandLineService.GetArguments("extension");
            if (arguments != null)
            {
                foreach (string assembly in arguments)
                {
                    service.AddAssembly(assembly);
                }
            }
            string folder = Path.Combine(Path.GetDirectoryName(this.GetType().Module.FullyQualifiedName), "extensions");

            service.AddFolder(folder);
            try
            {
                service.Compose();
            }
            catch (Exception ex)
            {
                this.mefExceptionToShow = ex;
            }
            PerformanceUtility.EndPerformanceSequence(PerformanceEvent.MefInitialization);
        }
コード例 #2
0
        private void ShowMefComposeError()
        {
            IConfigurationService        service1 = this.Services.GetService <IConfigurationService>();
            IMessageDisplayService       service2 = this.Services.GetService <IMessageDisplayService>();
            IMessageLoggingService       service3 = this.Services.GetService <IMessageLoggingService>();
            IExpressionMefHostingService service4 = this.Services.GetService <IExpressionMefHostingService>();

            if (this.mefExceptionToShow == null && Enumerable.Count <Exception>(service4.CompositionExceptions) <= 0)
            {
                return;
            }
            bool doNotAskAgain = service1 != null && (bool)service1["MEFHosting"].GetProperty("DoNotWarnAboutMefCompositionException", (object)false);

            if (!doNotAskAgain && service3 != null && (service4 != null && Enumerable.Count <Exception>(service4.CompositionExceptions) > 0))
            {
                foreach (Exception exception in service4.CompositionExceptions)
                {
                    service3.WriteLine(exception.Message);
                }
            }
            service4.ClearCompositionExceptions();
            if (!doNotAskAgain && service3 != null && (this.mefExceptionToShow != null && !string.IsNullOrEmpty(this.mefExceptionToShow.Message)))
            {
                service3.WriteLine(this.mefExceptionToShow.Message);
            }
            this.mefExceptionToShow = (Exception)null;
            if (doNotAskAgain || service2 == null)
            {
                return;
            }
            string         str  = Path.Combine(Path.GetDirectoryName(this.GetType().Module.FullyQualifiedName), "extensions");
            MessageBoxArgs args = new MessageBoxArgs()
            {
                Message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.MefCompositionException, new object[1]
                {
                    (object)str
                }),
                Button = MessageBoxButton.OK,
                Image  = MessageBoxImage.Exclamation
            };
            int num = (int)service2.ShowMessage(args, out doNotAskAgain);

            if (!doNotAskAgain || service1 == null)
            {
                return;
            }
            service1["MEFHosting"].SetProperty("DoNotWarnAboutMefCompositionException", (object)true);
        }
コード例 #3
0
 public void OnImportsSatisfied()
 {
     if (this.Capabilities == null)
     {
         return;
     }
     foreach (IPlatformCapabilitySettings capabilitySettings in this.Capabilities)
     {
         try
         {
             if (capabilitySettings.Version != 1)
             {
                 throw new ArgumentOutOfRangeException(typeof(IPlatformCapabilitySettings).ToString() + ".Version");
             }
             PlatformCapabilitySettings settings = new PlatformCapabilitySettings(capabilitySettings.RequiredTargetFramework, capabilitySettings.MaxFrameworkVersion);
             foreach (string index in (IEnumerable <string>)capabilitySettings.Capabilities.Keys)
             {
                 PlatformCapability result;
                 if (Enum.TryParse <PlatformCapability>(index, true, out result))
                 {
                     settings.AddCapability(result, capabilitySettings.Capabilities[index]);
                 }
             }
             PlatformTypes.AddCapabilitySettings(settings);
         }
         catch (Exception ex)
         {
             IExpressionMefHostingService service = this.services.GetService <IExpressionMefHostingService>();
             if (service != null)
             {
                 service.AddCompositionException(ex);
             }
             else
             {
                 throw;
             }
         }
     }
 }
コード例 #4
0
        public void Load(IServices services)
        {
            this.services = services;
            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.FrameworkPackageLoad);
            UIThreadDispatcher.InitializeInstance();
            IExpressionMefHostingService mefHostingService = (IExpressionMefHostingService) new ExpressionMefHostingService(services);

            this.services.AddService(typeof(IExpressionMefHostingService), (object)mefHostingService);
            mefHostingService.AddInternalPart((object)mefHostingService);
            IMessageDisplayService messageDisplayService = (IMessageDisplayService) new MessageDisplayService(services.GetService <IExpressionInformationService>());

            this.services.AddService(typeof(IMessageDisplayService), (object)messageDisplayService);
            mefHostingService.AddInternalPart((object)this.services.GetService <IMessageDisplayService>());
            PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create SchedulingService");
            this.services.AddService(typeof(ISchedulingService), (object)new SchedulingService());
            mefHostingService.AddInternalPart((object)this.services.GetService <ISchedulingService>());
            string str = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Microsoft\\Expression\\Blend 4");

            PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create ConfigurationService");
            IConfigurationService configurationService = (IConfigurationService) new ConfigurationService(str);

            this.services.AddService(typeof(IConfigurationService), (object)configurationService);
            PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create OptionsDialogService");
            IOptionsDialogService optionsDialogService = (IOptionsDialogService) new OptionsDialogService(configurationService);

            this.services.AddService(typeof(IOptionsDialogService), (object)optionsDialogService);
            PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create CommandService");
            ICommandService commandService = (ICommandService) new CommandService(services.GetService <IFeedbackService>());

            this.services.AddService(typeof(ICommandService), (object)commandService);
            PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Add Commands");
            this.AddCommand("Application_Exit", (ICommand) new FrameworkPackage.ExitCommand());
            this.AddCommand("Application_Options", (ICommand) new FrameworkPackage.OptionsCommand(optionsDialogService));
            PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create DocumentService");
            DocumentService documentService = (DocumentService) new BlendDocumentService(commandService, messageDisplayService);

            this.services.AddService(typeof(IDocumentService), (object)documentService);
            this.services.AddService(typeof(IViewService), (object)documentService);
            ICommandBarService commandBarService = (ICommandBarService) new CommandBarService(commandService);

            this.services.AddService(typeof(ICommandBarService), (object)commandBarService);
            PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create WorkspaceService");
            WorkspaceService workspaceService = new WorkspaceService(configurationService["WorkspaceService"], Path.Combine(str, "Workspaces"), (IEnumerable <string>) new string[2]
            {
                StringTable.DesignWorkspaceName,
                StringTable.AnimationWorkspaceName
            }, (IEnumerable <Uri>) new Uri[2]
            {
                new Uri("pack://application:,,,/Shopdrawing.Application;Component/Resources/Workspaces/Design.xaml", UriKind.Absolute),
                new Uri("pack://application:,,,/Shopdrawing.Application;Component/Resources/Workspaces/Animation.xaml", UriKind.Absolute)
            }, messageDisplayService);

            commandService.AddTarget((ICommandTarget)workspaceService);
            this.services.AddService(typeof(IWorkspaceService), (object)workspaceService);
            this.frameworkIcons        = new ResourceDictionary();
            this.frameworkIcons.Source = new Uri("pack://application:,,,/Microsoft.Expression.Framework;Component/Resources/Icons/FrameworkIcons.xaml", UriKind.Absolute);
            List <Theme> list = new List <Theme>(2);
            Uri          resourceDictionaryUriToMerge1 = new Uri("pack://application:,,,/Shopdrawing.Application;Component/Resources/BlendDarkTheme.xaml", UriKind.Absolute);

            list.Add(new Theme(StringTable.ThemeNameExpressionDark, "Resources\\UserInterface\\ExpressionDark.xaml", resourceDictionaryUriToMerge1));
            Uri resourceDictionaryUriToMerge2 = new Uri("pack://application:,,,/Shopdrawing.Application;Component/Resources/BlendLightTheme.xaml", UriKind.Absolute);

            list.Add(new Theme(StringTable.ThemeNameExpressionLight, "Resources\\UserInterface\\ExpressionLight.xaml", resourceDictionaryUriToMerge2));
            PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create WindowService");
            WindowService windowService = new WindowService(configurationService["WindowService"], commandBarService, commandService, (IViewService)documentService, (IWorkspaceService)workspaceService, messageDisplayService, services.GetService <IFeedbackService>(), services.GetService <IExpressionInformationService>().MainWindowRootElement, this.frameworkIcons, list.AsReadOnly(), this.suppressViewUI);

            this.services.AddService(typeof(Microsoft.Expression.Framework.UserInterface.IWindowService), (object)windowService);
            this.services.AddService(typeof(IOrderedViewProvider), (object)windowService);
            workspaceService.SetPaletteRegistry(windowService.PaletteRegistry);
            PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Register CommandTargets");
            commandService.AddTarget((ICommandTarget)this);
            commandService.AddTarget((ICommandTarget)documentService);
            this.services.AddService(typeof(IMessageLoggingService), (object)new FrameworkPackage.NullMessageLoggingService());
            this.services.AddService(typeof(IErrorService), (object)new FrameworkPackage.ErrorService());
            this.services.AddService(typeof(IImporterService), (object)new ImporterService(configurationService["ImporterService"], Path.Combine(str, "ImportersDataStore")));
            this.shellOptionsPage = new ShellOptionsPage((Microsoft.Expression.Framework.UserInterface.IWindowService)windowService);
            optionsDialogService.OptionsPages.Add((IOptionsPage)this.shellOptionsPage);
            Dialog.ServiceProvider = (IServiceProvider)services;
            PerformanceUtility.EndPerformanceSequence(PerformanceEvent.FrameworkPackageLoad);
        }
コード例 #5
0
ファイル: ProjectPackage.cs プロジェクト: radtek/Shopdrawing
        public void Load(IServices services)
        {
            this.services = services;
            ICommandService service = (ICommandService)this.services.GetService(typeof(ICommandService));
            IExpressionMefHostingService expressionMefHostingService = this.services.GetService <IExpressionMefHostingService>();
            IDocumentTypeManager         documentTypeManager         = new DocumentTypeManager(new UnknownDocumentType());

            this.services.AddService(typeof(IDocumentTypeManager), documentTypeManager);
            IProjectTypeManager projectTypeManager = new ProjectTypeManager();

            this.services.AddService(typeof(IProjectTypeManager), projectTypeManager);
            IConfigurationService configurationService = this.services.GetService <IConfigurationService>();
            ProjectManager        projectManager       = new ProjectManager(this.services, configurationService["ProjectManager"]);

            this.services.AddService(typeof(IProjectManager), projectManager);
            service.AddTarget(projectManager);
            this.services.AddService(typeof(IExternalChanges), projectManager);
            this.solutionService = new SolutionService(projectManager);
            this.services.AddService(typeof(ISolutionService), this.solutionService);
            this.assemblyLoggingService = new AssemblyLoggingService(configurationService.ConfigurationDirectoryPath);
            this.services.AddService(typeof(IAssemblyLoggingService), this.assemblyLoggingService);
            IProjectAdapterService projectAdapterService = new ProjectAdapterService(this.services);

            this.services.AddService(typeof(IProjectAdapterService), projectAdapterService);
            if (expressionMefHostingService != null)
            {
                expressionMefHostingService.AddInternalPart(projectAdapterService);
                expressionMefHostingService.AddInternalPart(this.solutionService);
            }
            IOptionsDialogService optionsDialogService = this.services.GetService <IOptionsDialogService>();

            this.projectSystemOptionsPage = new ProjectSystemOptionsPage(projectManager, this.assemblyLoggingService);
            optionsDialogService.OptionsPages.Add(this.projectSystemOptionsPage);
            this.assemblyDocumentType = new AssemblyDocumentType();
            documentTypeManager.Register(this.assemblyDocumentType);
            this.projectReferenceDocumentType = new ProjectReferenceDocumentType();
            documentTypeManager.Register(this.projectReferenceDocumentType);
            this.folderDocumentType = new FolderDocumentType();
            documentTypeManager.Register(this.folderDocumentType);
            this.comReferenceDocumentType = new ComReferenceDocumentType();
            documentTypeManager.Register(this.comReferenceDocumentType);
            this.cursorDocumentType = new CursorDocumentType();
            documentTypeManager.Register(this.cursorDocumentType);
            this.deepZoomDocumentType = new DeepZoomDocumentType();
            documentTypeManager.Register(this.deepZoomDocumentType);
            this.websiteProjectType = new WebsiteProjectType();
            projectTypeManager.Register(this.websiteProjectType);
            this.webApplicationProjectType = new WebApplicationProjectType();
            projectTypeManager.Register(this.webApplicationProjectType);
            this.assemblyService = new AssemblyService(this.services);
            this.services.AddService(typeof(IAssemblyService), this.assemblyService);
            this.services.AddService(typeof(ISatelliteAssemblyResolver), this.assemblyService);
            this.blendSdkAssemblyResolver = new BlendSdkAssemblyResolver();
            this.assemblyService.RegisterLibraryResolver(this.blendSdkAssemblyResolver);
            this.blendAssemblyResolver = new BlendAssemblyResolver();
            this.assemblyService.RegisterLibraryResolver(this.blendAssemblyResolver);
            Microsoft.Expression.Framework.UserInterface.IWindowService windowService = this.services.GetService <Microsoft.Expression.Framework.UserInterface.IWindowService>();
            windowService.Closing += new CancelEventHandler(this.WindowManager_Closing);
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new DispatcherOperationCallback((object o) => {
                Application.Current.SessionEnding += new SessionEndingCancelEventHandler(this.Current_SessionEnding);
                return(null);
            }), null);
            UIThreadDispatcher.Instance.BeginInvoke(DispatcherPriority.SystemIdle, new Action(this.assemblyService.AssemblyCache.Clean));
        }
コード例 #6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            this.InitializeUnhandledExceptionHandlers();
            CultureManager.ForceCulture(Path.GetDirectoryName(this.GetType().Module.FullyQualifiedName), "en");
            SplashService splashService = new SplashService("{5d76ab22-cd7a-42ea-9756-629f133abd8ex}", this.RegistryPath);

            this.ReplaceWithWelcomeSplashScreen(splashService.GetSplashVersion() == 1 ? "pack://application:,,,/Shopdrawing.Application;Component/licensing/SplashScreenSketchFlow.png" : "pack://application:,,,/Shopdrawing.Application;Component/licensing/SplashScreen.png");
            this.DoEvents();
            PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Creating Services and ExpressionInformationService");
            this.CreateInitialServices(ExpressionApplication.Version);
            this.ExpressionInformationService.MainWindowRootElement = FileTable.GetElement("MainWindow.xaml");
            //this.InitializeLicenseService(ExpressionFeatureMapper.Blend, (ApplicationLicenses) new BlendTrialRtmV4Licenses(), (ApplicationLicenses) new BlendMobileRtmV4Licenses());
            FrameworkPackage.RegisterCommandLineService(this.Services);
            ICommandLineService service1 = this.Services.GetService <ICommandLineService>();

            this.CreateFeedbackService("Shopdrawing", BlendFeedbackValues.CommandToFeedbackValues);
            this.Services.AddService(typeof(SplashService), (object)splashService);
            string name = service1.GetArgument("culture");

            if (!string.IsNullOrEmpty(name))
            {
                Thread.CurrentThread.CurrentCulture   = new CultureInfo(name);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(name);
            }
            PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Load resources");
            PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Register FrameworkPackage");
            this.Services.RegisterPackage((IPackage) new FrameworkPackage());
            IExpressionMefHostingService service2 = this.Services.GetService <IExpressionMefHostingService>();

            Microsoft.Expression.Framework.UserInterface.IWindowService service3 = this.Services.GetService <Microsoft.Expression.Framework.UserInterface.IWindowService>();
            service3.Title = StringTable.ApplicationTitle;
            FocusScopeManager.SetFocusScopePriority((DependencyObject)System.Windows.Application.Current.MainWindow, 0);
            //FocusScopeManager.Instance.ReturnFocusCallback = new ReturnFocusCallback(((ExpressionApplication)this).FocusScopeManagerReturnFocusCallback);
            this.Services.RegisterPackage((IPackage) new WebServerPackage());
            this.Services.RegisterPackage((IPackage) new SourceControlPackage());
            this.Services.RegisterPackage((IPackage) new ProjectPackage());
            this.Services.RegisterPackage((IPackage) new CodePackage());
            PlatformPackage platformPackage = new PlatformPackage();

            this.Services.RegisterPackage((IPackage)platformPackage);
            if (service2 != null)
            {
                service2.AddInternalPart((object)platformPackage);
            }
            this.Services.RegisterPackage((IPackage) new DesignerPackage());
            this.Services.GetService <IHelpService>().RegisterHelpProvider((IHelpProvider) new BlendSDKHelpProvider());
            PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Discovering external packages");
            BlendApplication.disableWhitecap = service1.GetArgument("DisableWhitecap") != null;
            if (BlendApplication.disableWhitecap)
            {
                this.Services.ExcludeAddIn("Microsoft.Expression.PrototypeHostEnvironment.dll");
            }
            this.Services.LoadAddIns("Microsoft.Expression.*.addin");
            this.Services.LoadAddIns("AddIns\\*.addin");
            this.InitializeMefHostingService(service1);
            ICommandService service4 = this.Services.GetService <ICommandService>();

            service4.AddTarget((ICommandTarget) new ApplicationCommandTarget(this.Services));
            PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Creating Menu");
            ICommandBar menuBar = this.Services.GetService <ICommandBarService>().CommandBars.AddMenuBar("MainMenu");

            MenuBar.Create(menuBar, this.Services);
            DebugCommands.CreateDebugMenu(menuBar, this.Services);
            this.DoEvents();
            PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Show ApplicationWindow");
            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.ShowMainWindow);
            service3.Initialized     += new EventHandler(this.MainWindow_SourceInitialized);
            service3.IsVisible        = true;
            this.MainWindow           = service3.MainWindow;
            this.MainWindow.IsEnabled = false;
            PerformanceUtility.EndPerformanceSequence(PerformanceEvent.ShowMainWindow);
            this.Services.GetService <IWorkspaceService>().LoadConfiguration(service1.GetArgument("DefaultWorkspace") != null);
            service4.AddTarget((ICommandTarget) new DebugCommands(this.Services));
            PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Initializing Project System");
            IProjectManager service5 = this.Services.GetService <IProjectManager>();

            service5.SolutionOpened   += new EventHandler <SolutionEventArgs>(this.ProjectManager_SolutionOpened);
            service5.SolutionClosed   += new EventHandler <SolutionEventArgs>(this.ProjectManager_SolutionClosed);
            service5.SolutionMigrated += new EventHandler <SolutionEventArgs>(this.ProjectManager_SolutionMigrated);
            this.DoEvents();
            BlendServer.StartRemoteService((IServiceProvider)this.Services);
            if (service1.GetArgument("ExceptionLog") != null)
            {
                ExceptionHandler.Attach(AppDomain.CurrentDomain);
                DebugVariables.Instance.ExceptionHandlerEnabled = true;
            }
            string[] arguments = service1.GetArguments("addin");
            if (arguments != null)
            {
                foreach (string fileName in arguments)
                {
                    try
                    {
                        this.Services.LoadAddIn(fileName);
                    }
                    catch (Exception ex)
                    {
                        IMessageDisplayService service6 = this.Services.GetService <IMessageDisplayService>();
                        if (service6 != null)
                        {
                            service6.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.ApplicationAssemblyLoadErrorDialogMessage, new object[2]
                            {
                                (object)fileName,
                                (object)ex.Message
                            }));
                        }
                    }
                }
            }
            this.OnStartupIdleProcessing();
            base.OnStartup(e);
        }