Mercurial > hg > Database > Christie-sharp
view datagear/command/CommandType.cs @ 23:46cfeb0609c5
Add TcpConnections
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Dec 2020 22:11:40 +0900 |
parents | 8fe565f8acb8 |
children |
line wrap: on
line source
using System; using System.Collections.Generic; using Christie_net.daemon; namespace Christie_net.datagear.command { public enum CommandType { PUT = 1, TAKE, PEEK, REMOTETAKE, REMOTEPEEK, REPLY, CLOSE, FINISH } public static class CommandTypeExt { public static Dictionary<int, CommandType> hash = new Dictionary<int, CommandType>(); static CommandTypeExt() { foreach (CommandType value in Enum.GetValues(typeof(CommandType))) { hash.Add((int)value, value); } } public static CommandType GetCommandTypeFormId(int id) { return hash[id]; } } // 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(); // } }