public override string ToString() { ACommand.Sendable sendable = this as ACommand.Sendable; if (sendable != null) { return(sendable.Serialize()); } else { StringBuilder sb = new StringBuilder(); sb.Append(base.ToString()); sb.Append("["); foreach (var propertyInfo in this.GetType().GetProperties()) { sb.Append(propertyInfo.Name); sb.Append(":"); sb.Append(propertyInfo.GetValue(this, null)); sb.Append(";"); } foreach (var fieldInfo in this.GetType().GetFields()) { sb.Append(fieldInfo.Name); sb.Append(":"); sb.Append(fieldInfo.GetValue(this)); sb.Append(";"); } sb.Append("]"); return(sb.ToString()); } }
public static async Task SendAsync(this ACommand.Sendable instance, NetworkStream s) { if (instance == null) { throw new ArgumentNullException("Instance can not be null."); } await s.WriteLineAsync(instance.Serialize()); }
public static string ToString(this ACommand.Sendable instance) { if (instance == null) { throw new ArgumentNullException("Instance can not be null."); } return(instance.Serialize()); }
public virtual string GetSendableCommand(ACommand s) { ACommand.Sendable commandSendable = commandsFactory.Transfer(s); if (commandSendable == null) { throw new ArgumentException("Protocol (" + this.GetType().Name + ") do not know command type: " + s.GetType().Name); } return(commandSendable.Serialize()); }