当前位置: 首页>>代码示例>>C#>>正文


C# ProtoWriter.Close方法代码示例

本文整理汇总了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();
        }
    }
开发者ID:wpszz,项目名称:CSLightForUnity,代码行数:14,代码来源:CSLightMng_ProtoBuf.cs

示例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); }
 }
开发者ID:AugustoAngeletti,项目名称:blockspaces,代码行数:23,代码来源:ProtoReader.cs

示例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);
     }
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:23,代码来源:ProtoReader.cs


注:本文中的ProtoBuf.ProtoWriter.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。