本文整理汇总了C#中IFile类的典型用法代码示例。如果您正苦于以下问题:C# IFile类的具体用法?C# IFile怎么用?C# IFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFile类属于命名空间,在下文中一共展示了IFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
public override void Import(IFile fileSystem, string rootPath)
{
string folderPath = GetFolder(rootPath);
string fileFullPath = System.IO.Path.Combine(folderPath, GetExportedFilename());
content = fileSystem.ReadBinary(fileFullPath);
}
示例2: ExploreFile
public void ExploreFile(IFile psiFile, UnitTestElementLocationConsumer consumer, CheckForInterrupt interrupted)
{
if ((psiFile.Language.Is<JavaScriptLanguage>() && !psiFile.Language.Is<JavaScriptWinRTLanguage>()) && (psiFile.GetProject() != null))
{
psiFile.ProcessDescendants(new JasmineFileExplorer(myFactory, consumer, psiFile, interrupted, myJavaScriptDependencyManager.GetTransitiveDependencies(psiFile.GetSourceFile())));
}
}
示例3: FileStream
public FileStream(IFile file)
{
if (file == null)
throw new ArgumentNullException("file");
File = file;
}
示例4: CreateModelReference
public static ModelReference CreateModelReference(IFile file)
{
var model = LoadModel(file);
var reference = new ModelReference(file.FullPathName, model);
References.Add(reference);
return reference;
}
示例5: Suite
public Suite(IFile systemFile)
{
System = Path.GetFileNameWithoutExtension(systemFile.FullPath);
SystemFile = systemFile;
LastRun = DateTime.MinValue;
}
示例6: Compile
public string Compile(string source, IFile sourceFile)
{
lock (_lock)
{
rootDirectory = sourceFile.Directory;
Initialize();
StartRecordingOpenedFiles();
dependentFileList.Add(sourceFile.FullPath);
try
{
var compilerOptions = GetCompilerOptions(sourceFile);
return (string)sassCompiler.compile(source, compilerOptions);
}
catch (Exception e)
{
// Provide more information for SassSyntaxErrors
if (e.Message == "Sass::SyntaxError")
{
throw CreateSassSyntaxError(sourceFile, e);
}
else
{
throw;
}
}
finally
{
StopRecordingOpenedFiles();
}
}
}
示例7: SetUp
public void SetUp()
{
_file = MockRepository.GenerateMock<IFile>();
_recentActivities = new RecentActivities(_file);
_recentActivities.Update(FIRST_ACTIVITY);
}
示例8: 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);
}
示例9: Compile
public string Compile(string lessSource, IFile sourceFile)
{
Trace.Source.TraceInformation("Compiling {0}", sourceFile.FullPath);
lock (engine)
{
currentFiles.Clear();
var result = CompileImpl(lessSource, sourceFile);
if (result.Css != null)
{
Trace.Source.TraceInformation("Compiled {0}", sourceFile.FullPath);
return result.Css;
}
else
{
var message = string.Format(
"Less compile error in {0}:\r\n{1}",
sourceFile.FullPath,
result.ErrorMessage
);
Trace.Source.TraceEvent(TraceEventType.Critical, 0, message);
throw new LessCompileException(message);
}
}
}
示例10: ExploreFile
public void ExploreFile(IFile psiFile, UnitTestElementLocationConsumer consumer, CheckForInterrupt interrupted)
{
if (psiFile.Language.Name != "CSHARP" && psiFile.Language.Name != "VBASIC")
return;
psiFile.ProcessDescendants(new XunitFileExplorer(provider, psiFile.GetSourceFile().ToProjectFile(), consumer, interrupted));
}
示例11: Post
public OperationResult Post(IFile file)
{
return new OperationResult.SeeOther
{
RedirectLocation = typeof(UploadedFile).CreateUri(new { id = this.ReceiveStream(file.ContentType, file.OpenStream()) })
};
}
示例12: ReplaceLegacyControlTags
private static void ReplaceLegacyControlTags(IFile file)
{
var contents = file.Contents;
var regex = new Regex
(@"(<%@\s*?Register\s+?TagPrefix="")(.+?)(""\s+?Namespace="".+?""\s+?Assembly="")(Subtext.Web.Controls)(""\s*?%>)"
, RegexOptions.IgnoreCase | RegexOptions.Multiline
);
var newContent = regex.Replace(contents, delegate(Match m)
{
if (m.Groups[2].Value.Equals("st", StringComparison.CurrentCultureIgnoreCase))
{
return string.Empty;
}
var sb = new StringBuilder();
sb.Append(m.Groups[1].Value);
sb.Append(m.Groups[2].Value);
sb.Append(m.Groups[3].Value);
sb.Append("Subtext.Web");
sb.Append(m.Groups[5].Value);
return sb.ToString();
});
if (contents != newContent)
{
var stream = new StreamWriter(file.OpenWrite());
stream.Write(newContent);
stream.Close();
}
}
示例13: DecryptToStream
public void DecryptToStream(IFile file, Stream outputStream)
{
if (file == null)
throw new ArgumentNullException(nameof(file));
if (outputStream == null)
throw new ArgumentNullException(nameof(outputStream));
//Read IV
int ivSize = _encryptionProvider.BlockSize / 8;
byte[] iv = new byte[ivSize];
using (Stream fileData = file.Read())
{
fileData.Seek(0, SeekOrigin.Begin);
fileData.Read(iv, 0, iv.Length);
//Write decrypted data
byte[] key = _key.GenerateBlock(_encryptionProvider.BlockSize);
ICryptoTransform decryptor = _encryptionProvider.CreateDecryptor(key, iv);
using (var cryptoStream = new CryptoStream(fileData, decryptor, CryptoStreamMode.Read))
{
cryptoStream.CopyTo(outputStream);
}
}
}
示例14: AddFile
/// <summary>
/// Adds a <see cref="IFile"/> to the current <see cref="IDirectory"/>.
/// </summary>
public void AddFile(IFile file)
{
if (_files.Contains(file)) return;
file.Directory = this;
_files.Add(file);
}
示例15: Read
public PackageDescriptor Read(IFile filePath)
{
if (!filePath.Exists)
return null;
IOException ioException = null;
int tries = 0;
while (tries < FILE_READ_RETRIES)
{
try
{
using (var fileStream = filePath.OpenRead())
{
var descriptor = Read(fileStream);
if (descriptor.Name == null)
descriptor.Name = PackageNameUtility.GetName(filePath.NameWithoutExtension);
return descriptor;
}
}
catch (IOException ex)
{
ioException = ex;
tries++;
Thread.Sleep(FILE_READ_RETRIES_WAIT);
continue;
}
}
throw ioException;
}