// Token: 0x06003293 RID: 12947 RVA: 0x00127460 File Offset: 0x00125860 internal static void AppendExtendValue(TypeModel model, IExtensible instance, int tag, DataFormat format, object value) { if (instance == null) { throw new ArgumentNullException("instance"); } if (value == null) { throw new ArgumentNullException("value"); } IExtension extensionObject = instance.GetExtensionObject(true); if (extensionObject == null) { throw new InvalidOperationException("No extension object available; appended data would be lost."); } bool commit = false; Stream stream = extensionObject.BeginAppend(); try { using (ProtoWriter protoWriter = new ProtoWriter(stream, model, null)) { model.TrySerializeAuxiliaryType(protoWriter, null, format, tag, value, false); protoWriter.Close(); } commit = true; } finally { extensionObject.EndAppend(stream, commit); } }
internal static void AppendExtendValue <TValue>(TypeModel model, IExtensible instance, int tag, DataFormat format, object value) { if (instance == null) { throw new ArgumentNullException("instance"); } if (value == null) { throw new ArgumentNullException("value"); } //TODO: CheckTagNotInUse //model.CheckTagNotInUse(tag); // obtain the extension object and prepare to write IExtension extn = instance.GetExtensionObject(true); if (extn == null) { throw new InvalidOperationException("No extension object available; appended data would be lost."); } bool commit = false; Stream stream = extn.BeginAppend(); try { using (ProtoWriter writer = new ProtoWriter(stream, model, null)) { model.TrySerializeAuxiliaryType(writer, null, format, tag, value, false); writer.Close(); } commit = true; } finally { extn.EndAppend(stream, commit); } }
static public int Close(IntPtr l) { try { ProtoBuf.ProtoWriter self = (ProtoBuf.ProtoWriter)checkSelf(l); self.Close(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
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(); } }
/// <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); } }
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); } }
/// <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); } }
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); } }