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); } }
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); } }
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); } }
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); } }