CreateMessageFormatException() public static method

public static CreateMessageFormatException ( Exception cause ) : MessageFormatException
cause System.Exception
return MessageFormatException
Beispiel #1
0
        public double GetDouble(string key)
        {
            Object value = GetObjectProperty(key);

            try
            {
                if (value is Double)
                {
                    return((double)value);
                }
                else if (value is Single || value is String)
                {
                    return(Convert.ToDouble(value));
                }
                else
                {
                    throw new MessageFormatException(" cannot read a double from " + value.GetType().Name);
                }
            }
            catch (FormatException ex)
            {
                throw NMSExceptionSupport.CreateMessageFormatException(ex);
            }
        }
Beispiel #2
0
        public short GetShort(string key)
        {
            Object value = GetObjectProperty(key);

            try
            {
                if (value is Int16)
                {
                    return((short)value);
                }
                else if (value is Byte || value is String)
                {
                    return(Convert.ToInt16(value));
                }
                else
                {
                    throw new MessageFormatException(" cannot read a short from " + value.GetType().Name);
                }
            }
            catch (FormatException ex)
            {
                throw NMSExceptionSupport.CreateMessageFormatException(ex);
            }
        }
Beispiel #3
0
        public long GetLong(string key)
        {
            Object value = GetObjectProperty(key);

            try
            {
                if (value is Int64)
                {
                    return((long)value);
                }
                else if (value is Int32 || value is Int16 || value is Byte || value is String)
                {
                    return(Convert.ToInt64(value));
                }
                else
                {
                    throw new MessageFormatException(" cannot read a long from " + value.GetType().Name);
                }
            }
            catch (FormatException ex)
            {
                throw NMSExceptionSupport.CreateMessageFormatException(ex);
            }
        }
Beispiel #4
0
        public bool GetBool(string key)
        {
            Object value = GetObjectProperty(key);

            try
            {
                if (value is Boolean)
                {
                    return((bool)value);
                }
                else if (value is String)
                {
                    return(((string)value).ToLower() == "true");
                }
                else
                {
                    throw new MessageFormatException(" cannot read a boolean from " + value.GetType().Name);
                }
            }
            catch (FormatException ex)
            {
                throw NMSExceptionSupport.CreateMessageFormatException(ex);
            }
        }