本文整理汇总了C#中IDirectory类的典型用法代码示例。如果您正苦于以下问题:C# IDirectory类的具体用法?C# IDirectory怎么用?C# IDirectory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDirectory类属于命名空间,在下文中一共展示了IDirectory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UrlGenerator
public UrlGenerator(IUrlModifier urlModifier, IDirectory sourceDirectory, string cassetteHandlerPrefix)
{
this.urlModifier = urlModifier;
this.cassetteHandlerPrefix = urlModifier.GetHandlerPrefix(cassetteHandlerPrefix);
this.sourceDirectory = sourceDirectory;
urlModifier.SetSourceDirectory(sourceDirectory);
}
示例2: Write
public override void Write(Stream output, IDirectory inputDirectory)
{
BinaryWriter writer = new BinaryWriter(output, Encoding.ASCII, true);
const int sbpHeaderSize = 8;
int entityHeaderSize = Entries.Count * SbpEntry.HeaderSize;
int headerSize = sbpHeaderSize + entityHeaderSize;
long headerPosition = output.Position;
output.Position += headerSize;
output.AlignWrite(16, 0x00);
foreach (var entry in Entries)
{
entry.WriteData(output, inputDirectory);
output.AlignWrite(16, 0x00);
}
long endPosition = output.Position;
output.Position = headerPosition;
writer.Write(0x4C504253); // SBPL
writer.Write(Convert.ToByte(Entries.Count));
writer.Write(Convert.ToUInt16(headerSize));
writer.Write((byte)0x00);
foreach (var entry in Entries)
{
entry.Write(output);
}
output.Position = endPosition;
}
示例3: PruneOperation
/// <summary>
/// Initializes a new instance of the <see cref="SelfMediaDatabase.Core.Operations.Prune.PruneOperation"/> class.
/// </summary>
/// <param name="directory">Injection wrapper of <see cref="System.IO.Directory"/>.</param>
/// <param name="file">Injection wrapper of <see cref="System.IO.File"/>.</param>
/// <param name="path">Injection wrapper of <see cref="System.IO.Path"/>.</param>
/// <param name="imageComparer">Image comparer.</param>
/// <param name="fileSystemHelper">Helper to access to files.</param>
public PruneOperation(
IDirectory directory,
IFile file,
IPath path,
IImageComparer imageComparer,
IFileSystemHelper fileSystemHelper,
IDialog dialog,
IRenameOperation renameOperation)
{
if (directory == null)
throw new ArgumentNullException("directory");
if (file == null)
throw new ArgumentNullException("file");
if (imageComparer == null)
throw new ArgumentNullException("imageComparer");
if (fileSystemHelper == null)
throw new ArgumentNullException("fileSystemHelper");
if (path == null)
throw new ArgumentNullException("path");
if (dialog == null)
throw new ArgumentNullException("dialog");
if (renameOperation == null)
throw new ArgumentNullException("renameOperation");
_directory = directory;
_file = file;
_path = path;
_imageComparer = imageComparer;
_fileSystemHelper = fileSystemHelper;
_dialog = dialog;
_renameOperation = renameOperation;
}
示例4: UncompressedPackage
public UncompressedPackage(IPackageRepository source,
IFile originalPackageFile,
IDirectory wrapCacheDirectory)
{
Check.NotNull(source, "source");
if (originalPackageFile == null || originalPackageFile.Exists == false)
{
IsValid = false;
return;
}
_originalPackageFile = originalPackageFile;
BaseDirectory = wrapCacheDirectory;
// get the descriptor file inside the package
Source = source;
var wrapDescriptor = wrapCacheDirectory.Files("*.wrapdesc").SingleOrDefault();
if (wrapDescriptor == null)
{
IsValid = false;
return;
}
var versionFile = wrapCacheDirectory.GetFile("version");
_descriptor = new PackageDescriptorReader().Read(wrapDescriptor);
_semver = _descriptor.SemanticVersion ?? _descriptor.Version.ToSemVer();
if (_semver == null)
_semver = versionFile.Exists ? versionFile.ReadString().ToSemVer() : null;
IsValid = string.IsNullOrEmpty(Name) == false && _semver != null;
if (IsValid)
Identifier = new PackageIdentifier(Name, _semver);
}
示例5: ProcessSingleBundle
protected Bundle ProcessSingleBundle(IFileHelper fileHelper, IDirectory directory, List<Bundle> bundlesToSort,
Dictionary<string, string> uncachedToCachedFiles, Bundle bundle, AssignHash hasher)
{
Trace.Source.TraceInformation("Processing {0} {1}", bundle.GetType().Name, bundle.Path);
//need to process early to generate an accurate hash.
if (IsCompositeBundle(bundle))
{
bundle.Process(settings);
}
else
{
hasher.Process(bundle, settings);
}
var bundleKey = CassetteSettings.bundles.GetSafeString(Encoding.Default.GetString(bundle.Hash));
if (CassetteSettings.bundles.ContainsKey(fileHelper, directory, uncachedToCachedFiles, bundleKey, bundle))
{
bundle = CassetteSettings.bundles.GetBundle(fileHelper, directory, uncachedToCachedFiles, bundleKey, bundle);
bundlesToSort.Add(bundle);
}
else
{
var unprocessedAssetPaths = CassetteSettings.bundles.GetAssetPaths(bundle);
if (!IsCompositeBundle(bundle))
{
bundle.Process(settings);
}
CassetteSettings.bundles.AddBundle(fileHelper, uncachedToCachedFiles, bundleKey, bundle, unprocessedAssetPaths);
}
return bundle;
}
示例6: UncompressedPackage
public UncompressedPackage(IPackageRepository source,
IFile originalPackageFile,
IDirectory wrapCacheDirectory)
{
Check.NotNull(source, "source");
if (originalPackageFile == null || originalPackageFile.Exists == false)
{
IsValid = false;
return;
}
_originalPackageFile = originalPackageFile;
BaseDirectory = wrapCacheDirectory;
// get the descriptor file inside the package
Source = source;
var wrapDescriptor = wrapCacheDirectory.Files("*.wrapdesc").SingleOrDefault();
if (wrapDescriptor == null)
{
IsValid = false;
return;
}
var versionFile = wrapCacheDirectory.GetFile("version");
_descriptor = new PackageDescriptorReaderWriter().Read(wrapDescriptor);
PackageInfo = new DefaultPackageInfo(originalPackageFile.Name,
versionFile.Exists ? versionFile.Read(x => x.ReadString().ToVersion()) : null,
_descriptor);
Identifier = new PackageIdentifier(Name, Version);
IsValid = true;
}
示例7: FindFiles
/// <summary>
/// Searches the given directory for files matching the search parameters of this object.
/// </summary>
/// <param name="directory">The directory to search.</param>
/// <returns>A collection of files.</returns>
public IEnumerable<IFile> FindFiles(IDirectory directory)
{
return from pattern in GetFilePatterns()
from file in directory.GetFiles(pattern, SearchOption)
where IsAssetFile(file)
select file;
}
示例8: VirtualDirectory
/// <summary>
/// Creates a new virtual directory.
/// </summary>
/// <param name="name">The name of the directory as it will be seen in the directory.</param>
/// <param name="parent">An <see cref="IDirectory" /> specifying the parent directory. This value should be <c>null</c> if this directory is to be the root directory.</param>
public VirtualDirectory(string name, IDirectory parent)
{
this.name = name;
this.parent = parent;
directories = new Hashtable();
files = new Hashtable();
}
示例9: CopyAsync
public async Task<IFile> CopyAsync(IDirectory destDirectory)
{
if (!(destDirectory is DirectoryWindowsStore))
throw new InvalidDirectoryException("destDirectory must be of WindowsStore Type");
var storeDirectory = destDirectory as DirectoryWindowsStore;
return new FileWindowsStore(await _storageFile.CopyAsync(storeDirectory.StorageFolder));
}
示例10: BasicStats
// Methods
public BasicStats(string name, IDirectory parent, Dictionary<Guid, User> users)
{
this.name = name;
this.parent = parent;
this.users = users;
this.started = DateTime.UtcNow;
}
示例11: WriteData
public void WriteData(BinaryWriter writer, IDirectory inputDirectory)
{
long ftexHeaderPosition = writer.BaseStream.Position;
writer.BaseStream.Position += HeaderSize + Entries.Count * PftxsFtexsFileEntry.HeaderSize;
foreach (var entry in Entries)
{
entry.CalculateHash();
var data = inputDirectory.ReadFile(Hashing.NormalizeFilePath(entry.FilePath));
entry.Offset = Convert.ToInt32(writer.BaseStream.Position - ftexHeaderPosition);
entry.Size = Convert.ToInt32(data.Length);
writer.Write(data);
}
CalculateHash();
long endPosition = writer.BaseStream.Position;
writer.BaseStream.Position = ftexHeaderPosition;
writer.Write(Convert.ToUInt32(0x58455446)); // FTEX
writer.Write(Convert.ToUInt32(endPosition - ftexHeaderPosition)); // Size
writer.Write(Hash);
writer.Write(Convert.ToUInt32(Entries.Count));
writer.Write(0U);
writer.Write(0U);
writer.Write(0U);
foreach (var entry in Entries)
{
entry.Write(writer);
}
writer.BaseStream.Position = endPosition;
}
示例12: OnFileRequested
/// <summary>
/// Called when the file is requested by a client.
/// </summary>
/// <param name="request">The <see cref="HttpRequest"/> requesting the file.</param>
/// <param name="directory">The <see cref="IDirectory"/> of the parent directory.</param>
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
if(request.IfModifiedSince != DateTime.MinValue)
{
if(File.GetLastWriteTimeUtc(path) < request.IfModifiedSince)
request.Response.ResponseCode = "304";
return;
}
if(request.IfUnmodifiedSince != DateTime.MinValue)
{
if(File.GetLastWriteTimeUtc(path) > request.IfUnmodifiedSince)
request.Response.ResponseCode = "304";
return;
}
if(System.IO.Path.GetFileName(path).StartsWith("."))
{
request.Response.ResponseCode = "403";
return;
}
try
{
request.Response.ResponseContent = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
}
catch(FileNotFoundException)
{
request.Response.ResponseCode = "404";
}
catch(IOException e)
{
request.Response.ResponseCode = "500";
request.Server.Log.WriteLine(e);
}
}
示例13: OptionsUtils
/// <summary>
/// Initializes a new instance of the <see cref="SelfMediaDatabase.Console.OptionsUtils"/> class.
/// </summary>
/// <param name="directory">Wrapper for <see cref="System.IO.Directory"/>.</param>
public OptionsUtils(IDirectory directory)
{
if (directory == null)
throw new ArgumentNullException("directory");
_directory = directory;
}
示例14: GitDirectory
public GitDirectory(IDirectory parent, string name, DateTime commitTime, Tree tree) : base(parent, name, Enumerable.Empty<IDirectory>(), Enumerable.Empty<IFile>())
{
m_Name = name;
m_CommitTime = commitTime;
m_Tree = tree;
}
示例15: ProcessIsolatedEnvironment
public ProcessIsolatedEnvironment(IDirectory baseDirectory)
{
_baseDirectory = baseDirectory;
_environmentId = Guid.NewGuid().ToString();
_handle = new EventWaitHandle(false, EventResetMode.AutoReset, _environmentId);
_hostProcess = CreateProcess(_environmentId);
}