// Autogenerated C# message buffer code. // Source: clad/gateway/switchboard.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/gateway/switchboard.clad namespace Anki { namespace Switchboard { public partial class SwitchboardError { /**** Constructors ****/ public SwitchboardError() { } public SwitchboardError(System.IO.Stream stream) { Unpack(stream); } public SwitchboardError(System.IO.BinaryReader reader) { Unpack(reader); } public void Unpack(System.IO.Stream stream) { } public void Unpack(System.IO.BinaryReader reader) { } public void Pack(System.IO.Stream stream) { } public void Pack(System.IO.BinaryWriter writer) { } public int Size { get { return 0; } } } public partial class ExternalConnectionRequest { /**** Constructors ****/ public ExternalConnectionRequest() { } public ExternalConnectionRequest(System.IO.Stream stream) { Unpack(stream); } public ExternalConnectionRequest(System.IO.BinaryReader reader) { Unpack(reader); } public void Unpack(System.IO.Stream stream) { } public void Unpack(System.IO.BinaryReader reader) { } public void Pack(System.IO.Stream stream) { } public void Pack(System.IO.BinaryWriter writer) { } public int Size { get { return 0; } } } public partial class ExternalConnectionResponse { private bool _isConnected; // bool private string _connectionId; // string[uint_16] public bool isConnected { get { return _isConnected; } set { _isConnected = value; } } public string connectionId { get { return _connectionId; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("connectionId string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _connectionId = value; } } /**** Constructors ****/ public ExternalConnectionResponse() { } public ExternalConnectionResponse(bool isConnected, string connectionId) { this.isConnected = isConnected; this.connectionId = connectionId; } public ExternalConnectionResponse(System.IO.Stream stream) { Unpack(stream); } public ExternalConnectionResponse(System.IO.BinaryReader reader) { Unpack(reader); } public ExternalConnectionResponse Initialize(bool isConnected, string connectionId) { this.isConnected = isConnected; this.connectionId = connectionId; 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) { _isConnected = reader.ReadBoolean(); int _connectionId_length = (int)reader.ReadUInt16(); byte[] _connectionId_bytes = reader.ReadBytes(_connectionId_length); _connectionId = System.Text.Encoding.UTF8.GetString(_connectionId_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((bool)_isConnected); if (_connectionId != null) { byte[] _connectionId_bytes = System.Text.Encoding.UTF8.GetBytes(_connectionId); writer.Write((ushort)_connectionId_bytes.Length); writer.Write(_connectionId_bytes); } else { writer.Write((ushort)0); } } public int Size { get { int result = 0; result += 1; // bool result += 2; // uint_16 if (connectionId != null) { result += System.Text.Encoding.UTF8.GetByteCount(connectionId); } 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 ==(ExternalConnectionResponse a, ExternalConnectionResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(ExternalConnectionResponse a, ExternalConnectionResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as ExternalConnectionResponse); } public bool Equals(ExternalConnectionResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._isConnected.Equals(p._isConnected) && this._connectionId.Equals(p._connectionId); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._isConnected.GetHashCode(); return hash; } } } public partial class ClientGuidRefreshRequest { /**** Constructors ****/ public ClientGuidRefreshRequest() { } public ClientGuidRefreshRequest(System.IO.Stream stream) { Unpack(stream); } public ClientGuidRefreshRequest(System.IO.BinaryReader reader) { Unpack(reader); } public void Unpack(System.IO.Stream stream) { } public void Unpack(System.IO.BinaryReader reader) { } public void Pack(System.IO.Stream stream) { } public void Pack(System.IO.BinaryWriter writer) { } public int Size { get { return 0; } } } public partial class ClientGuidRefreshResponse { /**** Constructors ****/ public ClientGuidRefreshResponse() { } public ClientGuidRefreshResponse(System.IO.Stream stream) { Unpack(stream); } public ClientGuidRefreshResponse(System.IO.BinaryReader reader) { Unpack(reader); } public void Unpack(System.IO.Stream stream) { } public void Unpack(System.IO.BinaryReader reader) { } public void Pack(System.IO.Stream stream) { } public void Pack(System.IO.BinaryWriter writer) { } public int Size { get { return 0; } } } public partial class SdkProxyRequest { private string _clientGuid; // string[uint_8] private string _messageId; // string[uint_8] private string _path; // string[uint_8] private string _json; // string[uint_16] public string clientGuid { get { return _clientGuid; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 255) { throw new System.ArgumentException("clientGuid string is too long. Must decode to less than or equal to 255 bytes.", "value"); } _clientGuid = value; } } public string messageId { get { return _messageId; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 255) { throw new System.ArgumentException("messageId string is too long. Must decode to less than or equal to 255 bytes.", "value"); } _messageId = value; } } public string path { get { return _path; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 255) { throw new System.ArgumentException("path string is too long. Must decode to less than or equal to 255 bytes.", "value"); } _path = value; } } public string json { get { return _json; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("json string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _json = value; } } /**** Constructors ****/ public SdkProxyRequest() { } public SdkProxyRequest(string clientGuid, string messageId, string path, string json) { this.clientGuid = clientGuid; this.messageId = messageId; this.path = path; this.json = json; } public SdkProxyRequest(System.IO.Stream stream) { Unpack(stream); } public SdkProxyRequest(System.IO.BinaryReader reader) { Unpack(reader); } public SdkProxyRequest Initialize(string clientGuid, string messageId, string path, string json) { this.clientGuid = clientGuid; this.messageId = messageId; this.path = path; this.json = json; 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 _clientGuid_length = (int)reader.ReadByte(); byte[] _clientGuid_bytes = reader.ReadBytes(_clientGuid_length); _clientGuid = System.Text.Encoding.UTF8.GetString(_clientGuid_bytes); int _messageId_length = (int)reader.ReadByte(); byte[] _messageId_bytes = reader.ReadBytes(_messageId_length); _messageId = System.Text.Encoding.UTF8.GetString(_messageId_bytes); int _path_length = (int)reader.ReadByte(); byte[] _path_bytes = reader.ReadBytes(_path_length); _path = System.Text.Encoding.UTF8.GetString(_path_bytes); int _json_length = (int)reader.ReadUInt16(); byte[] _json_bytes = reader.ReadBytes(_json_length); _json = System.Text.Encoding.UTF8.GetString(_json_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 (_clientGuid != null) { byte[] _clientGuid_bytes = System.Text.Encoding.UTF8.GetBytes(_clientGuid); writer.Write((byte)_clientGuid_bytes.Length); writer.Write(_clientGuid_bytes); } else { writer.Write((byte)0); } if (_messageId != null) { byte[] _messageId_bytes = System.Text.Encoding.UTF8.GetBytes(_messageId); writer.Write((byte)_messageId_bytes.Length); writer.Write(_messageId_bytes); } else { writer.Write((byte)0); } if (_path != null) { byte[] _path_bytes = System.Text.Encoding.UTF8.GetBytes(_path); writer.Write((byte)_path_bytes.Length); writer.Write(_path_bytes); } else { writer.Write((byte)0); } if (_json != null) { byte[] _json_bytes = System.Text.Encoding.UTF8.GetBytes(_json); writer.Write((ushort)_json_bytes.Length); writer.Write(_json_bytes); } else { writer.Write((ushort)0); } } public int Size { get { int result = 0; result += 1; // uint_8 if (clientGuid != null) { result += System.Text.Encoding.UTF8.GetByteCount(clientGuid); } result += 1; // uint_8 if (messageId != null) { result += System.Text.Encoding.UTF8.GetByteCount(messageId); } result += 1; // uint_8 if (path != null) { result += System.Text.Encoding.UTF8.GetByteCount(path); } result += 2; // uint_16 if (json != null) { result += System.Text.Encoding.UTF8.GetByteCount(json); } 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 ==(SdkProxyRequest a, SdkProxyRequest b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(SdkProxyRequest a, SdkProxyRequest b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as SdkProxyRequest); } public bool Equals(SdkProxyRequest p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._clientGuid.Equals(p._clientGuid) && this._messageId.Equals(p._messageId) && this._path.Equals(p._path) && this._json.Equals(p._json); } public override int GetHashCode() { unchecked { int hash = 17; return hash; } } } public partial class SdkProxyResponse { private string _messageId; // string[uint_8] private ushort _statusCode; // uint_16 private string _contentType; // string[uint_8] private string _content; // string[uint_16] public string messageId { get { return _messageId; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 255) { throw new System.ArgumentException("messageId string is too long. Must decode to less than or equal to 255 bytes.", "value"); } _messageId = value; } } public ushort statusCode { get { return _statusCode; } set { _statusCode = value; } } public string contentType { get { return _contentType; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 255) { throw new System.ArgumentException("contentType string is too long. Must decode to less than or equal to 255 bytes.", "value"); } _contentType = value; } } public string content { get { return _content; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("content string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _content = value; } } /**** Constructors ****/ public SdkProxyResponse() { } public SdkProxyResponse(string messageId, ushort statusCode, string contentType, string content) { this.messageId = messageId; this.statusCode = statusCode; this.contentType = contentType; this.content = content; } public SdkProxyResponse(System.IO.Stream stream) { Unpack(stream); } public SdkProxyResponse(System.IO.BinaryReader reader) { Unpack(reader); } public SdkProxyResponse Initialize(string messageId, ushort statusCode, string contentType, string content) { this.messageId = messageId; this.statusCode = statusCode; this.contentType = contentType; this.content = content; 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 _messageId_length = (int)reader.ReadByte(); byte[] _messageId_bytes = reader.ReadBytes(_messageId_length); _messageId = System.Text.Encoding.UTF8.GetString(_messageId_bytes); _statusCode = reader.ReadUInt16(); int _contentType_length = (int)reader.ReadByte(); byte[] _contentType_bytes = reader.ReadBytes(_contentType_length); _contentType = System.Text.Encoding.UTF8.GetString(_contentType_bytes); int _content_length = (int)reader.ReadUInt16(); byte[] _content_bytes = reader.ReadBytes(_content_length); _content = System.Text.Encoding.UTF8.GetString(_content_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 (_messageId != null) { byte[] _messageId_bytes = System.Text.Encoding.UTF8.GetBytes(_messageId); writer.Write((byte)_messageId_bytes.Length); writer.Write(_messageId_bytes); } else { writer.Write((byte)0); } writer.Write((ushort)_statusCode); if (_contentType != null) { byte[] _contentType_bytes = System.Text.Encoding.UTF8.GetBytes(_contentType); writer.Write((byte)_contentType_bytes.Length); writer.Write(_contentType_bytes); } else { writer.Write((byte)0); } if (_content != null) { byte[] _content_bytes = System.Text.Encoding.UTF8.GetBytes(_content); writer.Write((ushort)_content_bytes.Length); writer.Write(_content_bytes); } else { writer.Write((ushort)0); } } public int Size { get { int result = 0; result += 1; // uint_8 if (messageId != null) { result += System.Text.Encoding.UTF8.GetByteCount(messageId); } result += 2; // uint_16 result += 1; // uint_8 if (contentType != null) { result += System.Text.Encoding.UTF8.GetByteCount(contentType); } result += 2; // uint_16 if (content != null) { result += System.Text.Encoding.UTF8.GetByteCount(content); } 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 ==(SdkProxyResponse a, SdkProxyResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(SdkProxyResponse a, SdkProxyResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as SdkProxyResponse); } public bool Equals(SdkProxyResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._messageId.Equals(p._messageId) && this._statusCode.Equals(p._statusCode) && this._contentType.Equals(p._contentType) && this._content.Equals(p._content); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._statusCode.GetHashCode(); return hash; } } } public class SwitchboardRequest { public enum Tag { SwitchboardError = 0x1, // 1 AuthRequest = 0x2, // 2 JwtRequest = 0x3, // 3 ExternalConnectionRequest = 0x4, // 4 ExternalConnectionResponse = 0x5, // 5 ClientGuidRefreshResponse = 0x6, // 6 SdkProxyResponse = 0x7, // 7 INVALID = 255 }; private Tag _tag = Tag.INVALID; public Tag GetTag() { return _tag; } private object _state = null; public object GetState() { return _state; } public Anki.Switchboard.SwitchboardError SwitchboardError { get { if (_tag != Tag.SwitchboardError) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"SwitchboardError\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Switchboard.SwitchboardError)this._state; } set { _tag = (value != null) ? Tag.SwitchboardError : Tag.INVALID; _state = value; } } public Anki.Vector.AuthRequest AuthRequest { get { if (_tag != Tag.AuthRequest) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"AuthRequest\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.AuthRequest)this._state; } set { _tag = (value != null) ? Tag.AuthRequest : Tag.INVALID; _state = value; } } public Anki.Vector.JwtRequest JwtRequest { get { if (_tag != Tag.JwtRequest) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"JwtRequest\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.JwtRequest)this._state; } set { _tag = (value != null) ? Tag.JwtRequest : Tag.INVALID; _state = value; } } public Anki.Switchboard.ExternalConnectionRequest ExternalConnectionRequest { get { if (_tag != Tag.ExternalConnectionRequest) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"ExternalConnectionRequest\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Switchboard.ExternalConnectionRequest)this._state; } set { _tag = (value != null) ? Tag.ExternalConnectionRequest : Tag.INVALID; _state = value; } } public Anki.Switchboard.ExternalConnectionResponse ExternalConnectionResponse { get { if (_tag != Tag.ExternalConnectionResponse) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"ExternalConnectionResponse\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Switchboard.ExternalConnectionResponse)this._state; } set { _tag = (value != null) ? Tag.ExternalConnectionResponse : Tag.INVALID; _state = value; } } public Anki.Switchboard.ClientGuidRefreshResponse ClientGuidRefreshResponse { get { if (_tag != Tag.ClientGuidRefreshResponse) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"ClientGuidRefreshResponse\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Switchboard.ClientGuidRefreshResponse)this._state; } set { _tag = (value != null) ? Tag.ClientGuidRefreshResponse : Tag.INVALID; _state = value; } } public Anki.Switchboard.SdkProxyResponse SdkProxyResponse { get { if (_tag != Tag.SdkProxyResponse) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"SdkProxyResponse\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Switchboard.SdkProxyResponse)this._state; } set { _tag = (value != null) ? Tag.SdkProxyResponse : Tag.INVALID; _state = value; } } public SwitchboardRequest Initialize(T state) { _state = state; if(typeof(T) == typeof(Anki.Switchboard.SwitchboardError)) { _tag = Tag.SwitchboardError; } else if(typeof(T) == typeof(Anki.Vector.AuthRequest)) { _tag = Tag.AuthRequest; } else if(typeof(T) == typeof(Anki.Vector.JwtRequest)) { _tag = Tag.JwtRequest; } else if(typeof(T) == typeof(Anki.Switchboard.ExternalConnectionRequest)) { _tag = Tag.ExternalConnectionRequest; } else if(typeof(T) == typeof(Anki.Switchboard.ExternalConnectionResponse)) { _tag = Tag.ExternalConnectionResponse; } else if(typeof(T) == typeof(Anki.Switchboard.ClientGuidRefreshResponse)) { _tag = Tag.ClientGuidRefreshResponse; } else if(typeof(T) == typeof(Anki.Switchboard.SdkProxyResponse)) { _tag = Tag.SdkProxyResponse; } else { _state = null; _tag = Tag.INVALID; } return this; } /**** Constructors ****/ public SwitchboardRequest() { } public SwitchboardRequest(System.IO.Stream stream) { Unpack(stream); } public SwitchboardRequest(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.SwitchboardError: SwitchboardError = new Anki.Switchboard.SwitchboardError(reader); break; case Tag.AuthRequest: AuthRequest = new Anki.Vector.AuthRequest(reader); break; case Tag.JwtRequest: JwtRequest = new Anki.Vector.JwtRequest(reader); break; case Tag.ExternalConnectionRequest: ExternalConnectionRequest = new Anki.Switchboard.ExternalConnectionRequest(reader); break; case Tag.ExternalConnectionResponse: ExternalConnectionResponse = new Anki.Switchboard.ExternalConnectionResponse(reader); break; case Tag.ClientGuidRefreshResponse: ClientGuidRefreshResponse = new Anki.Switchboard.ClientGuidRefreshResponse(reader); break; case Tag.SdkProxyResponse: SdkProxyResponse = new Anki.Switchboard.SdkProxyResponse(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.SwitchboardError: if (SwitchboardError == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } SwitchboardError.Pack(writer); break; case Tag.AuthRequest: if (AuthRequest == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } AuthRequest.Pack(writer); break; case Tag.JwtRequest: if (JwtRequest == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } JwtRequest.Pack(writer); break; case Tag.ExternalConnectionRequest: if (ExternalConnectionRequest == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } ExternalConnectionRequest.Pack(writer); break; case Tag.ExternalConnectionResponse: if (ExternalConnectionResponse == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } ExternalConnectionResponse.Pack(writer); break; case Tag.ClientGuidRefreshResponse: if (ClientGuidRefreshResponse == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } ClientGuidRefreshResponse.Pack(writer); break; case Tag.SdkProxyResponse: if (SdkProxyResponse == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } SdkProxyResponse.Pack(writer); break; default: break; } } public int Size { get { int result = 1; // tag = byte switch(GetTag()) { case Tag.SwitchboardError: if (SwitchboardError == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += SwitchboardError.Size; break; case Tag.AuthRequest: if (AuthRequest == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += AuthRequest.Size; break; case Tag.JwtRequest: if (JwtRequest == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += JwtRequest.Size; break; case Tag.ExternalConnectionRequest: if (ExternalConnectionRequest == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += ExternalConnectionRequest.Size; break; case Tag.ExternalConnectionResponse: if (ExternalConnectionResponse == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += ExternalConnectionResponse.Size; break; case Tag.ClientGuidRefreshResponse: if (ClientGuidRefreshResponse == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += ClientGuidRefreshResponse.Size; break; case Tag.SdkProxyResponse: if (SdkProxyResponse == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += SdkProxyResponse.Size; break; default: // Just tag size break; } return result; } } public static bool operator ==(SwitchboardRequest a, SwitchboardRequest b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(SwitchboardRequest a, SwitchboardRequest b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as SwitchboardRequest); } public bool Equals(SwitchboardRequest 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 class SwitchboardResponse { public enum Tag { SwitchboardError = 0x1, // 1 AuthResponse = 0x2, // 2 JwtResponse = 0x3, // 3 ExternalConnectionRequest = 0x4, // 4 ExternalConnectionResponse = 0x5, // 5 ClientGuidRefreshRequest = 0x6, // 6 SdkProxyRequest = 0x7, // 7 INVALID = 255 }; private Tag _tag = Tag.INVALID; public Tag GetTag() { return _tag; } private object _state = null; public object GetState() { return _state; } public Anki.Switchboard.SwitchboardError SwitchboardError { get { if (_tag != Tag.SwitchboardError) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"SwitchboardError\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Switchboard.SwitchboardError)this._state; } set { _tag = (value != null) ? Tag.SwitchboardError : Tag.INVALID; _state = value; } } public Anki.Vector.AuthResponse AuthResponse { get { if (_tag != Tag.AuthResponse) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"AuthResponse\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.AuthResponse)this._state; } set { _tag = (value != null) ? Tag.AuthResponse : Tag.INVALID; _state = value; } } public Anki.Vector.JwtResponse JwtResponse { get { if (_tag != Tag.JwtResponse) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"JwtResponse\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.JwtResponse)this._state; } set { _tag = (value != null) ? Tag.JwtResponse : Tag.INVALID; _state = value; } } public Anki.Switchboard.ExternalConnectionRequest ExternalConnectionRequest { get { if (_tag != Tag.ExternalConnectionRequest) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"ExternalConnectionRequest\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Switchboard.ExternalConnectionRequest)this._state; } set { _tag = (value != null) ? Tag.ExternalConnectionRequest : Tag.INVALID; _state = value; } } public Anki.Switchboard.ExternalConnectionResponse ExternalConnectionResponse { get { if (_tag != Tag.ExternalConnectionResponse) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"ExternalConnectionResponse\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Switchboard.ExternalConnectionResponse)this._state; } set { _tag = (value != null) ? Tag.ExternalConnectionResponse : Tag.INVALID; _state = value; } } public Anki.Switchboard.ClientGuidRefreshRequest ClientGuidRefreshRequest { get { if (_tag != Tag.ClientGuidRefreshRequest) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"ClientGuidRefreshRequest\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Switchboard.ClientGuidRefreshRequest)this._state; } set { _tag = (value != null) ? Tag.ClientGuidRefreshRequest : Tag.INVALID; _state = value; } } public Anki.Switchboard.SdkProxyRequest SdkProxyRequest { get { if (_tag != Tag.SdkProxyRequest) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"SdkProxyRequest\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Switchboard.SdkProxyRequest)this._state; } set { _tag = (value != null) ? Tag.SdkProxyRequest : Tag.INVALID; _state = value; } } public SwitchboardResponse Initialize(T state) { _state = state; if(typeof(T) == typeof(Anki.Switchboard.SwitchboardError)) { _tag = Tag.SwitchboardError; } else if(typeof(T) == typeof(Anki.Vector.AuthResponse)) { _tag = Tag.AuthResponse; } else if(typeof(T) == typeof(Anki.Vector.JwtResponse)) { _tag = Tag.JwtResponse; } else if(typeof(T) == typeof(Anki.Switchboard.ExternalConnectionRequest)) { _tag = Tag.ExternalConnectionRequest; } else if(typeof(T) == typeof(Anki.Switchboard.ExternalConnectionResponse)) { _tag = Tag.ExternalConnectionResponse; } else if(typeof(T) == typeof(Anki.Switchboard.ClientGuidRefreshRequest)) { _tag = Tag.ClientGuidRefreshRequest; } else if(typeof(T) == typeof(Anki.Switchboard.SdkProxyRequest)) { _tag = Tag.SdkProxyRequest; } else { _state = null; _tag = Tag.INVALID; } return this; } /**** Constructors ****/ public SwitchboardResponse() { } public SwitchboardResponse(System.IO.Stream stream) { Unpack(stream); } public SwitchboardResponse(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.SwitchboardError: SwitchboardError = new Anki.Switchboard.SwitchboardError(reader); break; case Tag.AuthResponse: AuthResponse = new Anki.Vector.AuthResponse(reader); break; case Tag.JwtResponse: JwtResponse = new Anki.Vector.JwtResponse(reader); break; case Tag.ExternalConnectionRequest: ExternalConnectionRequest = new Anki.Switchboard.ExternalConnectionRequest(reader); break; case Tag.ExternalConnectionResponse: ExternalConnectionResponse = new Anki.Switchboard.ExternalConnectionResponse(reader); break; case Tag.ClientGuidRefreshRequest: ClientGuidRefreshRequest = new Anki.Switchboard.ClientGuidRefreshRequest(reader); break; case Tag.SdkProxyRequest: SdkProxyRequest = new Anki.Switchboard.SdkProxyRequest(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.SwitchboardError: if (SwitchboardError == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } SwitchboardError.Pack(writer); break; case Tag.AuthResponse: if (AuthResponse == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } AuthResponse.Pack(writer); break; case Tag.JwtResponse: if (JwtResponse == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } JwtResponse.Pack(writer); break; case Tag.ExternalConnectionRequest: if (ExternalConnectionRequest == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } ExternalConnectionRequest.Pack(writer); break; case Tag.ExternalConnectionResponse: if (ExternalConnectionResponse == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } ExternalConnectionResponse.Pack(writer); break; case Tag.ClientGuidRefreshRequest: if (ClientGuidRefreshRequest == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } ClientGuidRefreshRequest.Pack(writer); break; case Tag.SdkProxyRequest: if (SdkProxyRequest == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } SdkProxyRequest.Pack(writer); break; default: break; } } public int Size { get { int result = 1; // tag = byte switch(GetTag()) { case Tag.SwitchboardError: if (SwitchboardError == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += SwitchboardError.Size; break; case Tag.AuthResponse: if (AuthResponse == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += AuthResponse.Size; break; case Tag.JwtResponse: if (JwtResponse == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += JwtResponse.Size; break; case Tag.ExternalConnectionRequest: if (ExternalConnectionRequest == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += ExternalConnectionRequest.Size; break; case Tag.ExternalConnectionResponse: if (ExternalConnectionResponse == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += ExternalConnectionResponse.Size; break; case Tag.ClientGuidRefreshRequest: if (ClientGuidRefreshRequest == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += ClientGuidRefreshRequest.Size; break; case Tag.SdkProxyRequest: if (SdkProxyRequest == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += SdkProxyRequest.Size; break; default: // Just tag size break; } return result; } } public static bool operator ==(SwitchboardResponse a, SwitchboardResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(SwitchboardResponse a, SwitchboardResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as SwitchboardResponse); } public bool Equals(SwitchboardResponse 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 Switchboard } // namespace Anki