private static string GetSilverlightVersionFromProjectStore(IProjectStore projectStore) { string empty = string.Empty; empty = (projectStore.StoreVersion != CommonVersions.Version4_0 ? ProjectStoreHelper.GetSilverlightVersionFromImports(projectStore) : ProjectStoreHelper.GetSilverlightVersionUsingProperties(projectStore)); return(empty); }
public static Version GetSilverlightVersion(IProjectStore projectStore) { if (!ProjectStoreHelper.HasSilverlightGuids(projectStore)) { return(null); } return(ProjectStoreHelper.ConvertStringToVersion(ProjectStoreHelper.GetSilverlightVersionFromProjectStore(projectStore))); }
private static string GetSilverlightVersionUsingProperties(IProjectStore projectStore) { string property = projectStore.GetProperty("SilverlightVersion"); if (ProjectStoreHelper.PropertyMatchesMSBuildVariable(property, "TargetFrameworkVersion")) { property = projectStore.GetProperty("TargetFrameworkVersion"); } return(property ?? string.Empty); }
private bool IsValidIfSketchFlow(IProjectStore projectStore) { if (!ProjectStoreHelper.IsSketchFlowProject(projectStore)) { return(true); } FrameworkName targetFrameworkName = ProjectStoreHelper.GetTargetFrameworkName(projectStore); if (targetFrameworkName == null) { return(false); } return(targetFrameworkName.Version == CommonVersions.Version4_0); }
internal static IProjectStore CreateProjectStore(DocumentReference documentReference, IServiceProvider serviceProvider, IEnumerable <ProjectCreator> creatorChainOfResponsibility) { string message; string invalidStoreBadPath = null; if (!documentReference.IsValidPathFormat) { invalidStoreBadPath = StringTable.InvalidStoreBadPath; } else if (!PathHelper.FileOrDirectoryExists(documentReference.Path)) { invalidStoreBadPath = StringTable.InvalidStoreMissingPath; } if (!string.IsNullOrEmpty(invalidStoreBadPath)) { return(InvalidProjectStore.CreateInstance(documentReference, invalidStoreBadPath, serviceProvider)); } Exception exception1 = null; IProjectStore projectStore = ProjectStoreHelper.CreateProjectStore(documentReference, serviceProvider, creatorChainOfResponsibility, (Action action, Action <Exception> exceptionAction) => { bool flag; try { action(); flag = true; } catch (Exception exception) { exceptionAction(exception); flag = false; } return(flag); }, (Exception e) => exception1 = e); if (projectStore != null) { return(projectStore); } DocumentReference documentReference1 = documentReference; if (exception1 == null) { message = null; } else { message = exception1.Message; } return(InvalidProjectStore.CreateInstance(documentReference1, message, serviceProvider)); }
public static FrameworkName GetTargetFrameworkName(IProjectStore projectStore) { if (projectStore == null) { return(null); } if (!ProjectStoreHelper.IsKnownLanguage(ProjectStoreHelper.GetProjectLanguage(projectStore))) { return(null); } string property = projectStore.GetProperty("TargetFrameworkIdentifier"); string str = projectStore.GetProperty("TargetFrameworkVersion"); string property1 = projectStore.GetProperty("TargetFrameworkProfile"); Version version30 = null; if (!string.IsNullOrEmpty(str)) { char[] chrArray = new char[] { 'v' }; if (!Version.TryParse(str.TrimStart(chrArray), out version30)) { version30 = null; } } if (projectStore.StoreVersion == CommonVersions.Version2_0 && version30 == CommonVersions.Version2_0 && ProjectStoreHelper.UsesWpf(projectStore)) { version30 = CommonVersions.Version3_0; } if (string.IsNullOrEmpty(property) || property.Equals("Silverlight", StringComparison.OrdinalIgnoreCase)) { Version silverlightVersion = ProjectStoreHelper.GetSilverlightVersion(projectStore); if (silverlightVersion != null) { property = "Silverlight"; version30 = silverlightVersion; } else { property = ".NETFramework"; } } if (version30 == null) { return(null); } return(ProjectStoreHelper.GenerateFrameworkName(property, version30, property1)); }
protected internal void ReloadProjectStore() { Type type = this.ProjectStore.GetType(); FrameworkName targetFrameworkName = ProjectStoreHelper.GetTargetFrameworkName(this.ProjectStore); this.ProjectStore.Dispose(); this.ProjectStore = ProjectStoreHelper.CreateProjectStore(base.DocumentReference, this.Services, ProjectStoreHelper.DefaultProjectCreationChain); if (this.ProjectStore.GetType() != type || this.ProjectStore.StoreVersion != CommonVersions.Version4_0) { throw new ProjectStoreUnsupportedException(); } FrameworkName frameworkName = ProjectStoreHelper.GetTargetFrameworkName(this.ProjectStore); if (frameworkName != targetFrameworkName || frameworkName == null || targetFrameworkName == null || !string.Equals(targetFrameworkName.FullName, frameworkName.FullName, StringComparison.OrdinalIgnoreCase)) { throw new TargetFrameworkChangedException(); } }
internal static bool IsSupportedOutputType(IProjectStore projectStore) { string property = projectStore.GetProperty("OutputType"); if (string.IsNullOrEmpty(property)) { return(false); } if (property.Equals("WinExe", StringComparison.OrdinalIgnoreCase) || property.Equals("Library", StringComparison.OrdinalIgnoreCase)) { return(true); } if (!property.Equals("StaticLibrary", StringComparison.OrdinalIgnoreCase)) { return(false); } return(ProjectStoreHelper.GetProjectLanguage(projectStore) == ProjectLanguage.CPlusPlus); }
private void ReloadProject(INamedProject project) { IProjectStore projectStore = null; try { this.CloseProject(project); ((ProjectManager)this.Services.ProjectManager()).OnSolutionClosed(new SolutionEventArgs(this)); projectStore = ProjectStoreHelper.CreateProjectStore(project.DocumentReference, this.serviceProvider, ProjectStoreHelper.DefaultProjectCreationChain); this.OpenProject(projectStore); ((ProjectManager)this.Services.ProjectManager()).OnSolutionOpened(new SolutionEventArgs(this)); } catch { if (projectStore != null) { projectStore.Dispose(); } throw; } }
protected override bool LoadInternal() { IProjectStore projectStore = ProjectStoreHelper.CreateProjectStore(base.DocumentReference, base.Services, ProjectStoreHelper.ResilientProjectCreationChain); if (projectStore == null) { return(false); } if (!(new UpgradeWizard(this, EnumerableExtensions.AsEnumerable <IProjectStore>(projectStore), null, () => { projectStore.Dispose(); projectStore = ProjectStoreHelper.CreateProjectStore(this.DocumentReference, this.Services, ProjectStoreHelper.DefaultProjectCreationChain); }, base.Services)).Upgrade()) { return(false); } if (projectStore is MigratingMSBuildStore) { projectStore.Dispose(); projectStore = ProjectStoreHelper.CreateProjectStore(base.DocumentReference, base.Services, ProjectStoreHelper.DefaultProjectCreationChain); } INamedProject namedProject = null; try { namedProject = base.OpenProject(projectStore); if (namedProject != null) { base.OpenInitialScene(); } } finally { if (namedProject == null && projectStore != null) { projectStore.Dispose(); } } return(namedProject != null); }
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 override bool IsValidTypeForProject(IProjectStore projectStore) { Version storeVersion = projectStore.StoreVersion; if (!(projectStore is MSBuildBasedProjectStore) || !(storeVersion != null) || !(storeVersion == CommonVersions.Version4_0) || !ProjectStoreHelper.IsKnownLanguage(projectStore)) { return(false); } return(this.IsValidIfSketchFlow(projectStore)); }
private void PromptWithUnsupportedProjectDetails(IProjectStore projectStore, IProjectCreateError projectCreateError) { string invalidStoreUnsupportedError = StringTable.InvalidStoreUnsupportedError; string identifier = null; if (projectStore is InvalidProjectStore) { string safeExtension = Microsoft.Expression.Framework.Documents.PathHelper.GetSafeExtension(projectStore.DocumentReference.Path); if (!string.IsNullOrEmpty(safeExtension)) { identifier = string.Concat("DoNotWarnAboutExtension", safeExtension.ToUpperInvariant()); } } else if (projectCreateError != null) { invalidStoreUnsupportedError = projectCreateError.Message; identifier = projectCreateError.Identifier; } else if (projectStore.StoreVersion != CommonVersions.Version4_0) { CultureInfo currentUICulture = CultureInfo.CurrentUICulture; string invalidStoreBadToolsVersion = StringTable.InvalidStoreBadToolsVersion; object[] objArray = new object[] { "4.0" }; invalidStoreUnsupportedError = string.Format(currentUICulture, invalidStoreBadToolsVersion, objArray); identifier = "DoNotWarnAboutBadToolsVersion"; } else if (!ProjectStoreHelper.IsKnownLanguage(projectStore)) { invalidStoreUnsupportedError = StringTable.InvalidStoreUnknownLanguage; identifier = "DoNotWarnAboutUnknownLanguage"; } else if (!WindowsExecutableProjectType.IsSupportedOutputType(projectStore)) { invalidStoreUnsupportedError = StringTable.InvalidStoreUnsupportedOutputType; identifier = "DoNotWarnAboutUnsupportedOutputType"; } else if (ProjectStoreHelper.IsSketchFlowProject(projectStore)) { FrameworkName targetFrameworkName = ProjectStoreHelper.GetTargetFrameworkName(projectStore); if (targetFrameworkName == null || targetFrameworkName.Version != CommonVersions.Version4_0) { CultureInfo cultureInfo = CultureInfo.CurrentUICulture; string invalidStoreUnsupportedSketchflow = StringTable.InvalidStoreUnsupportedSketchflow; object[] objArray1 = new object[] { (targetFrameworkName.Identifier == "Silverlight" ? "Silverlight 4" : ".NET Framework 4.0") }; invalidStoreUnsupportedError = string.Format(cultureInfo, invalidStoreUnsupportedSketchflow, objArray1); identifier = "DoNotWarnAboutUnsupportedSketchflowProject"; } } CultureInfo currentUICulture1 = CultureInfo.CurrentUICulture; string unsupportedProjectWithDescription = StringTable.UnsupportedProjectWithDescription; object[] displayName = new object[] { projectStore.DocumentReference.DisplayName, invalidStoreUnsupportedError }; string str = string.Format(currentUICulture1, unsupportedProjectWithDescription, displayName); if (string.IsNullOrEmpty(identifier)) { this.Services.MessageDisplayService().ShowError(str); return; } IServiceProvider services = this.Services; MessageBoxArgs messageBoxArg = new MessageBoxArgs() { Button = MessageBoxButton.OK, Image = MessageBoxImage.Exclamation, Message = str, AutomationId = "UnsupportedProjectErrorDialog" }; services.ShowSuppressibleWarning(messageBoxArg, identifier, MessageBoxResult.OK); }
public static bool UsesSilverlight(IProjectStore projectStore) { return(ProjectStoreHelper.GetSilverlightVersion(projectStore) != null); }
public static bool IsKnownLanguage(IProjectStore projectStore) { return(ProjectStoreHelper.IsKnownLanguage(ProjectStoreHelper.GetProjectLanguage(projectStore))); }
public static bool DoesLanguageSupportXaml(IProjectStore projectStore) { return(ProjectStoreHelper.DoesLanguageSupportXaml(ProjectStoreHelper.GetProjectLanguage(projectStore))); }