private void EnsureDeepZoomProjectItems(IProjectItem deepZoomProjectItem) { string[] directoryExtensions = DeepZoomHelper.GetDirectoryExtensions(deepZoomProjectItem.DocumentReference.Path); if (directoryExtensions != null) { string[] strArrays = directoryExtensions; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; Microsoft.Expression.Framework.Documents.DocumentReference documentReference = DeepZoomHelper.CreateDeepZoomDirectoryReference(deepZoomProjectItem.DocumentReference, str); IProjectItem projectItem = base.FindItem(documentReference); if (projectItem != null && !deepZoomProjectItem.Children.ToList <IProjectItem>().Contains(projectItem)) { this.RemoveProjectItem(projectItem, false); projectItem = null; } if (projectItem == null && Microsoft.Expression.Framework.Documents.PathHelper.FileOrDirectoryExists(documentReference.Path)) { IProjectItem folderProjectItem = new FolderProjectItem(this, documentReference, base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder], base.Services, true, Microsoft.Expression.Project.FileTable.GetImageSource("Resources\\Folder_DeepZoom.png")); if (this.AddProjectItem(folderProjectItem, ProjectItemEventOptions.None)) { deepZoomProjectItem.AddChild(folderProjectItem); } } } } }
private void LoadDirectory(string directoryPath, IProjectItem parentItem) { FileInfo[] files = (new DirectoryInfo(directoryPath)).GetFiles(); for (int i = 0; i < (int)files.Length; i++) { FileInfo fileInfo = files[i]; if ((fileInfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { Microsoft.Expression.Framework.Documents.DocumentReference documentReference = Microsoft.Expression.Framework.Documents.DocumentReference.Create(fileInfo.FullName); IDocumentType documentType = this.GetDocumentType(fileInfo.FullName); this.AddItemDuringLoad(documentType, documentReference, parentItem); } } string[] directories = Directory.GetDirectories(directoryPath); for (int j = 0; j < (int)directories.Length; j++) { string str = directories[j]; if (((new DirectoryInfo(str)).Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { IDocumentType item = base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder]; string str1 = string.Concat(str, Path.DirectorySeparatorChar); FolderProjectItem folderProjectItem = this.AddItemDuringLoad(item, Microsoft.Expression.Framework.Documents.DocumentReference.Create(str1), parentItem) as FolderProjectItem; if (this.ShouldInitializeFolder(folderProjectItem)) { this.LoadDirectory(str, folderProjectItem); } } } }
private IProjectItem GetUpdatedItem(IProjectItem item, FileInfo fileInfo, CreationOptions creationOptions) { IDocumentType documentType = this.GetDocumentType(item.DocumentReference.Path); if (item.DocumentType == documentType) { return(null); } if (item.DocumentType == base.Services.DocumentTypes()[DocumentTypeNamesHelper.Xml] && documentType == base.Services.DocumentTypes()[DocumentTypeNamesHelper.DeepZoom]) { string[] directoryExtensions = DeepZoomHelper.GetDirectoryExtensions(item.DocumentReference.Path); for (int i = 0; i < (int)directoryExtensions.Length; i++) { string str = directoryExtensions[i]; Microsoft.Expression.Framework.Documents.DocumentReference documentReference = DeepZoomHelper.CreateDeepZoomDirectoryReference(item.DocumentReference, str); IProjectItem projectItem = base.FindItem(documentReference); if (projectItem != null) { this.RemoveProjectItem(projectItem, false); } } } this.RemoveProjectItem(item, false); DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo() { TargetPath = fileInfo.FullName, CreationOptions = creationOptions, DocumentType = documentType }; return(base.AddItem(documentCreationInfo)); }
public static IProjectStore CreateInstance(Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IServiceProvider serviceProvider) { if (documentReference == null) { throw new ArgumentNullException("documentReference"); } if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (!documentReference.IsValidPathFormat) { throw new ArgumentException("Document reference must be a valid path.", "documentReference"); } if (!File.Exists(documentReference.Path)) { throw new FileNotFoundException("File not found.", documentReference.Path); } string safeExtension = Microsoft.Expression.Framework.Documents.PathHelper.GetSafeExtension(documentReference.Path); if (string.IsNullOrEmpty(safeExtension)) { return(null); } if (!MSBuildBasedProjectStore.KnownMSBuildExtensions.Contains <string>(safeExtension.ToUpperInvariant())) { return(null); } MSBuildBasedProjectStore mSBuildBasedProjectStore = new MSBuildBasedProjectStore(documentReference); mSBuildBasedProjectStore.LoadProject(); mSBuildBasedProjectStore.blendVersion = (serviceProvider.ExpressionInformationService() == null ? "0.0.0.0" : serviceProvider.ExpressionInformationService().Version.ToString()); return(mSBuildBasedProjectStore); }
internal SolutionBase(IServiceProvider serviceProvider, Microsoft.Expression.Framework.Documents.DocumentReference documentReference) : base(documentReference) { this.serviceProvider = serviceProvider; this.readOnlyProjects = new ReadOnlyCollection <INamedProject>(this.projects); this.IsClosingAllProjects = false; this.IsSafeClose = false; }
private MigratingMSBuildStore(Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IServiceProvider serviceProvider) { this.DocumentReference = documentReference; this.serviceProvider = serviceProvider; this.AttemptToMigrate = (bool callerSuccess) => { if (!callerSuccess) { return(callerSuccess); } try { ProjectPathHelper.AttemptToMakeWritable(this.DocumentReference, this.serviceProvider); this.Save(); IProjectStore projectStore = MSBuildBasedProjectStore.CreateInstance(this.DocumentReference, this.serviceProvider); this.NestedStore.Dispose(); this.NestedStore = projectStore; this.AttemptToMigrate = (bool value) => value; } catch (InvalidProjectFileException invalidProjectFileException) { this.LastError = invalidProjectFileException; } return(callerSuccess); }; }
public static XmlMSBuildProjectStore CreateInstance(Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IServiceProvider serviceProvider) { if (documentReference == null) { throw new ArgumentNullException("documentReference"); } if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (!documentReference.IsValidPathFormat) { throw new ArgumentException("Document reference must be a valid path.", "documentReference"); } if (!File.Exists(documentReference.Path)) { throw new FileNotFoundException("File not found.", documentReference.Path); } XmlMSBuildProjectStore xmlMSBuildProjectStore = new XmlMSBuildProjectStore(documentReference) { document = XDocument.Load(documentReference.Path) }; if (xmlMSBuildProjectStore.document == null) { return(null); } return(xmlMSBuildProjectStore); }
public ProjectItem(IProject project, Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IDocumentType documentType, IServiceProvider serviceProvider) : base(project, documentReference, documentType, serviceProvider) { this.UpdateFileInformation(); base.Project.ItemDeleted += new EventHandler <ProjectItemEventArgs>(this.Project_ItemDeleted); base.Project.ItemRemoved += new EventHandler <ProjectItemEventArgs>(this.Project_ItemRemoved); base.Project.ItemRenamed += new EventHandler <ProjectItemRenamedEventArgs>(this.Project_ItemRenamed); }
public INamedProject FindProject(Microsoft.Expression.Framework.Documents.DocumentReference projectReference) { if (projectReference == null || this.projects == null) { return(null); } return(this.projects.FirstOrDefault <INamedProject>((INamedProject p) => projectReference.Path == p.DocumentReference.Path)); }
public string GetResourceReference(Microsoft.Expression.Framework.Documents.DocumentReference referencingDocument) { if (referencingDocument != null && referencingDocument.Equals(this.Project.ProjectRoot)) { return(this.ProjectRelativeDocumentReference.TrimStart(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectorySeparatorCharacters())); } return((new ResourceReferenceCreator(this)).CreateResourceReferenceFromDocument(referencingDocument)); }
protected ProjectStoreBase(Microsoft.Expression.Framework.Documents.DocumentReference documentReference) { if (documentReference == null) { throw new ArgumentNullException("documentReference"); } this.DocumentReference = documentReference; }
public void Rename(Microsoft.Expression.Framework.Documents.DocumentReference newDocumentReference) { if (!this.SafeToRename) { throw new InvalidOperationException("Rename not supported on this type of document item."); } this.documentReference = newDocumentReference; }
private void RefreshDirectory(string directoryPath, bool selectNewlyCreatedItems) { if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(directoryPath)) { return; } CreationOptions creationOption = (selectNewlyCreatedItems ? CreationOptions.None : CreationOptions.DoNotSelectCreatedItems); foreach (FileInfo fileInfo in (new DirectoryInfo(directoryPath)).EnumerateFiles()) { if ((fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } Microsoft.Expression.Framework.Documents.DocumentReference documentReference = Microsoft.Expression.Framework.Documents.DocumentReference.Create(fileInfo.FullName); IProjectItem projectItem = base.FindItem(documentReference); if (projectItem != null) { IProjectItem updatedItem = this.GetUpdatedItem(projectItem, fileInfo, creationOption); projectItem = (updatedItem != null ? updatedItem : projectItem); } else { IDocumentType documentType = this.GetDocumentType(fileInfo.FullName); DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo() { TargetPath = fileInfo.FullName, CreationOptions = creationOption, DocumentType = documentType }; projectItem = base.CreateProjectItemIfNeeded(documentCreationInfo); if (projectItem == null) { continue; } this.AddProjectItem(projectItem, ProjectItemEventOptions.None); } } foreach (string str in Directory.EnumerateDirectories(directoryPath)) { if (!this.ShouldInitializeFolder(base.FindItem(Microsoft.Expression.Framework.Documents.DocumentReference.Create(str)) as FolderProjectItem)) { continue; } this.RefreshDirectory(str, selectNewlyCreatedItems); } if (directoryPath != base.ProjectRoot.Path) { Microsoft.Expression.Framework.Documents.DocumentReference documentReference1 = Microsoft.Expression.Framework.Documents.DocumentReference.Create(string.Concat(directoryPath, Path.DirectorySeparatorChar)); if (base.FindItem(documentReference1) == null) { IProjectItem folderProjectItem = new FolderProjectItem(this, documentReference1, base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder], base.Services); base.AddProjectItem(folderProjectItem); } } }
protected ProjectBase(IProjectStore projectStore, IServiceProvider serviceProvider) : base(projectStore.DocumentReference) { this.Services = serviceProvider; if (projectStore.DocumentReference.IsValidPathFormat) { this.projectRoot = Microsoft.Expression.Framework.Documents.DocumentReference.Create(PathHelper.EnsurePathEndsInDirectorySeparator(PathHelper.GetDirectory(projectStore.DocumentReference.Path))); } this.ProjectFileInformation = new Microsoft.Expression.Project.ProjectFileInformation(projectStore.DocumentReference.Path); this.ProjectStore = projectStore; }
protected override void RenameProjectItemInternal(IProjectItem projectItem, Microsoft.Expression.Framework.Documents.DocumentReference newDocumentReference) { if (projectItem == this.StartupItem) { IProjectStore projectStore = base.ProjectStore; string projectRelativeDocumentReference = projectItem.ProjectRelativeDocumentReference; char[] directorySeparatorChar = new char[] { Path.DirectorySeparatorChar }; projectStore.SetProperty("StartPageUrl", projectRelativeDocumentReference.TrimStart(directorySeparatorChar)); } }
internal static IProjectStore CreateInstance(Microsoft.Expression.Framework.Documents.DocumentReference documentReference, string invalidStateDescription, IServiceProvider serviceProvider) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } return(new InvalidProjectStore(documentReference) { InvalidStateDescription = invalidStateDescription }); }
public IProject FindProjectContainingItem(Microsoft.Expression.Framework.Documents.DocumentReference documentReference) { IProject project = null; foreach (IProject project1 in this.Projects) { if (project1.FindItem(documentReference) == null) { continue; } project = project1; break; } return(project); }
public static IProjectStore CreateInstance(Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IServiceProvider serviceProvider) { IProjectStore projectStore; try { projectStore = MSBuildBasedProjectStore.CreateInstance(documentReference, serviceProvider); } catch (InvalidProjectFileException invalidProjectFileException1) { InvalidProjectFileException invalidProjectFileException = invalidProjectFileException1; MigratingMSBuildStore migratingMSBuildStore = new MigratingMSBuildStore(documentReference, serviceProvider) { LastError = invalidProjectFileException, NestedStore = XmlMSBuildProjectStore.CreateInstance(documentReference, serviceProvider) }; projectStore = migratingMSBuildStore; } return(projectStore); }
public IProject FindProjectContainingOpenItem(Microsoft.Expression.Framework.Documents.DocumentReference documentReference) { bool flag = false; foreach (IView view in this.Services.ViewService().Views) { DocumentView documentView = view as DocumentView; if (documentView == null || documentView.Document == null || StringComparer.OrdinalIgnoreCase.Compare(documentReference.Path, documentView.Document.DocumentReference.Path) != 0) { continue; } flag = true; break; } if (!flag) { return(null); } return(this.FindProjectContainingItem(documentReference)); }
private void EnsureServer(Microsoft.Expression.Framework.Documents.DocumentReference serverLocation) { if (this.serverHandle.HasValue && !this.webServerService.IsServerReachable(this.serverHandle.Value, WebApplicationProject.CassiniTimeout)) { this.webServerService.StopBrowsingSession(this.serverHandle.Value); this.serverHandle = null; } ISolution currentSolution = base.Services.ProjectManager().CurrentSolution; if (!this.serverHandle.HasValue && currentSolution != null) { WebServerSettings webServerSetting = new WebServerSettings(serverLocation.Path); int?webServerPort = this.GetWebServerPort(); if (!webServerPort.HasValue || !this.IsPortAvailable(webServerPort.Value)) { object projectProperty = currentSolution.SolutionSettingsManager.GetProjectProperty(this, "Port"); if (projectProperty is int && this.IsPortAvailable((int)projectProperty)) { webServerSetting.Port = (int)projectProperty; } } else { webServerSetting.Port = webServerPort.Value; } this.serverHandle = new int?(this.webServerService.StartServer(webServerSetting)); } if (this.serverHandle.HasValue && currentSolution != null) { string sessionAddress = this.webServerService.GetSessionAddress(this.serverHandle.Value); if (!string.IsNullOrEmpty(sessionAddress)) { Uri uri = new Uri(sessionAddress, UriKind.Absolute); if (uri.Port >= 0) { currentSolution.SolutionSettingsManager.SetProjectProperty(this, "Port", uri.Port); } } } }
private void PlaceItemInFolder(IProjectItem projectItem) { string parentDirectory = Microsoft.Expression.Framework.Documents.PathHelper.GetParentDirectory(projectItem.DocumentReference.Path); if (!string.IsNullOrEmpty(parentDirectory)) { Microsoft.Expression.Framework.Documents.DocumentReference documentReference = Microsoft.Expression.Framework.Documents.DocumentReference.Create(parentDirectory); if (base.DocumentReference.Equals(documentReference)) { return; } IProjectItem item = base.Items[documentReference.GetHashCode()]; if (item == null) { item = new FolderProjectItem(this, documentReference, base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder], base.Services); base.AddProjectItem(item); } if (item.CanAddChildren) { item.AddChild(projectItem); } } }
internal static IProjectStore CreateInstance(Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IServiceProvider serviceProvider) { if (documentReference == null) { throw new ArgumentNullException("documentReference"); } if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (!documentReference.IsValidPathFormat) { throw new ArgumentOutOfRangeException("documentReference", "Document reference must be a valid path."); } if (File.Exists(documentReference.Path)) { return(null); } if (!Directory.Exists(documentReference.Path)) { throw new FileNotFoundException("Directory not found.", documentReference.Path); } return(new FileSystemProjectStore(documentReference)); }
private FileSystemProjectStore(Microsoft.Expression.Framework.Documents.DocumentReference documentReference) : base(documentReference) { }
protected ProjectItemBase(IProject project, Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IDocumentType documentType, IServiceProvider serviceProvider) : base(documentReference) { this.serviceProvider = serviceProvider; this.project = project; this.documentType = documentType; }
private MSBuildBasedProjectStore(Microsoft.Expression.Framework.Documents.DocumentReference documentReference) : base(documentReference) { }
internal WebProjectSolution(IServiceProvider serviceProvider, Microsoft.Expression.Framework.Documents.DocumentReference documentReference) : base(serviceProvider, documentReference) { }
public FolderProjectItem(IProject project, Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IDocumentType documentType, IServiceProvider serviceProvider, bool isBlockingFolder) : this(project, documentReference, documentType, serviceProvider, isBlockingFolder, null) { }
public FolderProjectItem(IProject project, Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IDocumentType documentType, IServiceProvider serviceProvider, bool isBlockingFolder, ImageSource image) : base(project, documentReference, documentType, serviceProvider) { this.IsUIBlockingFolder = isBlockingFolder; this.overrideImage = image; }
private IProjectItem AddItemDuringLoad(IDocumentType documentType, Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IProjectItem parentItem) { IProjectItem projectItem = base.FindItem(documentReference) ?? documentType.CreateProjectItem(this, documentReference, base.Services); return(this.AddItemDuringLoad(projectItem, parentItem)); }
public AssemblyProjectItem(IProject project, Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IDocumentType documentType, IServiceProvider serviceProvider) : base(project, documentReference, documentType, serviceProvider) { this.UpdateGlobalAssemblyCacheProperty(); }