public static string command(this CommandMode inMode)
    {
        CommandAttribute[] attributes =
            (CommandAttribute[])inMode.GetType().GetField(inMode.ToString()).GetCustomAttributes(typeof(CommandAttribute), false);

        if (attributes.Length == 0)
        {
            Console.WriteLine("internal error");
            return("");
        }
        else
        {
            return(attributes[0].commandText);
        }
    }
Exemple #2
0
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (Command != null)
            {
                p.Add(new KeyValuePair <string, string>("Command", Command));
            }

            if (Sim != null)
            {
                p.Add(new KeyValuePair <string, string>("Sim", Sim));
            }

            if (CallbackMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString()));
            }

            if (CallbackUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("CallbackUrl", Serializers.Url(CallbackUrl)));
            }

            if (CommandMode != null)
            {
                p.Add(new KeyValuePair <string, string>("CommandMode", CommandMode.ToString()));
            }

            if (IncludeSid != null)
            {
                p.Add(new KeyValuePair <string, string>("IncludeSid", IncludeSid));
            }

            if (DeliveryReceiptRequested != null)
            {
                p.Add(new KeyValuePair <string, string>("DeliveryReceiptRequested", DeliveryReceiptRequested.Value.ToString().ToLower()));
            }

            return(p);
        }
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (Command != null)
            {
                p.Add(new KeyValuePair <string, string>("Command", Command));
            }

            if (Sim != null)
            {
                p.Add(new KeyValuePair <string, string>("Sim", Sim));
            }

            if (CallbackMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString()));
            }

            if (CallbackUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("CallbackUrl", CallbackUrl.AbsoluteUri));
            }

            if (CommandMode != null)
            {
                p.Add(new KeyValuePair <string, string>("CommandMode", CommandMode.ToString()));
            }

            if (IncludeSid != null)
            {
                p.Add(new KeyValuePair <string, string>("IncludeSid", IncludeSid));
            }

            return(p);
        }