Exemple #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            MessaggioStringa msg = obj as MessaggioStringa;

            if (ReferenceEquals(msg, null))
            {
                return(false);
            }
            return(base.Equals(msg) && this.Stringa == msg.Stringa);
        }
Exemple #2
0
 public static new 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);
         string stringa = parti[1];
         msg = new MessaggioStringa(comando, stringa);
         creata = true;
     }
     catch (Exception)
     {
         msg = null;
     }
     return creata;
 }
Exemple #3
0
        public static new 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);
                string      stringa = parti[1];
                msg    = new MessaggioStringa(comando, stringa);
                creata = true;
            }
            catch (Exception)
            {
                msg = null;
            }
            return(creata);
        }
Exemple #4
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;

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