當前位置: 首頁>>代碼示例>>C#>>正文


C# FileSystem.LoadFromFile方法代碼示例

本文整理匯總了C#中System.IO.FileSystem.LoadFromFile方法的典型用法代碼示例。如果您正苦於以下問題:C# FileSystem.LoadFromFile方法的具體用法?C# FileSystem.LoadFromFile怎麽用?C# FileSystem.LoadFromFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.FileSystem的用法示例。


在下文中一共展示了FileSystem.LoadFromFile方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: should_thrown_when_file_is_not_xml

        public void should_thrown_when_file_is_not_xml()
        {
            var fileSystem = new FileSystem();
            var fileName = Path.GetTempFileName();
            fileSystem.WriteStringToFile(fileName, "not xml!");

            typeof(ApplicationException).ShouldBeThrownBy(() => fileSystem.LoadFromFile<SerializeMe>(fileName));
        }
開發者ID:bobpace,項目名稱:fubucore,代碼行數:8,代碼來源:FilesSystem_load_from_file.cs

示例2: should_return_empty_instance_when_file_does_not_exist

        public void should_return_empty_instance_when_file_does_not_exist()
        {
            var fileSystem = new FileSystem();
            const string fileName = "does not exist";

            var result = fileSystem.LoadFromFile<SerializeMe>(fileName);

            result.Name.ShouldBeNull();
            result.Index.ShouldEqual(0);
        }
開發者ID:bobpace,項目名稱:fubucore,代碼行數:10,代碼來源:FilesSystem_load_from_file.cs

示例3: should_deserialize_xml

        public void should_deserialize_xml()
        {
            var fileSystem = new FileSystem();
            var fileName = Path.GetTempFileName();
            fileSystem.WriteStringToFile(fileName, SerializeMe.SerializedXml);

            var result = fileSystem.LoadFromFile<SerializeMe>(fileName);

            result.Name.ShouldEqual("Serialized Name");
            result.Index.ShouldEqual(42);
        }
開發者ID:bobpace,項目名稱:fubucore,代碼行數:11,代碼來源:FilesSystem_load_from_file.cs

示例4: LoadForFolder

        public static Project LoadForFolder(string folder)
        {
            var system = new FileSystem();
            var file = folder.AppendPath(FILE);

            var project = system.FileExists(file) ? system.LoadFromFile<Project>(file) : new Project();

            project.ProjectPath = folder;

            return project;
        }
開發者ID:storyteller,項目名稱:Storyteller,代碼行數:11,代碼來源:Project.cs

示例5: LoadResults

        public ResultHistory LoadResults(string directory)
        {
            var history = new ResultHistory();
            var system = new FileSystem();
            system.GetFiles(directory, "stresult").Each(f =>
            {
                var result = system.LoadFromFile<TestResult>(f);
                history[result.Locator] = result;
            });

            return history;
        }
開發者ID:adymitruk,項目名稱:storyteller,代碼行數:12,代碼來源:ResultPersistor.cs

示例6: save_and_load_an_object_to_xml

        public void save_and_load_an_object_to_xml()
        {
            var object1 = new BigObject
            {
                Name = "Max",
                Age = 5
            };
            var system = new FileSystem();
            system.PersistToFile(object1, "bigobject.xml");

            var object2 = system.LoadFromFile<BigObject>("bigobject.xml");

            object1.ShouldNotBeTheSameAs(object2);
            object1.ShouldEqual(object2);
        }
開發者ID:adymitruk,項目名稱:storyteller,代碼行數:15,代碼來源:FileSystemTester.cs

示例7: LoadForFolder

        public static Project LoadForFolder(string folder)
        {
            var system = new FileSystem();
            var file = folder.AppendPath(FILE);

            if (system.FileExists(file))
            {
                return system.LoadFromFile<Project>(file);
            }

            return new Project();
        }
開發者ID:jamesmanning,項目名稱:Storyteller,代碼行數:12,代碼來源:Project.cs


注:本文中的System.IO.FileSystem.LoadFromFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。