コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: Messaggio.cs プロジェクト: Tacconi/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;
 }
コード例 #4
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);
        }
コード例 #5
0
ファイル: MessaggioFactory.cs プロジェクト: Tacconi/FLIP
        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;

                default:
                    resp = null;
                    break;
                    //throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception)
            {
            }
            return(resp);
        }