• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# RelativePath类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RelativePath的典型用法代码示例。如果您正苦于以下问题:C# RelativePath类的具体用法?C# RelativePath怎么用?C# RelativePath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RelativePath类属于命名空间,在下文中一共展示了RelativePath类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WriteAllText

 public static void WriteAllText(this FileAbstractLayer fal, RelativePath file, string content)
 {
     using (var writer = CreateText(fal, file))
     {
         writer.Write(content);
     }
 }
开发者ID:vicancy,项目名称:docfx,代码行数:7,代码来源:FileAbstractLayerExtensions.cs


示例2: GetPathChangeKind

 public PathChangeKind GetPathChangeKind(RelativePath path) {
   PathChangeKind result;
   if (!_map.TryGetValue(path, out result)) {
     result = PathChangeKind.None;
   }
   return result;
 }
开发者ID:mbbill,项目名称:vs-chromium,代码行数:7,代码来源:FullPathChanges.cs


示例3: FixLink

 private static void FixLink(XAttribute link, RelativePath filePath, HashSet<string> linkToFiles)
 {
     string linkFile;
     string anchor = null;
     if (PathUtility.IsRelativePath(link.Value))
     {
         var index = link.Value.IndexOf('#');
         if (index == -1)
         {
             linkFile = link.Value;
         }
         else if (index == 0)
         {
             return;
         }
         else
         {
             linkFile = link.Value.Remove(index);
             anchor = link.Value.Substring(index);
         }
         var path = filePath + (RelativePath)linkFile;
         var file = (string)path.GetPathFromWorkingFolder();
         link.Value = file + anchor;
         linkToFiles.Add(HttpUtility.UrlDecode(file));
     }
 }
开发者ID:dotnet,项目名称:docfx,代码行数:26,代码来源:RtfDocumentProcessor.cs


示例4: ReadAllText

 public static string ReadAllText(this FileAbstractLayer fal, RelativePath file)
 {
     using (var sr = OpenReadText(fal, file))
     {
         return sr.ReadToEnd();
     }
 }
开发者ID:vicancy,项目名称:docfx,代码行数:7,代码来源:FileAbstractLayerExtensions.cs


示例5: GetProperty

 public static string GetProperty(this FileAbstractLayer fal, RelativePath file, string propertyName)
 {
     var dict = fal.GetProperties(file);
     string result;
     dict.TryGetValue(propertyName, out result);
     return result;
 }
开发者ID:vicancy,项目名称:docfx,代码行数:7,代码来源:FileAbstractLayerExtensions.cs


示例6: Copy

 public override void Copy(PathMapping sourceFilePath, RelativePath destFilePath)
 {
     var key = destFilePath.GetPathFromWorkingFolder();
     _mapping[key] = new PathMapping(key, sourceFilePath.PhysicalPath)
     {
         Properties = sourceFilePath.Properties,
     };
 }
开发者ID:vicancy,项目名称:docfx,代码行数:8,代码来源:LinkFileWriter.cs


示例7: GetSection

 public IEnumerable<string> GetSection(string sectionName, Func<IEnumerable<string>, IEnumerable<string>> postProcessing)
 {
     var filename = new RelativePath(sectionName);
       return _configurationFileProvider.ReadFile(filename, (fullPathName, lines) => {
     _volatileToken.AddFile(fullPathName);
     return postProcessing(lines);
       });
 }
开发者ID:nick-chromium,项目名称:vs-chromium,代码行数:8,代码来源:ConfigurationFileSectionProvider.cs


示例8: FileName

 public FileName(DirectoryName parent, RelativePath relativePath) {
   if (parent == null)
     throw new ArgumentNullException("parent");
   if (relativePath.IsEmpty)
     throw new ArgumentException("Relative path is empty", "relativePath");
   _parent = parent;
   _relativePath = relativePath;
 }
开发者ID:mbbill,项目名称:vs-chromium,代码行数:8,代码来源:FileName.cs


示例9: PhpSourceFile

		public PhpSourceFile(FullPath root, FullPath fullPath)
		{
			root.EnsureNonEmpty("root");
			fullPath.EnsureNonEmpty("fullPath");

			this.fullPath = fullPath;
			this.relativePath = RelativePath.Empty;
			this.root = root;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:9,代码来源:PhpSourceFile.cs


示例10: Exists

 public bool Exists(RelativePath file)
 {
     if (file == null)
     {
         throw new ArgumentNullException(nameof(file));
     }
     EnsureNotDisposed();
     return Reader.FindFile(file) != null;
 }
开发者ID:vicancy,项目名称:docfx,代码行数:9,代码来源:FileAbstractLayer.cs


示例11: FindFile

 public PathMapping? FindFile(RelativePath file)
 {
     var pp = Path.Combine(_expandedInputFolder, file.RemoveWorkingFolder());
     if (!File.Exists(pp))
     {
         return null;
     }
     return new PathMapping(file, Path.Combine(InputFolder, file.RemoveWorkingFolder())) { Properties = Properties };
 }
开发者ID:vicancy,项目名称:docfx,代码行数:9,代码来源:RealFileReader.cs


示例12: RelativePath_Unit_Append1_PathContainsAnotherSeparator

        public void RelativePath_Unit_Append1_PathContainsAnotherSeparator()
        {
            String[] nodes = new String[] { "sites" };
            Char separator = RelativePath.ForwardSlash;
            RelativePath target = new RelativePath(nodes, separator);
            String path = "Chad\\Greer";

            target.Append(path);
        }
开发者ID:cegreer,项目名称:Common,代码行数:9,代码来源:RelativePathTests.cs


示例13: MatchFileName

    public bool MatchFileName(RelativePath relativePath, IPathComparer comparer) {
      var path = relativePath.Value;
      CheckPath(path);

      if (PrePassWontMatch(MatchKind.File, path, comparer))
        return false;

      var result = BaseOperator.Match(MatchKind.File, comparer, Operators, 0, path, 0);
      return IsMatch(path, result);
    }
开发者ID:mbbill,项目名称:vs-chromium,代码行数:10,代码来源:PathMatcher.cs


示例14: OpenRead

 public FileStream OpenRead(RelativePath file)
 {
     if (file == null)
     {
         throw new ArgumentNullException(nameof(file));
     }
     EnsureNotDisposed();
     var pp = FindPhysicalPath(file);
     return File.OpenRead(Environment.ExpandEnvironmentVariables(pp.PhysicalPath));
 }
开发者ID:vicancy,项目名称:docfx,代码行数:10,代码来源:FileAbstractLayer.cs


示例15: ReadFile

        public IEnumerable<string> ReadFile(RelativePath relativePath, Func<FullPath, IEnumerable<string>, IEnumerable<string>> postProcessing)
        {
            foreach (var directoryName in PossibleDirectoryNames()) {
            var path = directoryName.Combine(relativePath);
            if (_fileSystem.FileExists(path))
              return postProcessing(path, _fileSystem.ReadAllLines(path));
              }

              throw new FileLoadException(
            string.Format("Could not load configuration file \"{0}\" from the following locations:{1}", relativePath,
                      PossibleDirectoryNames().Aggregate("", (x, y) => x + "\n" + y)));
        }
开发者ID:nick-chromium,项目名称:vs-chromium,代码行数:12,代码来源:ConfigurationFileProvider.cs


示例16: Create

 public FileStream Create(RelativePath file)
 {
     if (file == null)
     {
         throw new ArgumentNullException(nameof(file));
     }
     EnsureNotDisposed();
     if (!CanWrite)
     {
         throw new InvalidOperationException();
     }
     return Writer.Create(file);
 }
开发者ID:vicancy,项目名称:docfx,代码行数:13,代码来源:FileAbstractLayer.cs


示例17: RelativePath_Unit_Append1_Optimal

        public void RelativePath_Unit_Append1_Optimal()
        {
            String[] nodes = new String[] { "sites" };
            Char separator = RelativePath.ForwardSlash;
            RelativePath target = new RelativePath(nodes, separator);
            String path = "Chad/Greer";

            RelativePath result = target.Append(path);
            Assert.AreEqual("sites", result.Nodes.ElementAt(0));
            Assert.AreEqual("Chad", result.Nodes.ElementAt(1));
            Assert.AreEqual("Greer", result.Nodes.ElementAt(2));
            Assert.AreEqual(separator, result.Separator);
        }
开发者ID:cegreer,项目名称:Common,代码行数:13,代码来源:RelativePathTests.cs


示例18: TestPaths

        public void TestPaths()
        {
            FullPath root;
            FullPath full;
            RelativePath rel;
            string str1, str2;

            string[,] cases = 
      {
          // root:        // full:          // full canonical:    // relative canonical:
        { @"C:\a/b/c/",   @"D:\a/b/",       @"D:\a\b\",           @"D:\a\b\" },
                                            
        { @"C:\a\b\c",    @"C:\a\b\c",      @"C:\a\b\c",          @"" },
        { @"C:\a\b\c",    @"C:\a\b\c\",     @"C:\a\b\c\",         @"" },
        { @"C:\a\b\c\",   @"C:\a\b\c",      @"C:\a\b\c",          @"" },
        { @"C:\a\b\c\",   @"C:\a\b\c\",     @"C:\a\b\c\",         @"" },
                                            
        { @"C:\a\b\c",    @"C:\a\b",        @"C:\a\b",            @".." },
        { @"C:\a\b\c\",   @"C:\a\b",        @"C:\a\b",            @".." },
                                            
        { @"C:\a\b\c",    @"C:\",           @"C:\",                @"..\..\.." },
        { @"C:\a\b\c\",   @"C:\",           @"C:\",                @"..\..\.." },
                                            
        { @"C:\a\b\c\",   @"C:\a\b\x\y\z",  @"C:\a\b\x\y\z",      @"..\x\y\z" },
        { @"C:\a\b\cd\",  @"C:\a\b\c",      @"C:\a\b\c",          @"..\c" },
        { @"C:\a\b\cd",   @"C:\a\b\c",      @"C:\a\b\c",          @"..\c" },
        { @"C:\a\b\cd\",  @"C:\a\b\c\d",    @"C:\a\b\c\d",          @"..\c\d" },
        { @"C:\a\b\cd",   @"C:\a\b\c\d",    @"C:\a\b\c\d",          @"..\c\d" },
      };

            for (int i = 0; i < cases.GetLength(0); i++)
            {
                root = new FullPath(cases[i, 0]);
                full = new FullPath(cases[i, 1]);
                rel = new RelativePath(root, full);

                Assert.AreEqual(full.ToString(), cases[i, 2]);

                Assert.AreEqual(rel.ToString(), cases[i, 3]);

                str1 = full;
                if (str1[str1.Length - 1] == '\\') str1 = str1.Substring(0, str1.Length - 1);

                str2 = rel.ToFullPath(root);
                if (str2[str2.Length - 1] == '\\') str2 = str2.Substring(0, str2.Length - 1);

                Assert.AreEqual(str1, str2);

                Assert.AreEqual(RelativePath.ParseCanonical(cases[i, 3]).ToString(), cases[i, 3]);
            }
        }
开发者ID:dw4dev,项目名称:Phalanger,代码行数:51,代码来源:RelativePathTests.cs


示例19: MatchFileName

    public bool MatchFileName(RelativePath relativePath, IPathComparer comparer) {
      if (relativePath.IsEmpty)
        throw new ArgumentNullException("relativePath");

      if (_fileExtensions.Contains(relativePath.Extension))
        return true;

      // Note: Use "for" loop to avoid allocation if using "Any()"
      for (var index = 0; index < _pathMatchers.Length; index++) {
        if (_pathMatchers[index].MatchFileName(relativePath, comparer))
          return true;
      }
      return false;
    }
开发者ID:mbbill,项目名称:vs-chromium,代码行数:14,代码来源:AnyPathMatcher.cs


示例20: PathMapping

 public PathMapping(RelativePath logicalPath, string physicalPath)
 {
     if (logicalPath == null)
     {
         throw new ArgumentNullException(nameof(logicalPath));
     }
     if (physicalPath == null)
     {
         throw new ArgumentNullException(nameof(physicalPath));
     }
     LogicalPath = logicalPath.GetPathFromWorkingFolder();
     PhysicalPath = physicalPath;
     AllowMoveOut = false;
     Properties = ImmutableDictionary<string, string>.Empty;
 }
开发者ID:vicancy,项目名称:docfx,代码行数:15,代码来源:PathMapping.cs



注:本文中的RelativePath类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RelayCommand类代码示例发布时间:2022-05-24
下一篇:
C# RelativeLayout类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap