public ZlibOutputStreamIs(IO.Stream st, int compressLevel, EDeflateCompressStrategy strat, bool leaveOpen) : base(st, compressLevel, strat, leaveOpen) { deflater = new Deflater(compressLevel); setStrat(strat); ost = new DeflaterOutputStream(st, deflater); ost.IsStreamOwner = !leaveOpen; }
/// <summary> /// Serialize value. /// </summary> /// <param name="stream">Data stream.</param> /// <param name="type">Type of value.</param> /// <param name="value">Value to serialize.</param> protected override void SerializeValue(IO.Stream stream, Type type, object value) { if (typeof(IEntity).IsAssignableFrom(type)) { base.SerializeValue(stream, typeof(Guid), ((IEntity)value).Index); return; } base.SerializeValue(stream, type, value); }
public override void WriteToStream( Type type, object value, IO.Stream stream, Net.Http.HttpContent content ) { base.WriteToStream(type, value, stream, content); }
public override object ReadFromStream( Type type, IO.Stream stream, Net.Http.HttpContent content, IFormatterLogger formatterLogger ) { return(base.ReadFromStream(type, stream, content, formatterLogger)); }
/// <summary> /// Get the string of the specified Resource in the assembly /// </summary> /// <param name="assembly"></param> /// <param name="name"></param> /// <param name="encoding"></param> /// <returns></returns> static public string GetManifestResourceString(this Assembly assembly, Encoding encoding, params string[] name) { IO.Stream stream = assembly.GetManifestResourceStream(name); if (stream != null) { using (IO.StreamReader reader = new IO.StreamReader(stream, encoding, true, 2048)) return(reader.ReadToEnd()); } return(null); }
private async Task UploadFilePartAsync(IO.Stream stream, JObject data, CancellationToken cancellationToken) { using (var uploadClient = new HttpClient(new HttpClientHandler { UseCookies = false })) { var request = new HttpRequestMessage(HttpMethod.Put, data.Value <string>("url")) { Content = new StreamContent(stream) }; request.Headers.Add("Authorization", data.Value <string>("authorization")); request.Headers.Add("x-amz-date", data.Value <string>("date")); var response = await uploadClient.SendAsync(request, cancellationToken); response.EnsureSuccessStatusCode(); } }
private async Task UploadFilePartAsync(IO.Stream stream, ResourcePart part, CancellationToken cancellationToken) { using (var uploadClient = new HttpClient(new HttpClientHandler { UseCookies = false })) { var request = new HttpRequestMessage(HttpMethod.Put, part.Url) { Content = new StreamContent(stream) }; request.Headers.Add("Authorization", part.Authorization); request.Headers.Add("x-amz-date", part.Date); var response = await uploadClient.SendAsync(request, cancellationToken); response.EnsureSuccessStatusCode(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testOneDictionary() throws Exception public virtual void testOneDictionary() { string toTest = "hu_HU.zip"; for (int i = 0; i < tests.Length; i++) { if (tests[i].Equals(toTest)) { File f = new File(DICTIONARY_HOME, tests[i]); Debug.Assert(f.exists()); using (ZipFile zip = new ZipFile(f, StandardCharsets.UTF_8)) { ZipEntry dicEntry = zip.getEntry(tests[i + 1]); Debug.Assert(dicEntry != null); ZipEntry affEntry = zip.getEntry(tests[i + 2]); Debug.Assert(affEntry != null); using (System.IO.Stream dictionary = zip.getInputStream(dicEntry), System.IO.Stream affix = zip.getInputStream(affEntry)) { new Dictionary(affix, dictionary); } } } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void test() throws Exception public virtual void test() { for (int i = 0; i < tests.Length; i += 3) { File f = new File(DICTIONARY_HOME, tests[i]); Debug.Assert(f.exists()); using (ZipFile zip = new ZipFile(f, StandardCharsets.UTF_8)) { ZipEntry dicEntry = zip.getEntry(tests[i + 1]); Debug.Assert(dicEntry != null); ZipEntry affEntry = zip.getEntry(tests[i + 2]); Debug.Assert(affEntry != null); using (System.IO.Stream dictionary = zip.getInputStream(dicEntry), System.IO.Stream affix = zip.getInputStream(affEntry)) { Dictionary dic = new Dictionary(affix, dictionary); Console.WriteLine(tests[i] + "\t" + RamUsageEstimator.humanSizeOf(dic) + "\t(" + "words=" + RamUsageEstimator.humanSizeOf(dic.words) + ", " + "flags=" + RamUsageEstimator.humanSizeOf(dic.flagLookup) + ", " + "strips=" + RamUsageEstimator.humanSizeOf(dic.stripData) + ", " + "conditions=" + RamUsageEstimator.humanSizeOf(dic.patterns) + ", " + "affixData=" + RamUsageEstimator.humanSizeOf(dic.affixData) + ", " + "prefixes=" + RamUsageEstimator.humanSizeOf(dic.prefixes) + ", " + "suffixes=" + RamUsageEstimator.humanSizeOf(dic.suffixes) + ")"); } } } }
/// <summary> /// Calculate the CRC for the specified <see cref="System.IO.Stream"/>. /// </summary> /// <param name="stream">The input to calculate the CRC for.</param> /// <returns>CRC of <paramref name="stream"/>.</returns> public static ulong CalculateCRC(IO.Stream stream) => BitConverter.ToUInt64(new Sims3PackCRC().ComputeHash(stream), 0);
/// <summary> /// Serialize and write the byte array provided in the constructor to an HTTP /// content to a stream as an asynchronous operation. /// </summary> /// <param name="stream">The target stream.</param> /// <param name="context">Information about the transport (channel binding token, for example). This /// parameter may be null.</param> /// <returns> /// The task object representing the asynchronous operation. /// </returns> protected override Threading.Tasks.Task SerializeToStreamAsync(IO.Stream stream, TransportContext context) { return(m_buffer.CopyToAsync(stream)); }