public bool AddMethod(Type returnType, string methodName, IEnumerable <IParameterDeclaration> parameters) { CodeModelService.VisualStudioCodeModelService.MessageFilterTypeDeclaration.AddHandlerImplementation handlerImplementation = new CodeModelService.VisualStudioCodeModelService.MessageFilterTypeDeclaration.AddHandlerImplementation(this.services.GetService <IExpressionInformationService>(), this.typeDeclaration, returnType, methodName, parameters); handlerImplementation.Execute(); Exception exception = handlerImplementation.Exception; if (exception == null) { return(true); } bool flag = false; COMException comException = exception as COMException; if (comException != null && comException.ErrorCode == -2147221492) { flag = true; } IMessageDisplayService service = this.services.GetService <IMessageDisplayService>(); if (service != null) { if (flag) { service.ShowError(StringTable.EventHandlerCommunicatingWithVSTerminatedDialogMessage); } else { service.ShowError(StringTable.EventHandlerChangeFailedDialogMessage, exception, (string)null); } } return(false); }
/// <summary> /// Function to unload the selected plug in assemblies. /// </summary> private void DoUnloadPlugInAssemblies() { try { IReadOnlyList <CodecSetting> selected = SelectedCodecs.ToArray(); IReadOnlyList <GorgonSpriteCodecPlugIn> plugIns = selected.Select(item => item.PlugIn).ToArray(); MessageResponse response = MessageResponse.None; if (plugIns.Count == 0) { return; } foreach (GorgonSpriteCodecPlugIn plugIn in plugIns) { if ((response != MessageResponse.YesToAll) && (response != MessageResponse.NoToAll)) { response = _messageDisplay.ShowConfirmation(string.Format(Resources.GORSPR_CONFIRM_REMOVE_CODECS, Path.GetFileName(plugIn.PlugInPath)), toAll: plugIns.Count > 1); } if (response == MessageResponse.NoToAll) { return; } _busyService.SetBusy(); if (response == MessageResponse.No) { continue; } _codecs.RemoveCodecPlugIn(plugIn); foreach (CodecSetting setting in selected) { SelectedCodecs.Remove(setting); CodecPlugInPaths.Remove(setting); } _busyService.SetIdle(); } // Store the settings now. DoWriteSettings(); } catch (Exception ex) { _messageDisplay.ShowError(ex, Resources.GORSPR_ERR_CANNOT_UNLOAD_CODECS); } finally { _busyService.SetIdle(); } }
public bool Execute() { this.SetRunning(true); Process process = null; System.Diagnostics.ProcessStartInfo processStartInfo = this.ProcessStartInfo; if (processStartInfo != null) { try { process = Process.Start(processStartInfo); } catch (Win32Exception win32Exception1) { Win32Exception win32Exception = win32Exception1; IMessageDisplayService messageDisplayService = base.Services.MessageDisplayService(); CultureInfo currentCulture = CultureInfo.CurrentCulture; string projectBuilderLaunchFailedDialogMessage = StringTable.ProjectBuilderLaunchFailedDialogMessage; object[] fileName = new object[] { processStartInfo.FileName, win32Exception.ToString() }; messageDisplayService.ShowError(string.Format(currentCulture, projectBuilderLaunchFailedDialogMessage, fileName)); } } if (process == null || process.HasExited) { this.SetRunning(false); } else { process.EnableRaisingEvents = true; process.Exited += new EventHandler(this.Process_Exited); } PerformanceUtility.EndPerformanceSequence(PerformanceEvent.ProjectRun); return(process != null); }
/// <summary> /// Function to delete a project item. /// </summary> /// <param name="args">The arguments for the command.</param> private async void DoDeleteItemAsync(RecentItemDeleteEventArgs args) { try { if (_messageDisplay.ShowConfirmation(string.Format(Resources.GOREDIT_CONFIRM_DELETE_PROJECT_ITEM, args.Item.FilePath)) == MessageResponse.No) { args.Cancel = true; return; } ShowWaitPanel(string.Format(Resources.GOREDIT_TEXT_DELETING_PROJECT, args.Item.FilePath.Ellipses(40, true))); // We will send the project to the recycle bin so it can be recovered if need be. await Task.Run(() => { if (Directory.Exists(args.Item.FilePath)) { Shell32.SendToRecycleBin(args.Item.FilePath, Shell32.FileOperationFlags.FOF_SILENT | Shell32.FileOperationFlags.FOF_NOCONFIRMATION | Shell32.FileOperationFlags.FOF_WANTNUKEWARNING); } }); Files.Remove(args.Item); } catch (Exception ex) { _messageDisplay.ShowError(ex, string.Format(Resources.GOREDIT_ERR_DELETING_PROJECT_ITEM, args.Item.FilePath)); } finally { HideWaitPanel(); } }
public static bool Navigate(Uri uri, IMessageDisplayService messageDisplayService) { bool flag; try { Process.Start(uri.OriginalString); return(true); } catch (Exception exception1) { Exception exception = exception1; if (!(exception is ObjectDisposedException) && !(exception is Win32Exception) && !(exception is ArgumentException) && !(exception is InvalidOperationException)) { throw; } if (messageDisplayService != null) { CultureInfo currentCulture = CultureInfo.CurrentCulture; string webNavigationFailedMessage = StringTable.WebNavigationFailedMessage; object[] originalString = new object[] { uri.OriginalString }; messageDisplayService.ShowError(string.Format(currentCulture, webNavigationFailedMessage, originalString)); } flag = false; } return(flag); }
public override void Execute() { IMessageDisplayService service = this.services.GetService <IMessageDisplayService>(); SceneView sceneView = (SceneView)this.services.GetService <IViewService>().ActiveView; if (sceneView != null) { ViewNodeManager viewNodeManager = sceneView.InstanceBuilderContext.ViewNodeManager; if (viewNodeManager == null || viewNodeManager.Root == null) { return; } StringBuilder sb = new StringBuilder(); XmlTextWriter xmlTextWriter = new XmlTextWriter((TextWriter) new StringWriter(sb)); xmlTextWriter.Indentation = 4; xmlTextWriter.Formatting = Formatting.Indented; this.DumpViewNodeTree(viewNodeManager.Root, (XmlWriter)xmlTextWriter); xmlTextWriter.Flush(); Dump.Write(sb.ToString()); } else { service.ShowError("No Active Scene"); } }
public static void DisplayCommandFailedMessage(this IProjectCommand source, string failureMessage) { IMessageDisplayService messageDisplayService = source.Services.MessageDisplayService(); if (messageDisplayService != null) { messageDisplayService.ShowError(failureMessage); } }
public static void DisplayFailureMessage(this IServiceProvider source, string failure, string description) { IMessageDisplayService messageDisplayService = source.MessageDisplayService(); CultureInfo currentCulture = CultureInfo.CurrentCulture; string dialogFailedMessage = StringTable.DialogFailedMessage; object[] objArray = new object[] { failure, description }; messageDisplayService.ShowError(string.Format(currentCulture, dialogFailedMessage, objArray)); }
public int StartServer(IWebServerSettings settings) { foreach (WebServerService.BrowsingSession browsingSession in this._listSessions) { if (string.CompareOrdinal(browsingSession.localPath, settings.LocalPath) == 0 && !browsingSession.process.HasExited) { return(browsingSession.Handle); } } WebServerService.BrowsingSession browsingSession1 = new WebServerService.BrowsingSession(); if (Microsoft.Expression.Framework.Documents.PathHelper.PathEndsInDirectorySeparator(settings.LocalPath)) { settings.LocalPath = Microsoft.Expression.Framework.Documents.PathHelper.TrimTrailingDirectorySeparators(settings.LocalPath); } browsingSession1.localPath = settings.LocalPath; int num = settings.Port; if (num == 0) { num = this.GetNextAvailPort(); } ProcessStartInfo startInfo = new ProcessStartInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Microsoft.Expression.WebServer.exe", " /port:" + (object)num + (" /path:\"" + settings.LocalPath + "\"") + (" /vpath:\"" + settings.VirtualPath + "\"") + (settings.ShowTrayIcon ? (string)null : " /nosystray") + (!string.IsNullOrEmpty(settings.PhpServerExe) ? " /php:\"" + settings.PhpServerExe + "\"" : (string)null) + (settings.Silent ? " /silent" : (string)null) + (settings.UseNtlmAuthentication ? " /ntlm" : (string)null) + (settings.ShowDirectoryListing ? (string)null : " /nodirlist")); try { browsingSession1.process = Process.Start(startInfo); browsingSession1.Uri = "http://localhost:" + (object)num + "/"; browsingSession1.Handle = ++WebServerService.g_Handle; this._listSessions.Add(browsingSession1); } catch (Win32Exception ex) { IMessageDisplayService service = this.services.GetService <IMessageDisplayService>(); if (service != null) { service.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.WebServerCannotLaunch, new object[1] { (object)settings.LocalPath })); } return(0); } return(browsingSession1.Handle); }
public override void Execute() { IMessageDisplayService service = this.services.GetService <IMessageDisplayService>(); SceneView sceneView = (SceneView)this.services.GetService <IViewService>().ActiveView; if (sceneView != null) { IInstanceDictionary instanceDictionary = sceneView.InstanceDictionary; if (instanceDictionary == null) { return; } StringBuilder stringBuilder1 = new StringBuilder(); foreach (KeyValuePair <object, ViewNode> keyValuePair in (IEnumerable <KeyValuePair <object, ViewNode> >)instanceDictionary) { try { StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.Append(keyValuePair.Key.ToString()); stringBuilder2.Append(": "); stringBuilder2.Append(keyValuePair.Value.ToString()); stringBuilder1.AppendLine(stringBuilder2.ToString()); } catch (Exception ex) { StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.Append(keyValuePair.Key.GetType().ToString()); stringBuilder2.Append(": "); stringBuilder2.Append(keyValuePair.Value.ToString()); stringBuilder1.AppendLine(stringBuilder2.ToString()); } } Dump.Write(stringBuilder1.ToString()); } else { service.ShowError("No Active Scene"); } }
public static bool Navigate(Uri uri, IMessageDisplayService messageDisplayService) { try { Process.Start(uri.OriginalString); } catch (Exception ex) { if (ex is ObjectDisposedException || ex is Win32Exception || (ex is ArgumentException || ex is InvalidOperationException)) { if (messageDisplayService != null) { messageDisplayService.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.WebNavigationFailedMessage, new object[1] { (object)uri.OriginalString })); } return(false); } throw; } return(true); }
public IEnumerable <INamedProject> CreateProjects(string name, string path, IEnumerable <TemplateArgument> templateArguments, IServiceProvider serviceProvider) { Uri uri; IEnumerable <INamedProject> namedProjects; ICodeDocumentType codeDocumentType = base.GetCodeDocumentType(serviceProvider); if (templateArguments != null) { templateArguments = templateArguments.Concat <TemplateArgument>(TemplateManager.GetDefaultArguments(serviceProvider.ExpressionInformationService())); } else { templateArguments = TemplateManager.GetDefaultArguments(serviceProvider.ExpressionInformationService()); } TemplateArgument templateArgument = new TemplateArgument("projectname", name); if (!base.Template.TemplateData.CreateNewFolderSpecified || base.Template.TemplateData.CreateNewFolder) { path = Microsoft.Expression.Framework.Documents.PathHelper.ResolveCombinedPath(path, name); Directory.CreateDirectory(path); } List <INamedProject> namedProjects1 = new List <INamedProject>(); Uri uri1 = null; try { uri1 = new Uri(Microsoft.Expression.Framework.Documents.PathHelper.EnsurePathEndsInDirectorySeparator(path)); } catch (UriFormatException uriFormatException) { namedProjects = namedProjects1; return(namedProjects); } List <Uri> uris = new List <Uri>(); List <ProjectTemplate.FileToOpen> fileToOpens = new List <ProjectTemplate.FileToOpen>(); List <ProjectTemplate.SourceDestination> sourceDestinations = new List <ProjectTemplate.SourceDestination>(); string str = CodeGenerator.MakeSafeIdentifier(codeDocumentType, name, false); string str1 = CodeGenerator.MakeSafeIdentifier(codeDocumentType, name, true); TemplateArgument templateArgument1 = new TemplateArgument("safeprojectname", str); TemplateArgument templateArgument2 = new TemplateArgument("safeprojectname", str1); TemplateArgument templateArgument3 = new TemplateArgument("assemblyname", name); TemplateArgument templateArgument4 = new TemplateArgument("safeassemblyname", name.Replace(' ', '\u005F')); using (ProjectPathHelper.TemporaryDirectory temporaryDirectory = new ProjectPathHelper.TemporaryDirectory(true)) { foreach (VSTemplateTemplateContentProject templateProject in this.TemplateProjects) { if (!string.IsNullOrEmpty(templateProject.File)) { string targetFileName = templateProject.TargetFileName; if (string.IsNullOrEmpty(targetFileName)) { targetFileName = string.Concat(name, Path.GetExtension(templateProject.File)); } TemplateArgument[] templateArgumentArray = new TemplateArgument[] { templateArgument, templateArgument1, templateArgument3, templateArgument4 }; IEnumerable <TemplateArgument> templateArguments1 = templateArguments.Concat <TemplateArgument>(templateArgumentArray); uri = base.ResolveFileUri(targetFileName, uri1); string str2 = TemplateParser.ReplaceTemplateArguments(uri.LocalPath, templateArguments1); uri = new Uri(str2); if (!string.IsNullOrEmpty(templateProject.File) && !base.IsDirectory(templateProject.File)) { Uri uri2 = new Uri(temporaryDirectory.GenerateTemporaryFileName()); base.CreateFile(templateProject.File, base.TemplateLocation, uri2, templateProject.ReplaceParameters, templateArguments1); ProjectTemplate.SourceDestination sourceDestination = new ProjectTemplate.SourceDestination() { Source = uri2, Destination = uri }; sourceDestinations.Add(sourceDestination); } } else { uri = uri1; } foreach (Microsoft.Expression.Project.Templates.ProjectItem projectItem in templateProject.Items.OfType <Microsoft.Expression.Project.Templates.ProjectItem>()) { string value = projectItem.TargetFileName; if (string.IsNullOrEmpty(value)) { value = projectItem.Value; } int num = projectItem.Value.IndexOf('.'); string str3 = (num != -1 ? projectItem.Value.Remove(num) : projectItem.Value); bool flag = Path.GetExtension(projectItem.Value).Equals(codeDocumentType.DefaultFileExtension, StringComparison.OrdinalIgnoreCase); string str4 = CodeGenerator.MakeSafeIdentifier(codeDocumentType, str3, flag); TemplateArgument[] templateArgumentArray1 = new TemplateArgument[] { templateArgument, templateArgument3, templateArgument4, null, null, null }; templateArgumentArray1[3] = (flag ? templateArgument2 : templateArgument1); templateArgumentArray1[4] = new TemplateArgument("safeitemname", str4); templateArgumentArray1[5] = new TemplateArgument("safeitemrootname", str4); TemplateArgument[] templateArgumentArray2 = templateArgumentArray1; string str5 = TemplateParser.ReplaceTemplateArguments(value, templateArguments.Concat <TemplateArgument>(templateArgumentArray2)); Uri uri3 = base.ResolveFileUri(str5, uri1); Uri uri4 = new Uri(temporaryDirectory.GenerateTemporaryFileName()); if (!base.CreateFile(projectItem.Value, base.TemplateLocation, uri4, projectItem.ReplaceParameters, templateArguments.Concat <TemplateArgument>(templateArgumentArray2))) { continue; } if (projectItem.OpenInEditorSpecified && projectItem.OpenInEditor) { ProjectTemplate.FileToOpen fileToOpen = new ProjectTemplate.FileToOpen() { ProjectFile = uri, ProjectItem = uri3 }; fileToOpens.Add(fileToOpen); } ProjectTemplate.SourceDestination sourceDestination1 = new ProjectTemplate.SourceDestination() { Source = uri4, Destination = uri3 }; sourceDestinations.Add(sourceDestination1); } uris.Add(uri); } foreach (ProjectTemplate.SourceDestination sourceDestination2 in sourceDestinations) { string localPath = sourceDestination2.Destination.LocalPath; if (!Microsoft.Expression.Framework.Documents.PathHelper.FileOrDirectoryExists(localPath)) { continue; } IMessageDisplayService messageDisplayService = serviceProvider.MessageDisplayService(); CultureInfo currentUICulture = CultureInfo.CurrentUICulture; string cannotCreateTemplateDirectoryOrFileExistsMessage = StringTable.CannotCreateTemplateDirectoryOrFileExistsMessage; object[] objArray = new object[] { localPath }; messageDisplayService.ShowError(string.Format(currentUICulture, cannotCreateTemplateDirectoryOrFileExistsMessage, objArray)); namedProjects = namedProjects1; return(namedProjects); } foreach (ProjectTemplate.SourceDestination sourceDestination3 in sourceDestinations) { base.CreateFile(sourceDestination3.Source.LocalPath, new Uri(Path.GetDirectoryName(sourceDestination3.Source.LocalPath)), sourceDestination3.Destination, false, Enumerable.Empty <TemplateArgument>()); } foreach (Uri uri5 in uris) { DocumentReference documentReference = DocumentReference.Create(uri5.LocalPath); IProjectStore projectStore = null; INamedProject namedProject = null; try { projectStore = ProjectStoreHelper.CreateProjectStore(documentReference, serviceProvider, ProjectStoreHelper.DefaultProjectCreationChain); namedProject = serviceProvider.ProjectManager().AddProject(projectStore); } finally { if (namedProject == null && projectStore != null) { projectStore.Dispose(); } } if (namedProject == null) { continue; } namedProjects1.Add(namedProject); } foreach (ProjectTemplate.FileToOpen fileToOpen1 in fileToOpens) { ISolution currentSolution = serviceProvider.ProjectManager().CurrentSolution; if (currentSolution == null) { continue; } IProject project = currentSolution.Projects.FindMatchByUrl <IProject>(fileToOpen1.ProjectFile.LocalPath); if (project == null) { continue; } IProjectItem projectItem1 = project.Items.FindMatchByUrl <IProjectItem>(fileToOpen1.ProjectItem.LocalPath); if (projectItem1 == null) { continue; } projectItem1.OpenView(true); } return(namedProjects1); } return(namedProjects); }
public bool Execute() { bool flag; this.SetRunning(true); if (base.Services.ProjectAdapterService() != null) { IProjectExecutionAdapter projectExecutionAdapter = base.Services.ProjectAdapterService().FindAdapter <IProjectExecutionAdapter>(this); if (projectExecutionAdapter != null) { try { if (projectExecutionAdapter.Execute(new Microsoft.Expression.Extensibility.Project.Project(this), new ExecuteCompleteCallback(this.executeCompleteCallback))) { flag = true; } else { this.SetRunning(false); flag = false; } } catch (Exception exception) { this.SetRunning(false); flag = false; } return(flag); } } Process process = null; string startProgram = this.StartProgram; System.Diagnostics.ProcessStartInfo processStartInfo = this.ProcessStartInfo; if (processStartInfo == null && !string.IsNullOrEmpty(startProgram)) { processStartInfo = new System.Diagnostics.ProcessStartInfo(startProgram) { WorkingDirectory = this.WorkingDirectory }; string startArguments = this.StartArguments; if (startArguments != null) { processStartInfo.Arguments = startArguments; } processStartInfo.UseShellExecute = false; processStartInfo.RedirectStandardError = true; } if (processStartInfo != null) { try { process = Process.Start(processStartInfo); } catch (Win32Exception win32Exception1) { Win32Exception win32Exception = win32Exception1; IMessageDisplayService messageDisplayService = base.Services.MessageDisplayService(); CultureInfo currentCulture = CultureInfo.CurrentCulture; string projectBuilderLaunchFailedDialogMessage = StringTable.ProjectBuilderLaunchFailedDialogMessage; object[] str = new object[] { startProgram, win32Exception.ToString() }; messageDisplayService.ShowError(string.Format(currentCulture, projectBuilderLaunchFailedDialogMessage, str)); } } if (process == null || process.HasExited) { this.SetRunning(false); } else { process.EnableRaisingEvents = true; process.Exited += new EventHandler(this.Process_Exited); process.ErrorDataReceived += new DataReceivedEventHandler(this.OnErrorDataReceivedFromProcess); process.BeginErrorReadLine(); } PerformanceUtility.EndPerformanceSequence(PerformanceEvent.ProjectRun); return(process != null); }
protected INamedProject InitializeProject(IProjectStore projectStore) { INamedProject namedProject; INamedProject unlicensedProject = null; try { IProjectType projectTypeForProject = this.Services.ProjectTypeManager().GetProjectTypeForProject(projectStore); if (projectTypeForProject != null) { IProjectCreateError projectCreateError = projectTypeForProject.CanCreateProject(projectStore); if (projectCreateError != null) { projectTypeForProject = this.Services.ProjectTypeManager().UnknownProjectType; } if (projectTypeForProject is UnknownProjectType && SolutionBase.IsReloadPromptEnabled()) { InvalidProjectStore invalidProjectStore = projectStore as InvalidProjectStore; if (invalidProjectStore == null || string.IsNullOrEmpty(invalidProjectStore.InvalidStateDescription)) { this.PromptWithUnsupportedProjectDetails(projectStore, projectCreateError); } else { IMessageDisplayService messageDisplayService = this.Services.MessageDisplayService(); ErrorArgs errorArg = new ErrorArgs(); CultureInfo currentUICulture = CultureInfo.CurrentUICulture; string unsupportedProjectWithDescription = StringTable.UnsupportedProjectWithDescription; object[] displayName = new object[] { projectStore.DocumentReference.DisplayName, invalidProjectStore.InvalidStateDescription }; errorArg.Message = string.Format(currentUICulture, unsupportedProjectWithDescription, displayName); errorArg.AutomationId = "OpenProjectErrorDialog"; messageDisplayService.ShowError(errorArg); } } LicenseState licenseState = LicensingHelper.IsProjectLicensed(projectStore, this.serviceProvider); if (!licenseState.IsExpired) { if (!licenseState.FullyLicensed) { LicensingHelper.UnlicensedProjectLoadAttempted(); } unlicensedProject = projectTypeForProject.CreateProject(projectStore, this.GetCodeDocumentTypeFromProject(projectStore), this.serviceProvider); } else { LicensingHelper.UnlicensedProjectLoadAttempted(); unlicensedProject = new UnlicensedProject(projectStore, this.serviceProvider); } return(unlicensedProject); } else { namedProject = null; } } catch (Exception exception) { if (unlicensedProject != null) { projectStore.Dispose(); unlicensedProject.Dispose(); unlicensedProject = null; } throw; } return(namedProject); }
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); }
public static bool SaveDocument(IDocument document, bool saveAsOnFailure, bool forceSave, IMessageDisplayService messageManager) { bool flag = false; if (!forceSave) { if (!document.IsDirty) { flag = true; goto label_12; } } try { if (document.Container != null) { document.Container.BeginCheckDocumentStatus(document); } FileAttributes fileAttributes = !PathHelper.FileExists(document.DocumentReference.Path) ? FileAttributes.Normal : File.GetAttributes(document.DocumentReference.Path); if ((fileAttributes & FileAttributes.ReadOnly) != (FileAttributes)0) { MessageBoxArgs args = new MessageBoxArgs() { Message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.OverwriteConfirmationMessage, new object[1] { (object)document.DocumentReference.DisplayName }), Button = MessageBoxButton.YesNoCancel, Image = MessageBoxImage.Exclamation }; switch (messageManager.ShowMessage(args)) { case MessageBoxResult.Yes: File.SetAttributes(document.DocumentReference.Path, fileAttributes & ~FileAttributes.ReadOnly); flag = document.Save(); break; case MessageBoxResult.No: flag = true; break; } } else { flag = document.Save(); } } catch (UnauthorizedAccessException ex) { flag = false; messageManager.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.SaveAccessError, new object[2] { (object)document.DocumentReference.DisplayName, (object)ex.Message })); int num = saveAsOnFailure ? 1 : 0; } catch (IOException ex) { flag = false; messageManager.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.SaveAccessError, new object[2] { (object)document.DocumentReference.DisplayName, (object)ex.Message })); int num = saveAsOnFailure ? 1 : 0; } label_12: return(flag); }
public IAddIn LoadAddIn(string fileName) { if (this.excludedAddIns.Contains(Path.GetFileName(fileName).ToUpperInvariant())) { return((IAddIn)null); } try { switch (Path.GetExtension(fileName).ToUpperInvariant()) { case ".ADDIN": using (XmlReader xmlReader = XmlReader.Create(fileName)) { if (xmlReader.IsStartElement("AddIn")) { if (xmlReader.MoveToAttribute("AssemblyFile")) { return(this.LoadAddIn(Path.Combine(Path.GetDirectoryName(fileName), xmlReader.Value))); } break; } break; } case ".DLL": string str = Path.Combine(Path.GetDirectoryName(this.GetType().Module.FullyQualifiedName), Environment.ExpandEnvironmentVariables(fileName)); if (Microsoft.Expression.Framework.Documents.PathHelper.FileExists(str)) { foreach (IAddIn addIn in this.AddIns) { if (new Uri(str).Equals((object)new Uri(addIn.Location))) { return(addIn); } } Assembly assembly = Assembly.LoadFrom(str); if (assembly != (Assembly)null) { List <Type> list = new List <Type>(); object[] customAttributes = assembly.GetCustomAttributes(typeof(PackageAttribute), false); if (customAttributes != null && customAttributes.Length != 0) { foreach (PackageAttribute packageAttribute in customAttributes) { list.Add(packageAttribute.PackageType); } } else { list.AddRange((IEnumerable <Type>)assembly.GetExportedTypes()); } Services.AddIn addIn = new Services.AddIn(this, str); foreach (Type type in list) { if (typeof(IPackage).IsAssignableFrom(type) && !type.IsAbstract && !type.IsInterface) { IPackage package = Activator.CreateInstance(type) as IPackage; if (package != null) { addIn.RegisterPackage(package); } } } if (!EnumerableExtensions.CountIsMoreThan <IPackage>(addIn.Packages, 0)) { return((IAddIn)null); } this.addIns.Add((IAddIn)addIn); return((IAddIn)addIn); } break; } break; } return((IAddIn)null); } catch (TypeLoadException ex1) { IMessageDisplayService service = this.GetService <IMessageDisplayService>(); if (service != null) { try { service.ShowError(string.Concat(new object[4] { (object)"Addin '", (object)fileName, (object)"' has an issue with a type mismatch\r", (object)ex1 })); } catch (Exception ex2) { } } return((IAddIn)null); } }