private IEnumerable <PageTemplateFile> SearchDirectoryForPageTemplateFiles(string directoryPath, string searchText) { var directoryContents = _resourceLocator.GetDirectory(directoryPath); foreach (var file in directoryContents.Where(f => !f.IsDirectory)) { // filename contains the search text and is located in a 'PageTemplates' folder, but not a 'partials' folder and has the extension .cshtml if (Contains(file.Name, searchText) && !Contains(file.Name, "_ViewStart") && !Contains(file.Name, "_ViewImports") && file.Name.EndsWith(VIEW_FILE_EXTENSION, StringComparison.OrdinalIgnoreCase)) { yield return(MapPageTemplateFile(directoryPath, file)); } } foreach (var childDirectoryName in directoryContents .Where(f => f.IsDirectory) .Select(f => f.Name) ) { var childDirectoryPath = RelativePathHelper.Combine(directoryPath, childDirectoryName); foreach (var file in SearchDirectoryForPageTemplateFiles(childDirectoryPath, searchText)) { yield return(file); } } }
private PageBlockTypeFileLocation CreateTemplateFile(string directoryPath, IFileInfo file) { var templateFile = new PageBlockTypeFileLocation(); templateFile.Path = RelativePathHelper.Combine(directoryPath, file.Name); templateFile.FileName = Path.GetFileNameWithoutExtension(file.Name); var templatePath = RelativePathHelper.Combine(directoryPath, TEMPLATES_FOLDER_NAME); var templateDirectory = _resourceLocator.GetDirectory(templatePath); if (templateDirectory != null) { templateFile.Templates = FilterViewFiles(templateDirectory) .GroupBy(t => t.Name, (k, v) => v.FirstOrDefault()) // De-dup .Select(t => new PageBlockTypeTemplateFileLocation() { FileName = Path.GetFileNameWithoutExtension(t.Name), Path = RelativePathHelper.Combine(templatePath, t.Name) }) .ToDictionary(t => t.FileName); } else { templateFile.Templates = new Dictionary <string, PageBlockTypeTemplateFileLocation>(); } return(templateFile); }
public static string GetFullFilename(string filename) { string mcd = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "state.agilemap", Encoding.Default); return(RelativePathHelper.GetFullPath(mcd, filename)); //return RelativePathHelper.GetFullPath(CurrentFilename, filename); }
internal static string GetRelativeFilename(string filename) { if (!UseRelativePath) { return(filename); } return(RelativePathHelper.GetRelativePath(CurrentFilename, filename)); }
private static bool IsValidInternal(HttpRequest request, IUrlHelper urlHelper, string url) { var isValid = !string.IsNullOrEmpty(url) && urlHelper.IsLocalUrl(url) && !RelativePathHelper.IsWellFormattedAndEqual(request.Path, url); return(isValid); }
public void IsWellFormattedAndEqual_ValidWithAppReleative_ReturnsTrue(string path1, string path2) { var bothResult = RelativePathHelper.IsWellFormattedAndEqual(path1, path1); var path1Result = RelativePathHelper.IsWellFormattedAndEqual(path1, path2); var path2Result = RelativePathHelper.IsWellFormattedAndEqual(path2, path1); Assert.True(bothResult); Assert.True(path1Result); Assert.True(path2Result); }
public void IsWellFormattedAndEqual_WhenInvalid_ReturnsFalse(string path) { var bothResult = RelativePathHelper.IsWellFormattedAndEqual(path, path); var path1Result = RelativePathHelper.IsWellFormattedAndEqual(path, "/mypath"); var path2Result = RelativePathHelper.IsWellFormattedAndEqual("/mypath", path); Assert.False(bothResult); Assert.False(path1Result); Assert.False(path2Result); }
private void AddCurrentChanges(GitVersionIdentification versionIdentification, FilesProgramModel model, Repository repo) { var lastCommit = repo.Head.Tip; TreeChanges diff = repo.Diff.Compare <TreeChanges>(default(Tree), lastCommit.Tree); foreach (var entry in diff) { var filePath = entry.Path; var fullPath = Path.Combine(versionIdentification.RepositoryPath, filePath); var relativePathToSolution = RelativePathHelper.GetRelativePath(model, fullPath); if (model.Files.All(x => !x.Id.Equals(relativePathToSolution, StringComparison.Ordinal))) { model.Files.Add(new FileElement(relativePathToSolution, () => GetContent(versionIdentification.RepositoryPath, lastCommit.Id.Sha, filePath))); } } var status = repo.RetrieveStatus(); status.Added.Union(status.Untracked).ForEach(addedFile => { var fullPath = Path.Combine(versionIdentification.RepositoryPath, addedFile.FilePath); var relativePathToSolution = RelativePathHelper.GetRelativePath(model, fullPath); if (model.Files.All(x => !x.Id.Equals(relativePathToSolution, StringComparison.Ordinal))) { model.Files.Add(new FileElement(relativePathToSolution, () => File.ReadAllText(fullPath))); } }); status.Modified.Union(status.Staged).ForEach(changedFile => { var fullPath = Path.Combine(versionIdentification.RepositoryPath, changedFile.FilePath); var relativePathToSolution = RelativePathHelper.GetRelativePath(model, fullPath); var file = model.Files.SingleOrDefault(x => x.Id.Equals(relativePathToSolution, StringComparison.Ordinal)); if (file != null) { model.Files.Remove(file); model.Files.Add(new FileElement(relativePathToSolution, () => File.ReadAllText(fullPath))); } }); status.Missing.Union(status.Removed).ForEach(changedFile => { var fullPath = Path.Combine(versionIdentification.RepositoryPath, changedFile.FilePath); var relativePathToSolution = RelativePathHelper.GetRelativePath(model, fullPath); if (model.Files.Any(x => x.Id.Equals(relativePathToSolution, StringComparison.Ordinal))) { model.Files.RemoveAll(x => x.Id.Equals(relativePathToSolution, StringComparison.Ordinal)); } }); }
public StructuralDelta <FilesProgramModel, FileElement> Parse(IntendedChangesArtefact artefact) { var delta = new StructuralDelta <FilesProgramModel, FileElement>(artefact.ProgramModel, artefact.ProgramModel); foreach (string intendedChange in artefact.IntendedChanges) { var relativePathToSolution = RelativePathHelper.GetRelativePath(artefact.ProgramModel, intendedChange); delta.ChangedElements.Add(new FileElement(relativePathToSolution, () => File.ReadAllText(intendedChange))); } return(delta); }
public IEnumerable <EmbeddedResourcePath> GetEmbeddedResourcePaths() { if (_adminSettings.Disabled) { yield break; } var path = RouteConstants.PluginModuleResourcePathPrefix + "Shared/Content/"; var rewritePath = RelativePathHelper.Combine(_adminSettings.DirectoryName, path); yield return(new EmbeddedResourcePath(this.GetType().Assembly, path, rewritePath)); }
private PageTemplateFile MapPageTemplateFile(string virtualDirectoryPath, IFileInfo file) { var fileName = Path.ChangeExtension(file.Name, null).TrimStart(TEMPLATE_NAME_CHAR_TO_TRIM); var virtualPath = RelativePathHelper.Combine(virtualDirectoryPath, file.Name); var templateFile = new PageTemplateFile() { FileName = fileName, VirtualPath = virtualPath }; return(templateFile); }
/// <summary> /// Constructor to use when you want to provide a custom resource path prefix, for /// when your module is located in a non-standard directory (or for all internal /// modules where you pass RouteConstants.InternalModuleResourcePathPrefix). /// </summary> /// <param name="routePrefix"> /// The unique entity/folder name of your route to use when building /// urls e.g. products, users, honeybagders. /// </param> /// <param name="resourcePathPrefix">The path prefix to your module e.g. '/admin/modules/'</param> public ModuleRouteLibrary( AdminSettings adminSettings, string routePrefix, string resourcePathPrefix ) { ModuleFolderName = TextFormatter.Pascalize(routePrefix); ResourcePrefix = resourcePathPrefix + ModuleFolderName + "/"; StaticResourcePrefix = RelativePathHelper.Combine(ResourcePrefix, CONTENT_FOLDER); UrlPrefix = routePrefix; _adminSettings = adminSettings; }
private void button2_Click(object sender, EventArgs e) { string fname = @"F:\\产品与项目\\MAS-II\\SMART0718\\SMART\\【控制】UI框架(新整理)\\SMART\\bin\\Release\\数据引用\\基础矢量\\行政区划\\面\\中国行政区.shp"; string refdir = @"F:\\产品与项目\\MAS-II\\SMART0718\\SMART\\【控制】UI框架(新整理)\\SMART\\bin\\Release\\LayoutTemplate\\自定义\\TempMcd.xml"; refdir = "f:\\"; refdir = @"F:\\产品与项目\\MAS-II\\SMART0718\\SMART\\【控制】UI框架(新整理)\\SMART\\TempMcd.xml"; refdir = "e:\\"; refdir = "F:\\产品与项目\\MAS-II\\SMART0718\\SMART\\【控制】UI框架(新整理)\\SMART\\bin\\Release\\数据引用\\基础矢量\\行政区划\\面\\中国面\\西北面\\TempMcd.xml"; string path = RelativePathHelper.GetRelativePath(refdir, fname); path = @"..\..\数据引用\基础矢量\行政区划\面\中国边界.SHP"; refdir = @"F:\产品与项目\MAS-II\SMART0718\SMART\【控制】UI框架(新整理)\SMART\bin\Release\LayoutTemplate\自定义\测试相对路径3.gxt"; string absPath = RelativePathHelper.GetFullPath(refdir, path); }
public ResolveFileConflictDialogViewModel(ICanClose view, IEnumerable <string> fileList) { _okCommand = new RelayCommand(OnOk, IsOKEnabled); _cancelCommand = new RelayCommand(OnCancel); _view = view; var list = new List <DisplayPathHelper>(); foreach (var file in fileList) { var display = new DisplayPathHelper(); display.Path = file; display.DisplayPath = PathUtil.ShortenPath(RelativePathHelper.GetRelativePath(file), MaxPathCharacters); list.Add(display); } _fileList = new ObservableCollection <DisplayPathHelper>(list); }
private static bool CreateTargetClassInTargetProject(Project targetProject, string classTemplatePath) { var sourceProjectPath = Access.ProjectModel.ProjectPathFromFilePath(SourceTargetInfo.SourcePath); Project sourceProject = ProjectFromPath(sourceProjectPath); Logger.InfoFormat("CreateClassHelper.CreateTargetClassInTargetProject, MirrorFolders={0} ", StaticOptions.MainOptions.MirrorProjectFolders); if (!StaticOptions.MainOptions.MirrorProjectFolders) { targetProject.ProjectItems.AddFromTemplate(classTemplatePath, SourceTargetInfo.TargetFileName); SetTargetPathWithAddedItem(targetProject.ProjectItems); return(true); } var relative = RelativePathHelper.GetRelativePath(Path.GetDirectoryName(sourceProject.FullName), Path.GetDirectoryName(SourceTargetInfo.SourcePath)); var trimmed = relative.TrimStart(new[] { '.', Path.DirectorySeparatorChar }); // If we just have a single item without dir separator chars // then there is no folder structure to create if (string.IsNullOrEmpty(trimmed) || !trimmed.Contains(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture))) { Logger.Info("CreateClassHelper.CreateTargetClassInTargetProject, no folder struct"); targetProject.ProjectItems.AddFromTemplate(classTemplatePath, SourceTargetInfo.TargetFileName); SetTargetPathWithAddedItem(targetProject.ProjectItems); return(true); } // get a stack var folderArray = trimmed.Split(new[] { Path.DirectorySeparatorChar }); var folderStack = StackFromArray(folderArray); // add folders recursively if they don't exist AddOrGetProjectFolderItem(targetProject.ProjectItems, folderStack); LastProjectItem.ProjectItems.AddFromTemplate(classTemplatePath, SourceTargetInfo.TargetFileName); SetTargetPathWithAddedItem(LastProjectItem.ProjectItems); return(true); }
private void AddFilesAtCommit(GitVersionIdentification versionIdentification, FilesProgramModel model, Repository repo) { var commit = repo.Commits.SingleOrDefault(x => x.Id.Sha == versionIdentification.Commit.ShaId); if (commit != null) { TreeChanges diff = repo.Diff.Compare <TreeChanges>(default(Tree), commit.Tree); foreach (var entry in diff) { var filePath = entry.Path; var fullPath = Path.Combine(versionIdentification.RepositoryPath, filePath); var relativePathToSolution = RelativePathHelper.GetRelativePath(model, fullPath); if (model.Files.All(x => !x.Id.Equals(relativePathToSolution, StringComparison.Ordinal))) { model.Files.Add(new FileElement(relativePathToSolution, () => GetContent(versionIdentification.RepositoryPath, commit.Id.Sha, filePath))); } } } }
private Dictionary <string, PageBlockTypeFileLocation> GetPageBlockTypeFileLocations() { var viewDirectoryPaths = _pageBlockTypeViewLocationRegistrations .SelectMany(r => r.GetPathPrefixes()) .Select(p => FormatViewFolder(p)) ; var templateFiles = new Dictionary <string, PageBlockTypeFileLocation>(); var foldersToExclude = new string[] { TEMPLATES_FOLDER_NAME, PARTIALS_FOLDER_NAME }; foreach (var directoryPath in viewDirectoryPaths) { var directory = _resourceLocator.GetDirectory(directoryPath); if (!directory.Exists) { continue; } foreach (var viewFile in FilterViewFiles(directory)) { AddTemplateToDictionary(templateFiles, directoryPath, viewFile); } foreach (var childDirectory in directory .Where(d => d.IsDirectory && !foldersToExclude.Any(f => d.Name.Equals(f, StringComparison.OrdinalIgnoreCase)))) { var childDirectoryPath = RelativePathHelper.Combine(directoryPath, childDirectory.Name); foreach (var viewFile in FilterChildDirectoryFiles(childDirectoryPath, directory, foldersToExclude)) { AddTemplateToDictionary(templateFiles, childDirectoryPath, viewFile); } } } return(templateFiles); }
public string StaticResourceFilePath(string fileName) { return(RelativePathHelper.Combine(StaticResourcePrefix, fileName)); }
public void Combine_WhenValid_ReturnsCombined(string path1, string path2, string path3, string expected) { var result = RelativePathHelper.Combine(path1, path2, path3); Assert.Equal(expected, result); }
public string StaticResource(string fileName) { return(RelativePathHelper.Combine(_adminSettings.DirectoryName, StaticResourcePrefix, fileName)); }
public void Combine_WhenMultipleNullOrWhitespace_ReturnsPath(string s) { var result = RelativePathHelper.Combine(s, s, s); Assert.Equal("/", result); }
public string GetStaticResourceUrlPath() { return(RelativePathHelper.Combine(_adminSettings.DirectoryName, StaticResourcePrefix)); }
public string CssDirectory() { return(RelativePathHelper.Combine(_adminSettings.DirectoryName, StaticResourcePrefix, "css")); }