本文整理汇总了C#中RelativePath类的典型用法代码示例。如果您正苦于以下问题:C# RelativePath类的具体用法?C# RelativePath怎么用?C# RelativePath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelativePath类属于命名空间,在下文中一共展示了RelativePath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteAllText
public static void WriteAllText(this FileAbstractLayer fal, RelativePath file, string content)
{
using (var writer = CreateText(fal, file))
{
writer.Write(content);
}
}
示例2: GetPathChangeKind
public PathChangeKind GetPathChangeKind(RelativePath path) {
PathChangeKind result;
if (!_map.TryGetValue(path, out result)) {
result = PathChangeKind.None;
}
return result;
}
示例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));
}
}
示例4: ReadAllText
public static string ReadAllText(this FileAbstractLayer fal, RelativePath file)
{
using (var sr = OpenReadText(fal, file))
{
return sr.ReadToEnd();
}
}
示例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;
}
示例6: Copy
public override void Copy(PathMapping sourceFilePath, RelativePath destFilePath)
{
var key = destFilePath.GetPathFromWorkingFolder();
_mapping[key] = new PathMapping(key, sourceFilePath.PhysicalPath)
{
Properties = sourceFilePath.Properties,
};
}
示例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);
});
}
示例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;
}
示例9: PhpSourceFile
public PhpSourceFile(FullPath root, FullPath fullPath)
{
root.EnsureNonEmpty("root");
fullPath.EnsureNonEmpty("fullPath");
this.fullPath = fullPath;
this.relativePath = RelativePath.Empty;
this.root = root;
}
示例10: Exists
public bool Exists(RelativePath file)
{
if (file == null)
{
throw new ArgumentNullException(nameof(file));
}
EnsureNotDisposed();
return Reader.FindFile(file) != null;
}
示例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 };
}
示例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);
}
示例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);
}
示例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));
}
示例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)));
}