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(); }
public async Task DisposesTemporaryLoadOrder( string path, bool directExe, IEnumerable <IModListingGetter> loadOrder, ITempFile tempFile, CancellationToken cancel, ExecuteOpenForSettings sut) { sut.LoadOrderProvider.Get(default !).ReturnsForAnyArgs(tempFile);
private static void WriteSampleDataTo(ITempFile tempFile) { var random = new Random(); var sampleData = Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = DateTime.Now.AddDays(index), TemperatureC = random.Next(-20, 55), Summary = Strings[random.Next(Strings.Length)] }); var json = JsonConvert.SerializeObject(sampleData); tempFile.WriteAllText(json, Encoding.UTF8); }
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); } }
public static bool IsTempFile(this ITempFile file) => file.IsTemporary;
private static void CreateTemporaryFileWithExtension(ITempStorage tempStorage) { using ITempFile tempFile = tempStorage.NewTempFile("txt"); tempFile.WriteAllText("some file content"); }
private static void CreateTemporaryFile(ITempStorage tempStorage) { using ITempFile tempFile = tempStorage.NewTempFile(); tempFile.WriteAllBytes(new byte[] { 0x2a }); }
private static WeatherForecast[] ReadSampleDataFrom(ITempFile tempFile) { var json = tempFile.ReadAllText(Encoding.UTF8); return(JsonConvert.DeserializeObject <WeatherForecast[]>(json)); }
public void TempFileIsNotDisposed( ITempFile tempFile, IEnumerable <IModListingGetter> loadOrder, TemporaryLoadOrderProvider sut) { sut.TempFileProvider.Create(default).ReturnsForAnyArgs(tempFile);
public BuildResult(ITempFile zip, Action compled) { Zip = zip; _compled = compled; }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); ADConfigurationObject config = null; string parameterSetName; if ((parameterSetName = base.ParameterSetName) != null) { if (parameterSetName == "UploadDialPlanPrompts" || parameterSetName == "UploadDialPlanPromptsStream") { config = this.DataObject; goto IL_7D; } if (parameterSetName == "UploadAutoAttendantPrompts" || parameterSetName == "UploadAutoAttendantPromptsStream") { config = base.AutoAttendant; goto IL_7D; } } ExAssert.RetailAssert(false, "Invalid parameter set {0}", new object[] { base.ParameterSetName }); try { IL_7D: ITempFile tempFile = null; string extension = Path.GetExtension(this.PromptFileName); if (string.Equals(extension, ".wav", StringComparison.OrdinalIgnoreCase)) { tempFile = TempFileFactory.CreateTempWavFile(); } else { if (!string.Equals(extension, ".wma", StringComparison.OrdinalIgnoreCase)) { throw new InvalidFileNameException(128); } tempFile = TempFileFactory.CreateTempWmaFile(); } using (tempFile) { using (FileStream fileStream = new FileStream(tempFile.FilePath, FileMode.Create, FileAccess.Write)) { if (this.PromptFileData != null) { fileStream.Write(this.PromptFileData, 0, this.PromptFileData.Length); } else { CommonUtil.CopyStream(this.PromptFileStream, fileStream); } } using (IPublishingSession publishingSession = PublishingPoint.GetPublishingSession(Environment.UserName, config)) { publishingSession.Upload(tempFile.FilePath, this.PromptFileName); } } } catch (UnsupportedCustomGreetingSizeFormatException) { this.HandleOversizeAudioData(); } catch (LocalizedException exception) { base.WriteError(exception, (ErrorCategory)1000, null); } catch (SystemException ex) { if (!this.HandleException(ex)) { throw; } base.WriteError(ex, (ErrorCategory)1000, null); } TaskLogger.LogExit(); }
public TempPackager(ITempFile tempFile) { _tempFile = tempFile; }