// Autogenerated C# message buffer code. // Source: clad/cloud/docs.clad // Full command line: victor-clad/tools/message-buffers/emitters/CSharp_emitter.py -C src -I clad/src lib/util/source/anki/clad robot/clad/src coretech/vision/clad_src coretech/common/clad_src -o generated/cladCSharp clad/cloud/docs.clad namespace Anki { namespace Vector { namespace JDocs { public partial class Doc { private ulong _docVersion; // uint_64 private ulong _fmtVersion; // uint_64 private string _metadata; // string[uint_8] private string _jsonDoc; // string[uint_32] public ulong docVersion { get { return _docVersion; } set { _docVersion = value; } } public ulong fmtVersion { get { return _fmtVersion; } set { _fmtVersion = value; } } public string metadata { get { return _metadata; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 255) { throw new System.ArgumentException("metadata string is too long. Must decode to less than or equal to 255 bytes.", "value"); } _metadata = value; } } public string jsonDoc { get { return _jsonDoc; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 4294967295) { throw new System.ArgumentException("jsonDoc string is too long. Must decode to less than or equal to 4294967295 bytes.", "value"); } _jsonDoc = value; } } /**** Constructors ****/ public Doc() { } public Doc(ulong docVersion, ulong fmtVersion, string metadata, string jsonDoc) { this.docVersion = docVersion; this.fmtVersion = fmtVersion; this.metadata = metadata; this.jsonDoc = jsonDoc; } public Doc(System.IO.Stream stream) { Unpack(stream); } public Doc(System.IO.BinaryReader reader) { Unpack(reader); } public Doc Initialize(ulong docVersion, ulong fmtVersion, string metadata, string jsonDoc) { this.docVersion = docVersion; this.fmtVersion = fmtVersion; this.metadata = metadata; this.jsonDoc = jsonDoc; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { _docVersion = reader.ReadUInt64(); _fmtVersion = reader.ReadUInt64(); int _metadata_length = (int)reader.ReadByte(); byte[] _metadata_bytes = reader.ReadBytes(_metadata_length); _metadata = System.Text.Encoding.UTF8.GetString(_metadata_bytes); int _jsonDoc_length = (int)reader.ReadUInt32(); byte[] _jsonDoc_bytes = reader.ReadBytes(_jsonDoc_length); _jsonDoc = System.Text.Encoding.UTF8.GetString(_jsonDoc_bytes); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { writer.Write((ulong)_docVersion); writer.Write((ulong)_fmtVersion); if (_metadata != null) { byte[] _metadata_bytes = System.Text.Encoding.UTF8.GetBytes(_metadata); writer.Write((byte)_metadata_bytes.Length); writer.Write(_metadata_bytes); } else { writer.Write((byte)0); } if (_jsonDoc != null) { byte[] _jsonDoc_bytes = System.Text.Encoding.UTF8.GetBytes(_jsonDoc); writer.Write((uint)_jsonDoc_bytes.Length); writer.Write(_jsonDoc_bytes); } else { writer.Write((uint)0); } } public int Size { get { int result = 0; result += 8; // uint_64 result += 8; // uint_64 result += 1; // uint_8 if (metadata != null) { result += System.Text.Encoding.UTF8.GetByteCount(metadata); } result += 4; // uint_32 if (jsonDoc != null) { result += System.Text.Encoding.UTF8.GetByteCount(jsonDoc); } return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(Doc a, Doc b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(Doc a, Doc b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as Doc); } public bool Equals(Doc p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._docVersion.Equals(p._docVersion) && this._fmtVersion.Equals(p._fmtVersion) && this._metadata.Equals(p._metadata) && this._jsonDoc.Equals(p._jsonDoc); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._docVersion.GetHashCode(); hash = hash * 23 + this._fmtVersion.GetHashCode(); return hash; } } } public partial class WriteRequest { private string _account; // string[uint_16] private string _thing; // string[uint_16] private string _docName; // string[uint_16] private Anki.Vector.JDocs.Doc _doc; // Doc public string account { get { return _account; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("account string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _account = value; } } public string thing { get { return _thing; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("thing string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _thing = value; } } public string docName { get { return _docName; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("docName string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _docName = value; } } public Anki.Vector.JDocs.Doc doc { get { return _doc; } set { if (value == null) { throw new System.ArgumentNullException("doc cannot be null.", "value"); } _doc = value; } } /**** Constructors ****/ public WriteRequest() { this.doc = new Anki.Vector.JDocs.Doc(); } public WriteRequest(string account, string thing, string docName, Anki.Vector.JDocs.Doc doc) { this.account = account; this.thing = thing; this.docName = docName; this.doc = doc; } public WriteRequest(System.IO.Stream stream) { Unpack(stream); } public WriteRequest(System.IO.BinaryReader reader) { Unpack(reader); } public WriteRequest Initialize(string account, string thing, string docName, Anki.Vector.JDocs.Doc doc) { this.account = account; this.thing = thing; this.docName = docName; this.doc = doc; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { int _account_length = (int)reader.ReadUInt16(); byte[] _account_bytes = reader.ReadBytes(_account_length); _account = System.Text.Encoding.UTF8.GetString(_account_bytes); int _thing_length = (int)reader.ReadUInt16(); byte[] _thing_bytes = reader.ReadBytes(_thing_length); _thing = System.Text.Encoding.UTF8.GetString(_thing_bytes); int _docName_length = (int)reader.ReadUInt16(); byte[] _docName_bytes = reader.ReadBytes(_docName_length); _docName = System.Text.Encoding.UTF8.GetString(_docName_bytes); _doc = new Anki.Vector.JDocs.Doc(reader); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { if (_account != null) { byte[] _account_bytes = System.Text.Encoding.UTF8.GetBytes(_account); writer.Write((ushort)_account_bytes.Length); writer.Write(_account_bytes); } else { writer.Write((ushort)0); } if (_thing != null) { byte[] _thing_bytes = System.Text.Encoding.UTF8.GetBytes(_thing); writer.Write((ushort)_thing_bytes.Length); writer.Write(_thing_bytes); } else { writer.Write((ushort)0); } if (_docName != null) { byte[] _docName_bytes = System.Text.Encoding.UTF8.GetBytes(_docName); writer.Write((ushort)_docName_bytes.Length); writer.Write(_docName_bytes); } else { writer.Write((ushort)0); } _doc.Pack(writer); } public int Size { get { int result = 0; result += 2; // uint_16 if (account != null) { result += System.Text.Encoding.UTF8.GetByteCount(account); } result += 2; // uint_16 if (thing != null) { result += System.Text.Encoding.UTF8.GetByteCount(thing); } result += 2; // uint_16 if (docName != null) { result += System.Text.Encoding.UTF8.GetByteCount(docName); } result += doc.Size; return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(WriteRequest a, WriteRequest b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(WriteRequest a, WriteRequest b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as WriteRequest); } public bool Equals(WriteRequest p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._account.Equals(p._account) && this._thing.Equals(p._thing) && this._docName.Equals(p._docName) && this._doc.Equals(p._doc); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._doc.GetHashCode(); return hash; } } } public enum DocError : byte { ErrorConnecting = 0 }; public enum WriteStatus : byte { Accepted = 0, RejectedDocVersion = 1, RejectedFmtVersion = 2, Error = 3 }; public partial class WriteResponse { private Anki.Vector.JDocs.WriteStatus _status; // WriteStatus private ulong _latestVersion; // uint_64 public Anki.Vector.JDocs.WriteStatus status { get { return _status; } set { _status = value; } } public ulong latestVersion { get { return _latestVersion; } set { _latestVersion = value; } } /**** Constructors ****/ public WriteResponse() { } public WriteResponse(Anki.Vector.JDocs.WriteStatus status, ulong latestVersion) { this.status = status; this.latestVersion = latestVersion; } public WriteResponse(System.IO.Stream stream) { Unpack(stream); } public WriteResponse(System.IO.BinaryReader reader) { Unpack(reader); } public WriteResponse Initialize(Anki.Vector.JDocs.WriteStatus status, ulong latestVersion) { this.status = status; this.latestVersion = latestVersion; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { _status = (Anki.Vector.JDocs.WriteStatus)reader.ReadByte(); _latestVersion = reader.ReadUInt64(); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { writer.Write((byte)_status); writer.Write((ulong)_latestVersion); } public int Size { get { return 9; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(WriteResponse a, WriteResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(WriteResponse a, WriteResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as WriteResponse); } public bool Equals(WriteResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._status.Equals(p._status) && this._latestVersion.Equals(p._latestVersion); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._status.GetHashCode(); hash = hash * 23 + this._latestVersion.GetHashCode(); return hash; } } } public partial class ReadItem { private string _docName; // string[uint_8] private ulong _myDocVersion; // uint_64 public string docName { get { return _docName; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 255) { throw new System.ArgumentException("docName string is too long. Must decode to less than or equal to 255 bytes.", "value"); } _docName = value; } } public ulong myDocVersion { get { return _myDocVersion; } set { _myDocVersion = value; } } /**** Constructors ****/ public ReadItem() { } public ReadItem(string docName, ulong myDocVersion) { this.docName = docName; this.myDocVersion = myDocVersion; } public ReadItem(System.IO.Stream stream) { Unpack(stream); } public ReadItem(System.IO.BinaryReader reader) { Unpack(reader); } public ReadItem Initialize(string docName, ulong myDocVersion) { this.docName = docName; this.myDocVersion = myDocVersion; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { int _docName_length = (int)reader.ReadByte(); byte[] _docName_bytes = reader.ReadBytes(_docName_length); _docName = System.Text.Encoding.UTF8.GetString(_docName_bytes); _myDocVersion = reader.ReadUInt64(); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { if (_docName != null) { byte[] _docName_bytes = System.Text.Encoding.UTF8.GetBytes(_docName); writer.Write((byte)_docName_bytes.Length); writer.Write(_docName_bytes); } else { writer.Write((byte)0); } writer.Write((ulong)_myDocVersion); } public int Size { get { int result = 0; result += 1; // uint_8 if (docName != null) { result += System.Text.Encoding.UTF8.GetByteCount(docName); } result += 8; // uint_64 return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(ReadItem a, ReadItem b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(ReadItem a, ReadItem b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as ReadItem); } public bool Equals(ReadItem p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._docName.Equals(p._docName) && this._myDocVersion.Equals(p._myDocVersion); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._myDocVersion.GetHashCode(); return hash; } } } public partial class ReadRequest { private string _account; // string[uint_16] private string _thing; // string[uint_16] private Anki.Vector.JDocs.ReadItem[] _items; // ReadItem[uint_16] public string account { get { return _account; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("account string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _account = value; } } public string thing { get { return _thing; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("thing string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _thing = value; } } public Anki.Vector.JDocs.ReadItem[] items { get { return _items; } set { if (value != null && value.Length > 65535) { throw new System.ArgumentException("items variable-length array is too long. Must be less than or equal to 65535.", "value"); } _items = value; } } /**** Constructors ****/ public ReadRequest() { } public ReadRequest(string account, string thing, Anki.Vector.JDocs.ReadItem[] items) { this.account = account; this.thing = thing; this.items = items; } public ReadRequest(System.IO.Stream stream) { Unpack(stream); } public ReadRequest(System.IO.BinaryReader reader) { Unpack(reader); } public ReadRequest Initialize(string account, string thing, Anki.Vector.JDocs.ReadItem[] items) { this.account = account; this.thing = thing; this.items = items; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { int _account_length = (int)reader.ReadUInt16(); byte[] _account_bytes = reader.ReadBytes(_account_length); _account = System.Text.Encoding.UTF8.GetString(_account_bytes); int _thing_length = (int)reader.ReadUInt16(); byte[] _thing_bytes = reader.ReadBytes(_thing_length); _thing = System.Text.Encoding.UTF8.GetString(_thing_bytes); int _items_length = (int)reader.ReadUInt16(); _items = new Anki.Vector.JDocs.ReadItem[_items_length]; for (int i = 0; i < _items_length; ++i) { _items[i] = new Anki.Vector.JDocs.ReadItem(reader); } } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { if (_account != null) { byte[] _account_bytes = System.Text.Encoding.UTF8.GetBytes(_account); writer.Write((ushort)_account_bytes.Length); writer.Write(_account_bytes); } else { writer.Write((ushort)0); } if (_thing != null) { byte[] _thing_bytes = System.Text.Encoding.UTF8.GetBytes(_thing); writer.Write((ushort)_thing_bytes.Length); writer.Write(_thing_bytes); } else { writer.Write((ushort)0); } if (_items != null) { writer.Write((ushort)_items.Length); for (int i = 0; i < _items.Length; ++i) { if (_items[i] == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } _items[i].Pack(writer); } } else { writer.Write((ushort)0); } } public int Size { get { int result = 0; result += 2; // uint_16 if (account != null) { result += System.Text.Encoding.UTF8.GetByteCount(account); } result += 2; // uint_16 if (thing != null) { result += System.Text.Encoding.UTF8.GetByteCount(thing); } result += 2; // uint_16 if (items != null) { for (int i = 0; i < items.Length; ++i) { if (items[i] == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += items[i].Size; } } return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(ReadRequest a, ReadRequest b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(ReadRequest a, ReadRequest b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as ReadRequest); } public bool Equals(ReadRequest p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._account.Equals(p._account) && this._thing.Equals(p._thing) && ArrayEquals(this._items,p._items); } public override int GetHashCode() { unchecked { int hash = 17; return hash; } } } public enum ReadStatus : byte { Unchanged = 0, Changed = 1, NotFound = 2, PermissionDenied = 3 }; public partial class ResponseDoc { private Anki.Vector.JDocs.ReadStatus _status; // ReadStatus private Anki.Vector.JDocs.Doc _doc; // Doc public Anki.Vector.JDocs.ReadStatus status { get { return _status; } set { _status = value; } } public Anki.Vector.JDocs.Doc doc { get { return _doc; } set { if (value == null) { throw new System.ArgumentNullException("doc cannot be null.", "value"); } _doc = value; } } /**** Constructors ****/ public ResponseDoc() { this.doc = new Anki.Vector.JDocs.Doc(); } public ResponseDoc(Anki.Vector.JDocs.ReadStatus status, Anki.Vector.JDocs.Doc doc) { this.status = status; this.doc = doc; } public ResponseDoc(System.IO.Stream stream) { Unpack(stream); } public ResponseDoc(System.IO.BinaryReader reader) { Unpack(reader); } public ResponseDoc Initialize(Anki.Vector.JDocs.ReadStatus status, Anki.Vector.JDocs.Doc doc) { this.status = status; this.doc = doc; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { _status = (Anki.Vector.JDocs.ReadStatus)reader.ReadByte(); _doc = new Anki.Vector.JDocs.Doc(reader); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { writer.Write((byte)_status); _doc.Pack(writer); } public int Size { get { int result = 0; result += 1; // ReadStatus result += doc.Size; return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(ResponseDoc a, ResponseDoc b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(ResponseDoc a, ResponseDoc b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as ResponseDoc); } public bool Equals(ResponseDoc p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._status.Equals(p._status) && this._doc.Equals(p._doc); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._status.GetHashCode(); hash = hash * 23 + this._doc.GetHashCode(); return hash; } } } public partial class ReadResponse { private Anki.Vector.JDocs.ResponseDoc[] _items; // ResponseDoc[uint_16] public Anki.Vector.JDocs.ResponseDoc[] items { get { return _items; } set { if (value != null && value.Length > 65535) { throw new System.ArgumentException("items variable-length array is too long. Must be less than or equal to 65535.", "value"); } _items = value; } } /**** Constructors ****/ public ReadResponse() { } public ReadResponse(Anki.Vector.JDocs.ResponseDoc[] items) { this.items = items; } public ReadResponse(System.IO.Stream stream) { Unpack(stream); } public ReadResponse(System.IO.BinaryReader reader) { Unpack(reader); } public ReadResponse Initialize(Anki.Vector.JDocs.ResponseDoc[] items) { this.items = items; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { int _items_length = (int)reader.ReadUInt16(); _items = new Anki.Vector.JDocs.ResponseDoc[_items_length]; for (int i = 0; i < _items_length; ++i) { _items[i] = new Anki.Vector.JDocs.ResponseDoc(reader); } } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { if (_items != null) { writer.Write((ushort)_items.Length); for (int i = 0; i < _items.Length; ++i) { if (_items[i] == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } _items[i].Pack(writer); } } else { writer.Write((ushort)0); } } public int Size { get { int result = 0; result += 2; // uint_16 if (items != null) { for (int i = 0; i < items.Length; ++i) { if (items[i] == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += items[i].Size; } } return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(ReadResponse a, ReadResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(ReadResponse a, ReadResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as ReadResponse); } public bool Equals(ReadResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return ArrayEquals(this._items,p._items); } public override int GetHashCode() { unchecked { int hash = 17; return hash; } } } public partial class DeleteRequest { private string _account; // string[uint_16] private string _thing; // string[uint_16] private string _docName; // string[uint_16] public string account { get { return _account; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("account string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _account = value; } } public string thing { get { return _thing; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("thing string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _thing = value; } } public string docName { get { return _docName; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("docName string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _docName = value; } } /**** Constructors ****/ public DeleteRequest() { } public DeleteRequest(string account, string thing, string docName) { this.account = account; this.thing = thing; this.docName = docName; } public DeleteRequest(System.IO.Stream stream) { Unpack(stream); } public DeleteRequest(System.IO.BinaryReader reader) { Unpack(reader); } public DeleteRequest Initialize(string account, string thing, string docName) { this.account = account; this.thing = thing; this.docName = docName; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { int _account_length = (int)reader.ReadUInt16(); byte[] _account_bytes = reader.ReadBytes(_account_length); _account = System.Text.Encoding.UTF8.GetString(_account_bytes); int _thing_length = (int)reader.ReadUInt16(); byte[] _thing_bytes = reader.ReadBytes(_thing_length); _thing = System.Text.Encoding.UTF8.GetString(_thing_bytes); int _docName_length = (int)reader.ReadUInt16(); byte[] _docName_bytes = reader.ReadBytes(_docName_length); _docName = System.Text.Encoding.UTF8.GetString(_docName_bytes); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { if (_account != null) { byte[] _account_bytes = System.Text.Encoding.UTF8.GetBytes(_account); writer.Write((ushort)_account_bytes.Length); writer.Write(_account_bytes); } else { writer.Write((ushort)0); } if (_thing != null) { byte[] _thing_bytes = System.Text.Encoding.UTF8.GetBytes(_thing); writer.Write((ushort)_thing_bytes.Length); writer.Write(_thing_bytes); } else { writer.Write((ushort)0); } if (_docName != null) { byte[] _docName_bytes = System.Text.Encoding.UTF8.GetBytes(_docName); writer.Write((ushort)_docName_bytes.Length); writer.Write(_docName_bytes); } else { writer.Write((ushort)0); } } public int Size { get { int result = 0; result += 2; // uint_16 if (account != null) { result += System.Text.Encoding.UTF8.GetByteCount(account); } result += 2; // uint_16 if (thing != null) { result += System.Text.Encoding.UTF8.GetByteCount(thing); } result += 2; // uint_16 if (docName != null) { result += System.Text.Encoding.UTF8.GetByteCount(docName); } return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(DeleteRequest a, DeleteRequest b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(DeleteRequest a, DeleteRequest b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as DeleteRequest); } public bool Equals(DeleteRequest p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._account.Equals(p._account) && this._thing.Equals(p._thing) && this._docName.Equals(p._docName); } public override int GetHashCode() { unchecked { int hash = 17; return hash; } } } public class DocRequest { public enum Tag { write, // 0 read, // 1 deleteReq, // 2 user, // 3 thing, // 4 INVALID = 255 }; private Tag _tag = Tag.INVALID; public Tag GetTag() { return _tag; } private object _state = null; public object GetState() { return _state; } public Anki.Vector.JDocs.WriteRequest write { get { if (_tag != Tag.write) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"write\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.JDocs.WriteRequest)this._state; } set { _tag = (value != null) ? Tag.write : Tag.INVALID; _state = value; } } public Anki.Vector.JDocs.ReadRequest read { get { if (_tag != Tag.read) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"read\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.JDocs.ReadRequest)this._state; } set { _tag = (value != null) ? Tag.read : Tag.INVALID; _state = value; } } public Anki.Vector.JDocs.DeleteRequest deleteReq { get { if (_tag != Tag.deleteReq) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"deleteReq\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.JDocs.DeleteRequest)this._state; } set { _tag = (value != null) ? Tag.deleteReq : Tag.INVALID; _state = value; } } public Anki.Vector.Void user { get { if (_tag != Tag.user) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"user\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.Void)this._state; } set { _tag = (value != null) ? Tag.user : Tag.INVALID; _state = value; } } public Anki.Vector.Void thing { get { if (_tag != Tag.thing) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"thing\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.Void)this._state; } set { _tag = (value != null) ? Tag.thing : Tag.INVALID; _state = value; } } public DocRequest Initialize(T state) { _state = state; if(typeof(T) == typeof(Anki.Vector.JDocs.WriteRequest)) { _tag = Tag.write; } else if(typeof(T) == typeof(Anki.Vector.JDocs.ReadRequest)) { _tag = Tag.read; } else if(typeof(T) == typeof(Anki.Vector.JDocs.DeleteRequest)) { _tag = Tag.deleteReq; } else if(typeof(T) == typeof(Anki.Vector.Void)) { _tag = Tag.user; } else if(typeof(T) == typeof(Anki.Vector.Void)) { _tag = Tag.thing; } else { _state = null; _tag = Tag.INVALID; } return this; } /**** Constructors ****/ public DocRequest() { } public DocRequest(System.IO.Stream stream) { Unpack(stream); } public DocRequest(System.IO.BinaryReader reader) { Unpack(reader); } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { Tag newTag = (Tag)reader.ReadByte(); switch(newTag) { case Tag.write: write = new Anki.Vector.JDocs.WriteRequest(reader); break; case Tag.read: read = new Anki.Vector.JDocs.ReadRequest(reader); break; case Tag.deleteReq: deleteReq = new Anki.Vector.JDocs.DeleteRequest(reader); break; case Tag.user: user = new Anki.Vector.Void(reader); break; case Tag.thing: thing = new Anki.Vector.Void(reader); break; default: break; } _tag = newTag; } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { writer.Write((byte)GetTag()); switch(GetTag()) { case Tag.write: if (write == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } write.Pack(writer); break; case Tag.read: if (read == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } read.Pack(writer); break; case Tag.deleteReq: if (deleteReq == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } deleteReq.Pack(writer); break; case Tag.user: if (user == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } user.Pack(writer); break; case Tag.thing: if (thing == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } thing.Pack(writer); break; default: break; } } public int Size { get { int result = 1; // tag = byte switch(GetTag()) { case Tag.write: if (write == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += write.Size; break; case Tag.read: if (read == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += read.Size; break; case Tag.deleteReq: if (deleteReq == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += deleteReq.Size; break; case Tag.user: if (user == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += user.Size; break; case Tag.thing: if (thing == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += thing.Size; break; default: // Just tag size break; } return result; } } public static bool operator ==(DocRequest a, DocRequest b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(DocRequest a, DocRequest b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as DocRequest); } public bool Equals(DocRequest p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return (_tag == p._tag && _state.Equals(p._state)); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._tag.GetHashCode(); hash = hash * 23 + this._state.GetHashCode(); return hash; } } } public partial class ErrorResponse { private Anki.Vector.JDocs.DocError _err; // DocError public Anki.Vector.JDocs.DocError err { get { return _err; } set { _err = value; } } /**** Constructors ****/ public ErrorResponse() { } public ErrorResponse(Anki.Vector.JDocs.DocError err) { this.err = err; } public ErrorResponse(System.IO.Stream stream) { Unpack(stream); } public ErrorResponse(System.IO.BinaryReader reader) { Unpack(reader); } public ErrorResponse Initialize(Anki.Vector.JDocs.DocError err) { this.err = err; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { _err = (Anki.Vector.JDocs.DocError)reader.ReadByte(); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { writer.Write((byte)_err); } public int Size { get { return 1; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(ErrorResponse a, ErrorResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(ErrorResponse a, ErrorResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as ErrorResponse); } public bool Equals(ErrorResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._err.Equals(p._err); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._err.GetHashCode(); return hash; } } } public partial class UserResponse { private string _userId; // string[uint_8] public string userId { get { return _userId; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 255) { throw new System.ArgumentException("userId string is too long. Must decode to less than or equal to 255 bytes.", "value"); } _userId = value; } } /**** Constructors ****/ public UserResponse() { } public UserResponse(string userId) { this.userId = userId; } public UserResponse(System.IO.Stream stream) { Unpack(stream); } public UserResponse(System.IO.BinaryReader reader) { Unpack(reader); } public UserResponse Initialize(string userId) { this.userId = userId; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { int _userId_length = (int)reader.ReadByte(); byte[] _userId_bytes = reader.ReadBytes(_userId_length); _userId = System.Text.Encoding.UTF8.GetString(_userId_bytes); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { if (_userId != null) { byte[] _userId_bytes = System.Text.Encoding.UTF8.GetBytes(_userId); writer.Write((byte)_userId_bytes.Length); writer.Write(_userId_bytes); } else { writer.Write((byte)0); } } public int Size { get { int result = 0; result += 1; // uint_8 if (userId != null) { result += System.Text.Encoding.UTF8.GetByteCount(userId); } return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(UserResponse a, UserResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(UserResponse a, UserResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as UserResponse); } public bool Equals(UserResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._userId.Equals(p._userId); } public override int GetHashCode() { unchecked { int hash = 17; return hash; } } } public partial class ThingResponse { private string _thingName; // string[uint_8] public string thingName { get { return _thingName; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 255) { throw new System.ArgumentException("thingName string is too long. Must decode to less than or equal to 255 bytes.", "value"); } _thingName = value; } } /**** Constructors ****/ public ThingResponse() { } public ThingResponse(string thingName) { this.thingName = thingName; } public ThingResponse(System.IO.Stream stream) { Unpack(stream); } public ThingResponse(System.IO.BinaryReader reader) { Unpack(reader); } public ThingResponse Initialize(string thingName) { this.thingName = thingName; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { int _thingName_length = (int)reader.ReadByte(); byte[] _thingName_bytes = reader.ReadBytes(_thingName_length); _thingName = System.Text.Encoding.UTF8.GetString(_thingName_bytes); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { if (_thingName != null) { byte[] _thingName_bytes = System.Text.Encoding.UTF8.GetBytes(_thingName); writer.Write((byte)_thingName_bytes.Length); writer.Write(_thingName_bytes); } else { writer.Write((byte)0); } } public int Size { get { int result = 0; result += 1; // uint_8 if (thingName != null) { result += System.Text.Encoding.UTF8.GetByteCount(thingName); } return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(ThingResponse a, ThingResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(ThingResponse a, ThingResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as ThingResponse); } public bool Equals(ThingResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._thingName.Equals(p._thingName); } public override int GetHashCode() { unchecked { int hash = 17; return hash; } } } public class DocResponse { public enum Tag { write, // 0 read, // 1 deleteResp, // 2 err, // 3 user, // 4 thing, // 5 INVALID = 255 }; private Tag _tag = Tag.INVALID; public Tag GetTag() { return _tag; } private object _state = null; public object GetState() { return _state; } public Anki.Vector.JDocs.WriteResponse write { get { if (_tag != Tag.write) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"write\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.JDocs.WriteResponse)this._state; } set { _tag = (value != null) ? Tag.write : Tag.INVALID; _state = value; } } public Anki.Vector.JDocs.ReadResponse read { get { if (_tag != Tag.read) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"read\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.JDocs.ReadResponse)this._state; } set { _tag = (value != null) ? Tag.read : Tag.INVALID; _state = value; } } public Anki.Vector.Void deleteResp { get { if (_tag != Tag.deleteResp) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"deleteResp\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.Void)this._state; } set { _tag = (value != null) ? Tag.deleteResp : Tag.INVALID; _state = value; } } public Anki.Vector.JDocs.ErrorResponse err { get { if (_tag != Tag.err) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"err\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.JDocs.ErrorResponse)this._state; } set { _tag = (value != null) ? Tag.err : Tag.INVALID; _state = value; } } public Anki.Vector.JDocs.UserResponse user { get { if (_tag != Tag.user) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"user\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.JDocs.UserResponse)this._state; } set { _tag = (value != null) ? Tag.user : Tag.INVALID; _state = value; } } public Anki.Vector.JDocs.ThingResponse thing { get { if (_tag != Tag.thing) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"thing\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.JDocs.ThingResponse)this._state; } set { _tag = (value != null) ? Tag.thing : Tag.INVALID; _state = value; } } public DocResponse Initialize(T state) { _state = state; if(typeof(T) == typeof(Anki.Vector.JDocs.WriteResponse)) { _tag = Tag.write; } else if(typeof(T) == typeof(Anki.Vector.JDocs.ReadResponse)) { _tag = Tag.read; } else if(typeof(T) == typeof(Anki.Vector.Void)) { _tag = Tag.deleteResp; } else if(typeof(T) == typeof(Anki.Vector.JDocs.ErrorResponse)) { _tag = Tag.err; } else if(typeof(T) == typeof(Anki.Vector.JDocs.UserResponse)) { _tag = Tag.user; } else if(typeof(T) == typeof(Anki.Vector.JDocs.ThingResponse)) { _tag = Tag.thing; } else { _state = null; _tag = Tag.INVALID; } return this; } /**** Constructors ****/ public DocResponse() { } public DocResponse(System.IO.Stream stream) { Unpack(stream); } public DocResponse(System.IO.BinaryReader reader) { Unpack(reader); } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { Tag newTag = (Tag)reader.ReadByte(); switch(newTag) { case Tag.write: write = new Anki.Vector.JDocs.WriteResponse(reader); break; case Tag.read: read = new Anki.Vector.JDocs.ReadResponse(reader); break; case Tag.deleteResp: deleteResp = new Anki.Vector.Void(reader); break; case Tag.err: err = new Anki.Vector.JDocs.ErrorResponse(reader); break; case Tag.user: user = new Anki.Vector.JDocs.UserResponse(reader); break; case Tag.thing: thing = new Anki.Vector.JDocs.ThingResponse(reader); break; default: break; } _tag = newTag; } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { writer.Write((byte)GetTag()); switch(GetTag()) { case Tag.write: if (write == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } write.Pack(writer); break; case Tag.read: if (read == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } read.Pack(writer); break; case Tag.deleteResp: if (deleteResp == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } deleteResp.Pack(writer); break; case Tag.err: if (err == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } err.Pack(writer); break; case Tag.user: if (user == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } user.Pack(writer); break; case Tag.thing: if (thing == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } thing.Pack(writer); break; default: break; } } public int Size { get { int result = 1; // tag = byte switch(GetTag()) { case Tag.write: if (write == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += write.Size; break; case Tag.read: if (read == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += read.Size; break; case Tag.deleteResp: if (deleteResp == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += deleteResp.Size; break; case Tag.err: if (err == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += err.Size; break; case Tag.user: if (user == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += user.Size; break; case Tag.thing: if (thing == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += thing.Size; break; default: // Just tag size break; } return result; } } public static bool operator ==(DocResponse a, DocResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(DocResponse a, DocResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as DocResponse); } public bool Equals(DocResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return (_tag == p._tag && _state.Equals(p._state)); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._tag.GetHashCode(); hash = hash * 23 + this._state.GetHashCode(); return hash; } } } } // namespace JDocs } // namespace Vector } // namespace Anki