本文整理汇总了C#中IDataWriter.WriteValue方法的典型用法代码示例。如果您正苦于以下问题:C# IDataWriter.WriteValue方法的具体用法?C# IDataWriter.WriteValue怎么用?C# IDataWriter.WriteValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataWriter
的用法示例。
在下文中一共展示了IDataWriter.WriteValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: using
void ISerializeExplicit.WriteData(IDataWriter writer)
{
// Write all Tile data to a compressed memory stream
byte[] compressedData;
using (MemoryStream compressedStream = new MemoryStream(1024 * 16))
{
using (GZipStream stream = new GZipStream(compressedStream, CompressionLevel.Optimal))
using (BinaryWriter streamWriter = new BinaryWriter(stream))
{
streamWriter.Write((int)this.tiles.Width);
streamWriter.Write((int)this.tiles.Height);
Tile[] rawData = this.tiles.RawData;
for (int i = 0; i < this.tiles.Capacity; i++)
{
streamWriter.Write((int)rawData[i].BaseIndex);
streamWriter.Write((short)rawData[i].DepthOffset);
streamWriter.Write((byte)rawData[i].AutoTileCon);
}
}
compressedData = compressedStream.ToArray();
}
// Transfer the compressed data to the serializer to handle it
writer.WriteValue("version", Serialize_Version_AutoTile);
writer.WriteValue("data", compressedData);
}
示例2: using
void ISerializable.WriteData(IDataWriter writer)
{
writer.WriteValue("version", ResFormat_Version_LayerPng);
using (MemoryStream str = new MemoryStream(1024 * 64))
{
this.ToBitmap().Save(str, System.Drawing.Imaging.ImageFormat.Png);
writer.WriteValue("pixelData", str.ToArray());
}
}
示例3: NotSupportedException
void ISerializeExplicit.WriteData(IDataWriter writer)
{
string formatId = ImageCodec.FormatPng;
writer.WriteValue("version", Serialize_Version_FormatId);
writer.WriteValue("formatId", formatId);
IImageCodec codec = ImageCodec.GetWrite(formatId);
if (codec == null)
{
throw new NotSupportedException(string.Format(
"Unable to retrieve image codec for format '{0}'. Can't save image data.",
formatId));
}
using (MemoryStream str = new MemoryStream(1024 * 64))
{
codec.Write(str, this, formatId);
writer.WriteValue("pixelData", str.ToArray());
}
}