本文整理汇总了C#中FileSystem.WriteStringToFile方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystem.WriteStringToFile方法的具体用法?C# FileSystem.WriteStringToFile怎么用?C# FileSystem.WriteStringToFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem.WriteStringToFile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: can_read_and_write_the_packages_config
public void can_read_and_write_the_packages_config()
{
var theFileSystem = new FileSystem();
theFileSystem.WriteStringToFile(NuGetDependencyStrategy.PackagesConfig, "<?xml version=\"1.0\" encoding=\"utf-8\"?><packages></packages>");
var theSolution = new Solution();
theSolution.AddDependency(new Dependency("Bottles", "1.0.1.1"));
theSolution.AddDependency(new Dependency("FubuCore", "1.2.0.1"));
var theProject = new Project("Test.csproj");
theProject.AddDependency("Bottles");
theProject.AddDependency("FubuCore");
theSolution.AddProject(theProject);
var theStrategy = new NuGetDependencyStrategy();
theStrategy.Write(theProject);
theStrategy
.Read(theProject)
.ShouldHaveTheSameElementsAs(
new Dependency("Bottles", "1.0.1.1"),
new Dependency("FubuCore", "1.2.0.1")
);
theFileSystem.DeleteFile(NuGetDependencyStrategy.PackagesConfig);
}
示例2: RenameClasses
public void RenameClasses()
{
var folder = ".".ToFullPath().ParentDirectory().ParentDirectory()
.AppendPath("CodeTracker");
var fileSystem = new FileSystem();
var files = fileSystem.FindFiles(folder, FileSet.Shallow("*.json"));
foreach (var file in files)
{
var json = fileSystem.ReadStringFromFile(file);
json = replace(json, "GithubProject");
json = replace(json, "Timestamped[]");
json = replace(json, "ProjectStarted");
json = replace(json, "IssueCreated");
json = replace(json, "IssueClosed");
json = replace(json, "IssueReopened");
json = replace(json, "Commit");
fileSystem.WriteStringToFile(file, json);
}
}
示例3: generate_visualizers
public void generate_visualizers()
{
var path = @"C:\code\diagnostics\src\FubuMVC.Diagnostics\Visualization\Visualizers\ConfigurationActions";
var types = typeof (FubuRequest).Assembly.GetExportedTypes()
.Where(x => x.IsConcreteTypeOf<IConfigurationAction>());
var fileSystem = new FileSystem();
types.Each(x =>
{
var writer = new StringWriter();
/*
<use master="" />
<viewdata model="FubuMVC.Diagnostics.Visualization.BehaviorNodeViewModel" />
*/
writer.WriteLine("<use master=\"\" />");
writer.WriteLine("<viewdata model=\"{0}\" />", x.FullName);
var file = path.AppendPath(x.Name + ".spark");
fileSystem.WriteStringToFile(file, writer.ToString());
});
}
示例4: ForSolution
public static PersistenceExpression<Solution> ForSolution(Solution target)
{
var file = "{0}-{1}.config".ToFormat(typeof(Solution).Name, Guid.NewGuid());
var fileSystem = new FileSystem();
if (fileSystem.FileExists(file))
{
fileSystem.DeleteFile(file);
}
var writer = ObjectBlockWriter.Basic(new RippleBlockRegistry());
var contents = writer.Write(target);
Debug.WriteLine(contents);
fileSystem.WriteStringToFile(file, contents);
var reader = SolutionLoader.Reader();
var specification = new PersistenceSpecification<Solution>(x =>
{
var fileContents = fileSystem.ReadStringFromFile(file);
var readValue = Solution.Empty();
reader.Read(readValue, fileContents);
fileSystem.DeleteFile(file);
return readValue;
});
specification.Original = target;
return new PersistenceExpression<Solution>(specification);
}
示例5: SetUp
public void SetUp()
{
var system = new FileSystem();
system.WriteStringToFile("a.txt", "something");
system.WriteStringToFile("b.txt", "else");
system.WriteStringToFile("c.txt", "altogether");
theWatcher = new FileChangePollingWatcher();
action1 = MockRepository.GenerateMock<System.Action>();
action2 = MockRepository.GenerateMock<System.Action>();
action3 = MockRepository.GenerateMock<System.Action>();
theWatcher.WatchFile("a.txt", action1);
theWatcher.WatchFile("b.txt", action2);
theWatcher.WatchFile("c.txt", action3);
}
示例6: DownloadTo
public INugetFile DownloadTo(Solution solution, string directory)
{
var files = new FileSystem();
files.CreateDirectory(directory);
var fileName = "{0}.{1}.nupkg".ToFormat(Name, Version);
files.WriteStringToFile(fileName, "");
return new StubNugetFile(new Dependency(Name, Version.ToString())) { FileName = fileName};
}
示例7: Alter
public void Alter(CsProjFile file, ProjectPlan plan)
{
var fileSystem = new FileSystem();
var rawText = fileSystem.ReadStringFromFile(_source);
var templatedText = plan.
ApplySubstitutions(rawText, _relativePath);
var expectedPath = file.ProjectDirectory.AppendPath(_relativePath);
fileSystem.WriteStringToFile(expectedPath, templatedText);
}
示例8: ExplodeTo
public IPackage ExplodeTo(string directory)
{
var explodedDirectory = directory.AppendPath(Name).ToFullPath();
RippleLog.Info("Exploding to " + explodedDirectory);
var fileSystem = new FileSystem();
fileSystem.CreateDirectory(explodedDirectory);
fileSystem.CleanDirectory(explodedDirectory);
fileSystem.DeleteFile(FileName);
fileSystem.WriteStringToFile(explodedDirectory.AppendPath(FileName), "");
return new StubPackage(Name, Version.ToString());
}
示例9: Check
public void Check(IPackageLog log)
{
var file = _folder.AppendPath(TracerFile);
try
{
var system = new FileSystem();
system.WriteStringToFile(file, "just a test of whether or not a process can write to a folder");
system.DeleteFile(file);
log.Trace(SuccessMessage.ToFormat(_folder));
}
catch (Exception)
{
log.MarkFailure(FailureMessage.ToFormat(_folder));
}
}
示例10: SetMode
public void SetMode(string mode)
{
var fileSystem = new FileSystem();
string file = filename();
if (mode.IsEmpty())
{
fileSystem.DeleteFile(file);
}
else
{
fileSystem.WriteStringToFile(file, mode);
}
}
示例11: SetUp
public void SetUp()
{
var context = TemplatePlan.CreateClean("assembly-info");
context.Add(new CreateSolution("AssemblyInfoSolution"));
var project = new ProjectPlan("MyProject");
context.Add(project);
var system = new FileSystem();
system.CreateDirectory("assembly-info");
system.CreateDirectory("assembly-info", "src");
system.CreateDirectory("assembly-info", "src", "MyProject");
system.CreateDirectory("assembly-info", "src", "MyProject", "Properties");
var expectedPath = "assembly-info".AppendPath("src", "MyProject", "Properties", "AssemblyInfo.cs");
system.WriteStringToFile(expectedPath, @"using System.Reflection;
[assembly: AssemblyTitle('MyProject')]
".Replace("'", "\""));
var alteration = new AssemblyInfoAlteration("using System.Reflection;", "[assembly: AssemblyTitle(\"%ASSEMBLYNAME%\")]", "using FubuMVC.Core;", "[assembly: FubuModule]");
project.Add(alteration);
context.Execute();
theProject = CsProjFile.LoadFrom("assembly-info".AppendPath("src", "MyProject", "MyProject.csproj"));
theContents =
new FileSystem().ReadStringFromFile(expectedPath);
}