本文整理汇总了C#中FileSystemPath类的典型用法代码示例。如果您正苦于以下问题:C# FileSystemPath类的具体用法?C# FileSystemPath怎么用?C# FileSystemPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileSystemPath类属于命名空间,在下文中一共展示了FileSystemPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImplicitConversionBackToString
public void ImplicitConversionBackToString()
{
var path = new FileSystemPath(@"relative\path", false, @"c:\");
string pathString = path;
pathString.Should().Be(@"c:\relative\path");
}
示例2: ProductSettingsTracker
public ProductSettingsTracker(Lifetime lifetime, ClientFactory clientFactory, IViewable<ISyncSource> syncSources, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
{
myClientFactory = clientFactory;
mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
mySettingsStore.Changed.Advise(lifetime, _ => InitClient());
myRootFolder = FileSystemPath.Parse("ReSharperPlatform");
InitClient();
syncSources.View(lifetime, (lt1, source) =>
source.FilesToSync.View(lt1, (lt2, fileToSync) =>
{
SyncFromCloud(fileToSync.Value);
var fileTrackingLifetime = new SequentialLifetimes(lt2);
fileToSync.Change.Advise(lt2,
args =>
{
var path = args.Property.Value;
if (lifetime.IsTerminated || path.IsNullOrEmpty())
{
fileTrackingLifetime.TerminateCurrent();
}
else
{
fileTrackingLifetime.Next(lt =>
fileSystemTracker.AdviseFileChanges(lt, path,
delta => delta.Accept(new FileChangesVisitor(myClient, myRootFolder))));
}
});
}));
}
示例3: Move
public static void Move(this IFileSystem sourceFileSystem, FileSystemPath sourcePath, IFileSystem destinationFileSystem, FileSystemPath destinationPath)
{
IEntityMover mover;
if (!EntityMovers.Registration.TryGetSupported(sourceFileSystem.GetType(), destinationFileSystem.GetType(), out mover))
throw new ArgumentException("The specified combination of file-systems is not supported.");
mover.Move(sourceFileSystem, sourcePath, destinationFileSystem, destinationPath);
}
示例4: DeclaredElementAsTypeMember
public static IDeclaredElement DeclaredElementAsTypeMember(this MockFactory factory, string typename, string member,
string location)
{
var elt = factory.Create<IDeclaredElement>();
var typeMember = elt.As<ITypeMember>();
var module = factory.Create<IAssemblyPsiModule>();
var file = factory.Create<IAssemblyFile>();
var path = new FileSystemPath(location);
var type = factory.Create<ITypeElement>();
typeMember.Setup(tm => tm.GetContainingType()).Returns(type.Object);
typeMember.Setup(tm => tm.ShortName).Returns(member);
type.Setup(t => t.CLRName).Returns(typename);
file.Setup(f => f.Location).Returns(path);
module.Setup(m => m.Assembly.GetFiles()).Returns(
new[] { file.Object });
typeMember.Setup(te => te.Module).Returns(module.Object);
return elt.Object;
}
示例5: CreateSingleFileSolution
protected Pair<ISolution, IProjectFile> CreateSingleFileSolution(string relativeProjectDirectory, string fileName, string [] systemAssemblies)
{
PlatformInfo platformInfo = PlatformManager.Instance.GetPlatformInfo("Standard", Environment.Version);
string projectDirectory = Path.Combine(testFilesDirectory, relativeProjectDirectory);
FileSystemPath filePath = new FileSystemPath(Path.Combine(projectDirectory, fileName));
if(!File.Exists(filePath.ToString()))
Assert.Fail("File does not exists {0}", filePath);
ISolution solution =
SolutionManager.Instance.CreateSolution(
new FileSystemPath(Path.Combine(projectDirectory, "TestSolution.sln")));
IProject project =
solution.CreateProject(new FileSystemPath(Path.Combine(projectDirectory, "TestProject.csproj")),
ProjectFileType.CSHARP,
platformInfo.PlatformID);
Arp.Common.Assertions.Assert.CheckNotNull(platformInfo);
project.AddAssemblyReference(platformInfo.MscorlibPath.ToString());
if(systemAssemblies != null)
{
foreach (string systemAssemblyName in systemAssemblies)
{
string assemblyPath = GetSystemAssemblyPath(platformInfo, systemAssemblyName);
project.AddAssemblyReference(assemblyPath);
}
}
IProjectFile file = project.CreateFile(filePath);
return new Pair<ISolution, IProjectFile>(solution, file);
}
示例6: Delete
public void Delete(FileSystemPath path)
{
using (var r = Refer(path))
{
r.FileSystem.Delete(GetRelativePath(path));
}
}
示例7: IsArchiveFile
protected override bool IsArchiveFile(IFileSystem fileSystem, FileSystemPath path)
{
return path.IsFile
&& ArchiveExtensions.Contains(path.GetExtension())
&& !HasArchive(path)// HACK: Disable ability to open archives inside archives (SevenZip's stream does not have the ability to trace at the moment).
;
}
示例8: Read
public static NuSpec Read(FileSystemPath path)
{
if (!path.ExistsFile)
return null;
NuSpec nuspec = null;
Logger.CatchSilent(() =>
{
using (var stream = path.OpenFileForReading())
{
stream.ReadXml(packageReader =>
{
if (!packageReader.ReadToDescendant("metadata"))
return;
packageReader.ReadElement(metadataReader =>
{
if (metadataReader.LocalName != "metadata")
return;
nuspec = new NuSpec();
metadataReader.ReadSubElements(childReader =>
{
Action<NuSpec, string> action;
if (StringActions.TryGetValue(childReader.LocalName, out action))
action(nuspec, childReader.ReadElementContentAsString());
});
});
});
}
});
return nuspec;
}
示例9: CreateDirectory
public void CreateDirectory(FileSystemPath path)
{
using (var r = Refer(path))
{
r.FileSystem.CreateDirectory(GetRelativePath(path));
}
}
示例10: T4OutsideSolutionSourceFile
public T4OutsideSolutionSourceFile(IProjectFileExtensions projectFileExtensions,
PsiProjectFileTypeCoordinator projectFileTypeCoordinator, IPsiModule module, FileSystemPath path,
Func<PsiSourceFileFromPath, bool> validityCheck, Func<PsiSourceFileFromPath, IPsiSourceFileProperties> propertiesFactory,
DocumentManager documentManager, IModuleReferenceResolveContext resolveContext)
: base(projectFileExtensions, projectFileTypeCoordinator, module, path, validityCheck, propertiesFactory, documentManager, resolveContext)
{
}
示例11: OpenFile
public Stream OpenFile(FileSystemPath path, FileAccess access)
{
var fs = GetFirst(path);
if (fs == null)
throw new FileNotFoundException();
return fs.OpenFile(path, access);
}
示例12: Move
public void Move(IFileSystem source, FileSystemPath sourcePath, IFileSystem destination, FileSystemPath destinationPath)
{
bool isFile;
if ((isFile = sourcePath.IsFile) != destinationPath.IsFile)
throw new ArgumentException("The specified destination-path is of a different type than the source-path.");
if (isFile)
{
using (var sourceStream = source.OpenFile(sourcePath, FileAccess.Read))
{
using (var destinationStream = destination.CreateFile(destinationPath))
{
byte[] buffer = new byte[BufferSize];
int readBytes;
while ((readBytes = sourceStream.Read(buffer, 0, buffer.Length)) > 0)
destinationStream.Write(buffer, 0, readBytes);
}
}
source.Delete(sourcePath);
}
else
{
destination.CreateDirectory(destinationPath);
foreach (var ep in source.GetEntities(sourcePath).ToArray())
{
var destinationEntityPath = ep.IsFile
? destinationPath.AppendFile(ep.EntityName)
: destinationPath.AppendDirectory(ep.EntityName);
Move(source, ep, destination, destinationEntityPath);
}
if (!sourcePath.IsRoot)
source.Delete(sourcePath);
}
}
示例13: Delete
public void Delete(FileSystemPath path)
{
if (path.IsFile)
System.IO.File.Delete(GetPhysicalPath(path));
else
System.IO.Directory.Delete(GetPhysicalPath(path), true);
}
示例14: AddEntity
public void AddEntity(FileSystemPath path)
{
if (!_entities.Contains(path))
_entities.Add(path);
if (!path.IsRoot)
AddEntity(path.ParentPath);
}
示例15: ProductSettingsTracker
public ProductSettingsTracker(Lifetime lifetime, IProductNameAndVersion product, ClientFactory clientFactory, GlobalPerProductStorage globalPerProductStorage, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
{
myClientFactory = clientFactory;
mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
mySettingsStore.Changed.Advise(lifetime, _ => InitClient());
myRootFolder = FileSystemPath.Parse(product.ProductName);
InitClient();
var productSettingsPath = globalPerProductStorage.XmlFileStorage.Path;
SyncFromCloud(productSettingsPath.Value);
var fileTrackingLifetime = new SequentialLifetimes(lifetime);
productSettingsPath.Change.Advise(lifetime,
args =>
{
var path = args.Property.Value;
if (lifetime.IsTerminated || path.IsNullOrEmpty())
{
fileTrackingLifetime.TerminateCurrent();
}
else
{
fileTrackingLifetime.Next(lt => fileSystemTracker.AdviseFileChanges(lt, path, delta => delta.Accept(new FileChangesVisitor(myClient, myRootFolder))));
}
});
}