/// <summary>
        /// Compare this parameter to another parameter.
        /// </summary>
        /// <param name="p">Specifies the other parameter to compare with this one.</param>
        /// <returns>Returns <i>true</i> if the two parameters are the same, <i>false</i> otherwise.</returns>
        public virtual bool Compare(BaseParameter p)
        {
            RawProto p1   = ToProto("foo");
            RawProto p2   = p.ToProto("foo");
            string   str1 = p1.ToString();
            string   str2 = p2.ToString();

            return(str1 == str2);
        }
Beispiel #2
0
        /// <summary>
        /// Returns a property as an double value.
        /// </summary>
        /// <param name="strName">Specifies the name of the property.</param>
        /// <param name="dfDefault">Specifies the default value returned when the property is not found.</param>
        /// <returns>The property value is returned.</returns>
        public double GetPropertyAsDouble(string strName, double dfDefault = 0)
        {
            string strVal = GetProperty(strName, false);

            if (strVal == null)
            {
                return(dfDefault);
            }

            double dfVal;

            if (!BaseParameter.TryParse(strVal, out dfVal))
            {
                throw new Exception("Failed to parse '" + strName + "' as a Double.  The value = '" + strVal + "'");
            }

            return(dfVal);
        }
Beispiel #3
0
        private object convert(string strVal, Type t)
        {
            strVal = strVal.TrimEnd('}');

            if (t == typeof(string))
            {
                return(strVal);
            }

            if (t == typeof(bool))
            {
                return(bool.Parse(strVal));
            }

            if (t == typeof(double))
            {
                return(BaseParameter.ParseDouble(strVal));
            }

            if (t == typeof(float))
            {
                return(BaseParameter.ParseFloat(strVal));
            }

            if (t == typeof(long))
            {
                return(long.Parse(strVal));
            }

            if (t == typeof(int))
            {
                return(int.Parse(strVal));
            }

            if (t == typeof(uint))
            {
                return(uint.Parse(strVal));
            }

            throw new Exception("The type '" + t.ToString() + "' is not supported by the FindArray<T> function!");
        }