当前位置: 首页>>代码示例>>C#>>正文


C# FileSystem.ReadStringFromFile方法代码示例

本文整理汇总了C#中FileSystem.ReadStringFromFile方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystem.ReadStringFromFile方法的具体用法?C# FileSystem.ReadStringFromFile怎么用?C# FileSystem.ReadStringFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileSystem的用法示例。


在下文中一共展示了FileSystem.ReadStringFromFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
        }
开发者ID:modulexcite,项目名称:ripple,代码行数:32,代码来源:CheckObjectBlockPersistence.cs

示例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);
            }

        }
开发者ID:phillip-haydon,项目名称:marten,代码行数:27,代码来源:AsyncDaemonFixture.cs

示例3: 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);
        }
开发者ID:nosami,项目名称:FubuCsProjFile,代码行数:12,代码来源:CopyFileToProject.cs

示例4: readSpecs

        private IDictionary<string, EmbeddedSpec> readSpecs()
        {
            var dict = new Dictionary<string, EmbeddedSpec>();

            var fileSystem = new FileSystem();
            fileSystem.FindFiles(_settings.Root, FileSet.Deep("*.specs.json")).Each(file =>
            {
                var json = fileSystem.ReadStringFromFile(file);
                var response = JsonSerialization.Deserialize<BatchRunResponse>(json);
                var fixtures = new Dictionary<string, FixtureModel>();
                response.fixtures.Each(x => fixtures.Add(x.key, x));

                response.records.Each(rec => dict.Add(rec.specification.path, new EmbeddedSpec(fixtures, rec)));
            });

            return dict;
        }
开发者ID:storyteller,项目名称:Storyteller,代码行数:17,代码来源:EmbeddedSpecData.cs

示例5: 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);
        }
开发者ID:mmoore99,项目名称:fubumvc,代码行数:39,代码来源:SolutionFileServiceTester.cs

示例6: writeNode

        private void writeNode(ISpecNode node)
        {
            var tag = _builder.BuildInPlaceHierarchyFor(node);

            _document.Add(tag);
            _document.Add("hr");

            _requirements.WriteAssetsInto(_document, node.AllSpecifications);

            var fileSystem = new FileSystem();
            node.AllSpecifications.SelectMany(x => x.HtmlFiles).Each(file =>
            {
                var html = fileSystem.ReadStringFromFile(file.FullPath);
                _document.Add("div").Text(html).Encoded(false);
            });
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:16,代码来源:JasminePages.cs

示例7: GetMode

        public string GetMode()
        {
            var system = new FileSystem();
            var file = filename();
            if (system.FileExists(file))
            {
                return (system.ReadStringFromFile(file) ?? "").Trim();
            }

            return string.Empty;
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:11,代码来源:FubuMode.cs


注:本文中的FileSystem.ReadStringFromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。