internal static void AppendExtendValue(TypeModel model, IExtensible instance, int tag, DataFormat format, object value) { #if FEAT_IKVM throw new NotSupportedException(); #else if (instance == null) { throw new ArgumentNullException("instance"); } if (value == null) { throw new ArgumentNullException("value"); } // TODO //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); } #endif }