本文整理汇总了C#中IFileSystem.OpenWrite方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.OpenWrite方法的具体用法?C# IFileSystem.OpenWrite怎么用?C# IFileSystem.OpenWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem.OpenWrite方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public static void Init(string workingDirectory, IFileSystem fileSystem)
{
var configFilePath = GetConfigFilePath(workingDirectory);
var config = new ConfigInitWizard().Run(Provide(workingDirectory, fileSystem), workingDirectory, fileSystem);
if (config == null) return;
using (var stream = fileSystem.OpenWrite(configFilePath))
using (var writer = new StreamWriter(stream))
{
Logger.WriteInfo("Saving config file");
ConfigSerialiser.Write(config, writer);
stream.Flush();
}
}
示例2: WriteSample
public static void WriteSample(string gitDirectory, IFileSystem fileSystem)
{
var configFilePath = GetConfigFilePath(gitDirectory);
if (!fileSystem.Exists(configFilePath))
{
using (var stream = fileSystem.OpenWrite(configFilePath))
using (var writer = new StreamWriter(stream))
{
ConfigSerialiser.WriteSample(writer);
}
}
else
{
Logger.WriteError("Cannot write sample, GitVersionConfig.yaml already exists");
}
}
示例3: WriteSample
public static void WriteSample(string targetDirectory, IFileSystem fileSystem)
{
if (fileSystem == null)
{
throw new ArgumentNullException("fileSystem");
}
var configFilePath = GetConfigFilePath(targetDirectory);
if (!fileSystem.Exists(configFilePath))
{
using (var stream = fileSystem.OpenWrite(configFilePath))
using (var writer = new StreamWriter(stream))
{
ConfigSerializer.WriteSample(writer);
}
}
else
{
Logger.WriteError("Cannot write sample, GitReleaseManager.yaml already exists");
}
}
示例4: Init
public static void Init(string workingDirectory, IFileSystem fileSystem, IConsole console)
{
var configFilePath = GetConfigFilePath(workingDirectory);
var currentConfiguration = Provide(workingDirectory, fileSystem, applyDefaults: false);
var config = new ConfigInitWizard(console, fileSystem).Run(currentConfiguration, workingDirectory);
if (config == null) return;
using (var stream = fileSystem.OpenWrite(configFilePath))
using (var writer = new StreamWriter(stream))
{
Logger.WriteInfo("Saving config file");
ConfigSerialiser.Write(config, writer);
stream.Flush();
}
}