using System; using System.Diagnostics; using System.IO; using Christie_net.codegear; using Christie_net.daemon; using Christie_net.datagear.dg; namespace Christie_net.datagear.command { public abstract class Command { public CommandType type; public string key; public string toDgmName; // for take public string fromDgmName = "local"; // for remotetake/reply public int? cgmID = -1; // for localtake public CodeGear cg; // for localtake public DataGear dg; // for put/localtake/reply public Type clazz; // for remote public Connection connection = null; // for reply public Command(CommandBuilder cb) { this.type = cb.type; this.key = cb.key; this.toDgmName = cb.toDgmName; this.fromDgmName = cb.fromDgmName; this.cgmID = cb.cgmID; this.cg = cb.cg; this.dg = cb.dg; this.clazz = cb.clazz; this.connection = cb.connection; } // instead of any Constoractor args protected void CheckNeedParam(CommandBuilder cb) { } public abstract void Execute(); // for remote public abstract MemoryStream Convert(); public RemoteMessage CreateRemoteMessage(byte[] data) { return new RemoteMessage((int) type, fromDgmName, key, clazz.FullName, data); } public void SetDg(Object obj) { this.dg.SetData(obj); } public override string ToString() { return "Command : type = " + type + ", key = " + key + "toDgmName = " + toDgmName + " fromDgmName = " + fromDgmName + " cgmID = " + cgmID + " cg = " + cg + " dg = " + dg + " clazz = " + clazz + "connection = " + connection; } } }