本文整理汇总了C#中IFileSystem.ReadFileAsText方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.ReadFileAsText方法的具体用法?C# IFileSystem.ReadFileAsText怎么用?C# IFileSystem.ReadFileAsText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem.ReadFileAsText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public static ServiceDefinition Load(string path, IFileSystem fileSystem)
{
if (fileSystem == null)
{
throw new ArgumentNullException("fileSystem");
}
return SwaggerParser.Parse(fileSystem.ReadFileAsText(path));
}
示例2: Compile
private static async Task<CompilationResult> Compile(IFileSystem fileSystem)
{
var compiler = new CSharpCompiler(
fileSystem.GetFiles("GeneratedCode", "*.cs", SearchOption.AllDirectories)
.Select(each => new KeyValuePair<string, string>(each, fileSystem.ReadFileAsText(each))).ToArray(),
ManagedAssets.FrameworkAssemblies.Concat(
AppDomain.CurrentDomain.GetAssemblies()
.Where(each => !each.IsDynamic && !string.IsNullOrEmpty(each.Location))
.Select(each => each.Location)
.Concat(new[]
{
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"Microsoft.Rest.ClientRuntime.dll"),
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"Microsoft.Rest.ClientRuntime.Azure.dll")
})
));
return await compiler.Compile(Microsoft.Rest.CSharp.Compiler.Compilation.OutputKind.DynamicallyLinkedLibrary);
}
示例3: Compile
protected async Task<CompilationResult> Compile(IFileSystem fileSystem)
{
var compiler = new CSharpCompiler(
fileSystem.GetFiles("GeneratedCode", "*.cs", SearchOption.AllDirectories)
.Select(each => new KeyValuePair<string, string>(each, fileSystem.ReadFileAsText(each))).ToArray(),
ManagedAssets.FrameworkAssemblies.Concat(
AppDomain.CurrentDomain.GetAssemblies()
.Where(each => !each.IsDynamic && !string.IsNullOrEmpty(each.Location) )
.Select(each => each.Location)
.Concat(new[]
{
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"Microsoft.Rest.ClientRuntime.dll"),
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"Microsoft.Rest.ClientRuntime.Azure.dll")
})
));
var result = await compiler.Compile(OutputKind.DynamicallyLinkedLibrary);
// if it failed compiling and we're in an interactive session
if (!result.Succeeded && System.Environment.OSVersion.Platform == PlatformID.Win32NT && System.Environment.UserInteractive)
{
var error = result.Messages.FirstOrDefault(each => each.Severity == DiagnosticSeverity.Error);
if (error != null)
{
// use this to dump the files to disk for examination
// open in Favorite Code Editor
InspectWithFavoriteCodeEditor(fileSystem.SaveFilesToTemp(GetType().Name), error.Location.GetMappedLineSpan());
}
}
return result;
}