示例#1
0
        private static void CreateTemporaryDirectory(ITempStorage tempStorage)
        {
            using ITempDirectory tempDir = tempStorage.NewTempDirectory();

            using ITempFile tempFile = tempDir.NewTempFile();
            tempFile.WriteAllText("some file content");

            using ITempDirectory subDir = tempDir.NewTempDirectory();
        }
示例#2
0
        private static void TempFileConvenienceMethods(ITempStorage tempStorage)
        {
            using ITempFile tempFile = tempStorage.NewTempFile();

            // text content
            tempFile.WriteAllText("some file content", Encoding.UTF8);
            string contents = tempFile.ReadAllText(Encoding.UTF8);

            // binary content
            byte[] bytes = tempFile.ReadAllBytes();
            tempFile.WriteAllBytes(bytes);

            // streams
            using (FileStream stream = tempFile.OpenRead())
            {
                stream.Read(bytes);
            }

            using (FileStream stream = tempFile.OpenWrite())
            {
                stream.Write(bytes);
            }
        }
示例#3
0
 private static void CreateTemporaryFileWithExtension(ITempStorage tempStorage)
 {
     using ITempFile tempFile = tempStorage.NewTempFile("txt");
     tempFile.WriteAllText("some file content");
 }
示例#4
0
 private static void CreateTemporaryFile(ITempStorage tempStorage)
 {
     using ITempFile tempFile = tempStorage.NewTempFile();
     tempFile.WriteAllBytes(new byte[] { 0x2a });
 }
示例#5
0
 public WeatherForecastController(ITempStorage tempStorage)
 {
     this.tempStorage = tempStorage;
 }
示例#6
0
 public CoursesController(IUniversityService universityService,
                          ITempStorage <EditCourseForm> editFormStorage)
 {
     _universityService = universityService;
     _editFormStorage   = editFormStorage;
 }