本文整理汇总了C#中FileSystem.AppendStringToFile方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystem.AppendStringToFile方法的具体用法?C# FileSystem.AppendStringToFile怎么用?C# FileSystem.AppendStringToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem.AppendStringToFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: should_add_project_references
public void should_add_project_references()
{
// build it up through a stringbuilder to use the environment-specific newline
var solutionBuilder = new StringBuilder("Microsoft Visual Studio Solution File, Format Version 11.00")
.AppendLine()
.AppendLine("# Visual Studio 2010")
.AppendLine(@"Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""FubuMVC.StructureMap"", ""FubuMVC.StructureMap\FubuMVC.StructureMap.csproj"", ""{ABFEA520-820C-4B77-9015-6A09E24252FA}""")
.AppendLine("EndProject")
.AppendLine("Global")
.AppendLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution")
.AppendLine(" Debug|Any CPU = Debug|Any CPU")
.AppendLine(" Release|Any CPU = Release|Any CPU")
.AppendLine(" EndGlobalSection")
.AppendLine(" GlobalSection(SolutionProperties) = preSolution")
.AppendLine(" HideSolutionNode = FALSE")
.AppendLine(" EndGlobalSection")
.AppendLine("EndGlobal");
var system = new FileSystem();
var solutionFile = "tmp.sln";
system.AppendStringToFile(solutionFile, solutionBuilder.ToString());
var project = new CsProj
{
Name = "Test",
ProjectGuid = "123",
RelativePath = @"example1\example1.csproj"
};
var service = new SolutionFileService(system);
service.AddProject(solutionFile, project);
var solutionContents = system.ReadStringFromFile(solutionFile);
var lines = service.SplitSolution(solutionContents);
lines[4].ShouldEqual("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Test\", \"example1\\example1.csproj\", \"{123}\"");
lines[5].ShouldEqual("EndProject");
system.DeleteFile(solutionFile);
}