コード例 #1
0
 private static TipoStato CreateMsgIng(string strMsg, TipoStato stato, out Messaggio msg)
 {
     msg = MessaggioFactory.Create(strMsg);
     TipoComando ingresso = (TipoComando)Enum.Parse(typeof(TipoComando), strMsg.Split(' ')[0], true);
     Ingresso ing = IngressoFactory.Create(ingresso);
     TipoStato statoSuccessivo = ing.CambiaStato(stato);
     return statoSuccessivo;
 }
コード例 #2
0
        public static Messaggio Parse(string str)
        {
            Messaggio newMsg = null;
            bool      creata = TryParse(str, out newMsg);

            if (!creata)
            {
                throw new FormatException("Formato Messaggio non corretto");
            }
            return(newMsg);
        }
コード例 #3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            Messaggio msg = obj as Messaggio;

            if (ReferenceEquals(msg, null))
            {
                return(false);
            }
            return(this.Comando == msg.Comando);
        }
コード例 #4
0
ファイル: Messaggio.cs プロジェクト: gabrielerossi/FLIP
 public static bool TryParse(string str, out Messaggio msg)
 {
     bool creata = false;
     try
     {
         string[] parti = str.Split(' ');
         TipoComando comando = (TipoComando)Enum.Parse(typeof(TipoComando), parti[0], true);
         msg = new Messaggio(comando);
         creata = true;
     }
     catch (Exception)
     {
         msg = null;
     }
     return creata;
 }
コード例 #5
0
        public static bool TryParse(string str, out Messaggio msg)
        {
            bool creata = false;

            try
            {
                string[]    parti   = str.Split(' ');
                TipoComando comando = (TipoComando)Enum.Parse(typeof(TipoComando), parti[0], true);
                msg    = new Messaggio(comando);
                creata = true;
            }
            catch (Exception)
            {
                msg = null;
            }
            return(creata);
        }
コード例 #6
0
        public static Messaggio Create(string str)
        {
            Messaggio resp = null;

            try
            {
                string      cmd     = str.Substring(0, 4);
                TipoComando cmdEnum = (TipoComando)Enum.Parse(typeof(TipoComando), cmd, true);
                switch (cmdEnum)
                {
                case TipoComando.Quit:
                    resp = Messaggio.Parse(str);
                    break;

                case TipoComando.Peop:
                    resp = MessaggioStringa.Parse(str);
                    break;

                case TipoComando.Birt:
                    resp = MessaggioData.Parse(str);
                    break;

                case TipoComando.Calc:
                    resp = Messaggio.Parse(str);
                    break;

                case TipoComando.Nessuno:
                    resp = null;
                    break;

                default:
                    resp = null;
                    break;
                    //throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception)
            {
            }
            return(resp);
        }
コード例 #7
0
 private static void RispostaServer(Messaggio msg, TipoStato stato, TipoStato statoSuccessivo, StreamWriter sw)
 {
     if (msg != null && statoSuccessivo != stato)
     {
         Console.WriteLine(msg.GetType().ToString());
         sw.WriteLine("{0} +OK", statoSuccessivo.ToString());
     }
     else
     {
         Console.WriteLine("Messaggio sconosciuto");
         sw.WriteLine("{0} -ERR", stato.ToString());
     }
 }