/// <inheritdoc /> public virtual Task <HttpResponseMessage> UploadStreamPart(StreamPart stream) { var arguments = new object[] { stream }; var func = requestBuilder.BuildRestResultFuncForMethod("UploadStreamPart", new Type[] { typeof(StreamPart) }); return((Task <HttpResponseMessage>)func(Client, arguments)); }
public async Task <Job> UploadPhotoAsync(string jobId, MediaFile file) { var streamPart = new StreamPart(file.GetStream(), "photo.jpg", "image/jpeg"); var updatedJob = await api.UploadPhoto(jobId, streamPart, Constants.ApiManagementKey); return(updatedJob); }
/// <summary> /// Splits the specified stream into stream parts. /// </summary> /// <param name="stream">The stream.</param> public void Split(Stream stream) { foreach (var streamPart in StreamPart.Create(stream)) { this.OnStreamPartAvailable(streamPart); } }
private void Read(StreamPart streamPart) { streamPart.Stream.Position = streamPart.Position; using (BinaryReader reader = IOTools.OpenReadFile(streamPart.Stream, IsLittleEndian)) { int tempsize = 0; byte[] imageData; header = ReadHeader(reader.ReadBytes(0x40)); ImageFormat = TMXHelper.PS2ToAux(header.PixelFormat); PaletteFormat = TMXHelper.PS2ToAux(header.PaletteFormat); tempsize += 0x40; System.Drawing.Color[] colors = null; if (header.PaletteCount == 1) { tempsize += TMXHelper.ReadPalette(reader, header.PixelFormat, header.PaletteFormat, out colors); } int datasize = header.Height * ImageHelper.GetStride(ImageFormat, header.Width); imageData = reader.ReadBytes(datasize); tempsize += datasize; if (header.FileSize != tempsize) { throw new Exception("TMX: filesize not equal"); } bitmap = new Bitmap(header.Width, header.Height, ImageFormat, imageData, colors); } }
private void Read(StreamPart streamFile) { streamFile.Stream.Position = streamFile.Position; using (BinaryReader reader = new BinaryReader(streamFile.Stream, Encoding.ASCII, true)) { if (reader.ReadInt32() != MagicNumber) { throw new Exception("SPD: wrong Magic Number"); } if (reader.ReadInt32() != 0x2) { } if (reader.ReadInt32() != streamFile.Size) { } if (reader.ReadInt32() != 0) { } if (reader.ReadInt32() != 0x20) { } ushort TextureCount = reader.ReadUInt16(); ushort KeyCount = reader.ReadUInt16(); int TextureKeyPosition = reader.ReadInt32(); int KeyPosition = reader.ReadInt32(); ReadTexture(streamFile, TextureKeyPosition, TextureCount); ReadKey(streamFile, KeyPosition, KeyCount); } }
public void CreateStreamPartIncreasesStreamPartsCreatedAsNew() { StreamPart.Create(); Assert.That(StreamPartStatistics.StreamPartsCreatedAsNew, Is.EqualTo(1)); Assert.That(StreamPartStatistics.StreamPartsCreatedFromDisposed, Is.EqualTo(0)); }
private async Task <BulkImportJob> ImportChunkedPeople <T>(IList <T> leads) { var csvStrings = _csvService.ToCsv(leads); var bulkImportResponse = await MarketoApiJobRetryPolicy .ExecuteAsync(async (context) => { using (var stream = GenerateStreamFromString(csvStrings)) { var streamPart = new StreamPart(stream, String.Empty, "text/csv"); var val = await _marketoBulkImportClient.PushLeads(streamPart); return(val); } } , new Context("ImportChunkedPeople") ); if (bulkImportResponse.Success == false) { throw new Exception( $"Unable to push person due to errors: {bulkImportResponse.ToString()}"); } return(bulkImportResponse.Result.Select(_bulkImportJobMapper.Map).FirstOrDefault()); }
private void Read(StreamPart streamFile, string name) { GetType(streamFile); int index = 0; streamFile.Stream.Position = streamFile.Position; using (BinaryReader reader = IOTools.OpenReadFile(streamFile.Stream, IsLittleEndian)) do { int Size = reader.ReadInt32(); if (streamFile.Position + streamFile.Size < Size + streamFile.Stream.Position) { throw new Exception("TBL error"); } byte[] tempdata = reader.ReadBytes(Size); FormatEnum fileType = GameFormatHelper.GetFormat(tempdata); string ext = Path.GetExtension(name); string tempName = name.Substring(0, name.Length - ext.Length) + "(" + index++.ToString().PadLeft(2, '0') + ")"; if (fileType == FormatEnum.Unknown) { tempName += ".DAT"; } else { tempName += "." + fileType.ToString(); } SubFiles.Add(GameFormatHelper.OpenFile(tempName, tempdata, fileType == FormatEnum.Unknown ? FormatEnum.DAT : fileType)); reader.BaseStream.Position += IOTools.Alignment(reader.BaseStream.Position - streamFile.Position, 16); } while (streamFile.Stream.Position < streamFile.Position + streamFile.Size); }
public void DisposeResultsInAnObjectDisposedException() { var streamPart = StreamPart.Create(); streamPart.Dispose(); Assert.That(() => streamPart.Value = new byte[0], Throws.Exception.TypeOf(typeof(ObjectDisposedException))); }
public void CreateStreamPartFromEmptyStream() { var stream = StreamHelper.GetStream(0); var streamParts = StreamPart.Create(stream); Assert.That(streamParts.Count(), Is.EqualTo(0)); }
public void DisposeStreamPartIncreasesStreamPartsCurrentlyDisposed() { var streamPart = StreamPart.Create(); streamPart.Dispose(); Assert.That(StreamPartStatistics.StreamPartsCurrentlyDisposed, Is.EqualTo(1)); }
public void ValueMustNotBeGreaterThanMaximumValueSize() { var streamPart = StreamPart.Create(); var tooBig = StreamPart.MaximumValueSize + 1; var input = new byte[tooBig]; Assert.That(() => streamPart.Value = input, Throws.Exception.TypeOf(typeof(ArgumentException))); }
public async Task <IEnumerable <ProductDTO> > GetRecommendedProductsFromPhotoAsync(string photoPath) { using (var photoStream = File.Open(photoPath, FileMode.Open)) { var streamPart = new StreamPart(photoStream, "photo.jpg", "image/jpeg"); return(await productsAPI.GetSimilarProductsAsync(authenticationService.AuthorizationHeader, streamPart)); } }
public async Task <Job> UploadPhotoAsync(string jobId, MediaFile file) { IPhotoServiceAPI api = GetManagedApiService <IPhotoServiceAPI>(); var streamPart = new StreamPart(file.GetStream(), "photo.jpg", "image/jpeg"); var updatedJob = await api.UploadPhoto(jobId, streamPart); return(updatedJob); }
public async Task <Photo> UploadPhotoAsync(string jobId, MediaFile file) { var restService = RestService.For <IPhotoServiceAPI>(Helpers.Constants.BaseUrl); var streamPart = new StreamPart(file.GetStream(), "photo.jpg", "image/jpeg"); var photo = await restService.UploadPhoto(jobId, streamPart, Constants.ApiManagementKey); return(photo); }
public void ValueCanOnlyBeSetOnce() { var streamPart = StreamPart.Create(); var input = new byte[] { 0, 1, 2, 3, 4 }; streamPart.Value = input; Assert.That(() => streamPart.Value = input, Throws.Exception.TypeOf(typeof(InvalidOperationException))); }
public void LengthIsZeroOnReusedStreamParts() { var streamPart = StreamPart.Create(); streamPart.Dispose(); streamPart = StreamPart.Create(); Assert.That(streamPart.Length, Is.EqualTo(0)); }
public void LengthReturnsLengthOfValue() { var streamPart = StreamPart.Create(); var input = new byte[] { 0, 1, 2 }; streamPart.Value = input; Assert.That(streamPart.Length, Is.EqualTo(3)); }
public void CreateStreamPartFromDisposedStreamPartIncreasesStreamPartsCreatedFromDisposed() { var streamPart = StreamPart.Create(); streamPart.Dispose(); StreamPart.Create(); Assert.That(StreamPartStatistics.StreamPartsCreatedAsNew, Is.EqualTo(1)); Assert.That(StreamPartStatistics.StreamPartsCreatedFromDisposed, Is.EqualTo(1)); }
public void ValueReturnsTheValueOriginallyStored() { var streamPart = StreamPart.Create(); var input = new byte[] { 0, 1, 2 }; streamPart.Value = input; var value = streamPart.Value; Assert.That(value, Is.EqualTo(input)); }
public Task <IEnumerable <Produto> > GetSimilarProductsAsync( [Header("Authorization")] string authorizationHeader, [AliasAs("file")] StreamPart stream) { var result = new List <Produto>(); result.Add(new Produto()); return(Task.FromResult <IEnumerable <Produto> >(result)); }
private void ReadKey(StreamPart streamFile, int pos, int count) { streamFile.Stream.Position = streamFile.Position + pos; using (BinaryReader reader = new BinaryReader(streamFile.Stream, Encoding.ASCII, true)) for (int i = 0; i < count; i++) { KeyList.Add(new SPDKey(reader)); } }
public void CreateStreamPartReusesDisposedInstances() { var streamPart1 = StreamPart.Create(); streamPart1.Dispose(); var streamPart2 = StreamPart.Create(); Assert.That(streamPart2, Is.SameAs(streamPart1)); }
public void CreateStreamPartCreatesMultipleInstances() { var streamPart1 = StreamPart.Create(); var streamPart2 = StreamPart.Create(); Assert.That(streamPart1, Is.InstanceOf(typeof(StreamPart))); Assert.That(streamPart2, Is.InstanceOf(typeof(StreamPart))); Assert.That(streamPart1, Is.Not.SameAs(streamPart2)); }
async void RecordBtn_Released(object sender, EventArgs e) { await _recorder.StopRecording(); Edit_InfoLabel(false); ConvertBtn.IsEnabled = true; PlayBtn.IsEnabled = true; _audioSource = new StreamPart(_recorder.GetAudioFileStream(), "source.wav", "audio/x-wav"); }
public void CombineReturnsARewindedStream() { const int size = SizeOf64KByte + 1; var stream = StreamHelper.GetStream(size); var streamParts = StreamPart.Create(stream); var combinedStream = StreamPart.Combine(streamParts); Assert.That(combinedStream.Position, Is.EqualTo(0)); }
public void CombineMultipleStreamParts() { const int size = SizeOf64KByte + 1; var stream = StreamHelper.GetStream(size); var streamParts = StreamPart.Create(stream); var combinedStream = StreamPart.Combine(streamParts); Assert.That(combinedStream.Length, Is.EqualTo(size)); }
public void LengthIsZeroOnReusedStreamPartsWithPreviousValue() { var streamPart = StreamPart.Create(); var input = new byte[] { 0, 1, 2 }; streamPart.Value = input; streamPart.Dispose(); streamPart = StreamPart.Create(); Assert.That(streamPart.Length, Is.EqualTo(0)); }
public void InitializeTypeEnforcesNewlyCreatedInstances() { var streamPart1 = StreamPart.Create(); streamPart1.Dispose(); StreamPart.InitializeType(); var streamPart2 = StreamPart.Create(); Assert.That(streamPart1, Is.Not.SameAs(streamPart2)); }
public void DisposeIsClearedAfterReuse() { var streamPart = StreamPart.Create(); streamPart.Dispose(); streamPart = StreamPart.Create(); streamPart.Value = new byte[0]; Assert.That(true); }