本文整理汇总了C#中ProtoBuf.ProtoWriter.Close方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoWriter.Close方法的具体用法?C# ProtoWriter.Close怎么用?C# ProtoWriter.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoBuf.ProtoWriter
的用法示例。
在下文中一共展示了ProtoWriter.Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
public void Serialize(Stream destination, object clsObj)
{
SInstance sInstance = clsObj as SInstance;
if (sInstance == null)
{
throw new ArgumentNullException("无效CSLight脚本对象: " + clsObj);
}
using (ProtoWriter writer = new ProtoWriter(destination, null, null))
{
WriteSInstance(writer, sInstance);
writer.Close();
}
}
示例2: AppendExtensionData
/// <summary>
/// Copies the current field into the instance as extension data
/// </summary>
public void AppendExtensionData(IExtensible instance)
{
if (instance == null) throw new ArgumentNullException("instance");
IExtension extn = instance.GetExtensionObject(true);
bool commit = false;
// unusually we *don't* want "using" here; the "finally" does that, with
// the extension object being responsible for disposal etc
Stream dest = extn.BeginAppend();
try
{
//TODO: replace this with stream-based, buffered raw copying
using (ProtoWriter writer = new ProtoWriter(dest, model))
{
AppendExtensionField(writer);
writer.Close();
}
commit = true;
}
finally { extn.EndAppend(dest, commit); }
}
示例3: AppendExtensionData
public void AppendExtensionData(IExtensible instance)
{
if (instance == null)
{
throw new ArgumentNullException("instance");
}
IExtension extensionObject = instance.GetExtensionObject(true);
bool commit = false;
Stream stream = extensionObject.BeginAppend();
try
{
using (ProtoWriter protoWriter = new ProtoWriter(stream, this.model, null))
{
this.AppendExtensionField(protoWriter);
protoWriter.Close();
}
commit = true;
}
finally
{
extensionObject.EndAppend(stream, commit);
}
}