本文整理汇总了C#中IEncoder.Encode方法的典型用法代码示例。如果您正苦于以下问题:C# IEncoder.Encode方法的具体用法?C# IEncoder.Encode怎么用?C# IEncoder.Encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEncoder
的用法示例。
在下文中一共展示了IEncoder.Encode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteAsset
public virtual void WriteAsset(Bundle bundle, IEncoder encoder)
{
response.ContentType = bundle.ContentType;
CacheLongTime(bundle.Hash.ToHexString(), bundle.BrowserTtl);
using (var stream = bundle.Content)
{
stream.CopyTo(response.OutputStream);
}
encoder.Encode(response);
}
示例2: Encode
/// <summary>
/// Encode this histogram into a <see cref="ByteBuffer"/>
/// </summary>
/// <param name="targetBuffer">The buffer to encode into</param>
/// <param name="encoder">The encoder to use</param>
/// <returns>The number of bytes written to the buffer</returns>
public int Encode(ByteBuffer targetBuffer, IEncoder encoder)
{
var data = GetData();
return encoder.Encode(data, targetBuffer);
}
示例3: Write
/// <summary>
/// Writes the header to the specified encoder.
/// </summary>
/// <param name="encoder">The encoder.</param>
public void Write(IEncoder encoder)
{
if (encoder == null)
{
throw new ArgumentNullException("encoder");
}
encoder.EncodeFixed(Magic);
encoder.EncodeMapChunk(this.metadata.Count);
foreach (var pair in this.metadata)
{
encoder.Encode(pair.Key);
encoder.Encode(pair.Value);
}
if (this.metadata.Count != 0)
{
encoder.EncodeMapChunk(0);
}
encoder.EncodeFixed(this.syncMarker);
}
示例4: Serialize
public string Serialize(License license, IEncoder encoder)
{
byte[] buffer;
using (MemoryStream stream = new MemoryStream())
{
WriteLicenseToStream(license, stream);
buffer = stream.ToArray();
}
return Base32Encoder.Encode(encoder.Encode(buffer));
}
示例5: GetEncodedContents
/// <summary>
/// Get the contents, encoded for shipping via SMTP
/// </summary>
/// <param name="encoder">The encoder to encode the contents</param>
/// <returns>returns the encoded string, ready for SMTP transfer</returns>
internal virtual String GetEncodedContents(IEncoder encoder)
{
StringBuilder sb=new StringBuilder();
System.Text.Encoding charset=null;
if (_charset==null)
{
charset=System.Text.Encoding.UTF8;
}
else
{
charset=this._charset;
}
if (_contents!=null)
{
encoder.Encode(new StringReader(_contents), new StringWriter(sb), charset);
}
else if (_fileinfo!=null)
{
encoder.Encode(_fileinfo.OpenRead(), new StringWriter(sb), charset);
}
else if (_contentbytes!=null)
{
encoder.Encode(new BinaryReader(new MemoryStream(_contentbytes)), new StringWriter(sb));
}
String encodedcontents=sb.ToString();
if (encodedcontents.Length!=0 && encodedcontents[encodedcontents.Length-1]!='\n')
{
return encodedcontents+SmtpProxy.ENDOFLINE+SmtpProxy.ENDOFLINE;
}
else
{
return encodedcontents+SmtpProxy.ENDOFLINE;
}
}