public static void AppendExtensionData(IExtensible instance, ProtoWriter writer) { if (instance == null) { throw new ArgumentNullException("instance"); } if (writer == null) { throw new ArgumentNullException("writer"); } if (writer.wireType != ProtoBuf.WireType.None) { throw ProtoWriter.CreateException(writer); } IExtension extensionObject = instance.GetExtensionObject(false); if (extensionObject != null) { Stream stream = extensionObject.BeginQuery(); try { ProtoWriter.CopyRawFromStream(stream, writer); } finally { extensionObject.EndQuery(stream); } } }