Mercurial > hg > Database > Christie-sharp
changeset 18:8fe565f8acb8
fix CommandType enum
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 25 Nov 2020 01:27:41 +0900 |
parents | 4a3115ba746d |
children | c9d1a5a79254 |
files | datagear/command/Command.cs datagear/command/CommandType.cs |
diffstat | 2 files changed, 37 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/datagear/command/Command.cs Tue Nov 24 03:11:50 2020 +0900 +++ b/datagear/command/Command.cs Wed Nov 25 01:27:41 2020 +0900 @@ -37,7 +37,7 @@ public abstract MemoryStream Convert(); public RemoteMessage CreateRemoteMessage() { - return new RemoteMessage(type.id, fromDgmName, key, clazz.Name); + return new RemoteMessage((int) type, fromDgmName, key, clazz.Name); } public void SetDg(Object obj) {
--- a/datagear/command/CommandType.cs Tue Nov 24 03:11:50 2020 +0900 +++ b/datagear/command/CommandType.cs Wed Nov 25 01:27:41 2020 +0900 @@ -2,31 +2,41 @@ using System.Collections.Generic; namespace Christie_net.datagear.command { -public class CommandType { - private static int lastId = 0; // コマンドの総数 - public readonly int id = ++lastId; // コマンドのid コンストラクタが呼ばれるたびにlastIdが++される - public static readonly Dictionary<int, CommandType> hash = new Dictionary<int, CommandType>(); - - private CommandType() { - hash.Add(this.id, this); - } - - /// <summary> - /// idよりCommandTypeを返す - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - public static CommandType GetCommandTypeFromId(int id) { - return hash[id]; - } - - public static readonly CommandType PUT = new CommandType(); - public static readonly CommandType TAKE = new CommandType(); - public static readonly CommandType PEEK = new CommandType(); - public static readonly CommandType REMOTETAKE = new CommandType(); - public static readonly CommandType REMOTEPEEK = new CommandType(); - public static readonly CommandType REPLY = new CommandType(); - public static readonly CommandType CLOSE = new CommandType(); - public static readonly CommandType FINISH = new CommandType(); +public enum CommandType { + PUT = 1, + TAKE, + PEEK, + REMOTETAKE, + REMOTEPEEK, + REPLY, + CLOSE, + FINISH } +// public class CommandType { +// private static int lastId = 0; // コマンドの総数 +// public readonly int id = ++lastId; // コマンドのid コンストラクタが呼ばれるたびにlastIdが++される +// public static readonly Dictionary<int, CommandType> hash = new Dictionary<int, CommandType>(); +// +// private CommandType() { +// hash.Add(this.id, this); +// } +// +// /// <summary> +// /// idよりCommandTypeを返す +// /// </summary> +// /// <param name="id"></param> +// /// <returns></returns> +// public static CommandType GetCommandTypeFromId(int id) { +// return hash[id]; +// } +// +// public static readonly CommandType PUT = new CommandType(); +// public static readonly CommandType TAKE = new CommandType(); +// public static readonly CommandType PEEK = new CommandType(); +// public static readonly CommandType REMOTETAKE = new CommandType(); +// public static readonly CommandType REMOTEPEEK = new CommandType(); +// public static readonly CommandType REPLY = new CommandType(); +// public static readonly CommandType CLOSE = new CommandType(); +// public static readonly CommandType FINISH = new CommandType(); +// } } \ No newline at end of file