/// <summary> /// Parse a variable from this object. /// </summary> /// <param name="key">Keyword for variable.</param> /// <param name="message">Message to parse for.</param> /// <param name="parser">Parser that is currently processing message.</param> /// <returns></returns> public string ParseVariable(string key, Tools.Message message, Tools.Parser parser) { var prop = this._GetProperty(key); if (prop == null || prop.GetMethod == null) { return(null); } object instance = prop.GetMethod.IsStatic ? null : this; object result = prop.GetMethod.Invoke(instance, new object[0]); if (object.ReferenceEquals(result, null)) { return(null); } if (result is float) { return(((float)result).ToString(System.Globalization.CultureInfo.InvariantCulture)); } if (result is double) { return(((double)result).ToString(System.Globalization.CultureInfo.InvariantCulture)); } if (result is IntPtr) { return(((IntPtr)result).ToHexString()); } return(result.ToString()); }
/// <summary> /// Parse an argument from this object. /// </summary> /// <param name="key">Keyword for argument.</param> /// <param name="message">Message to parse for.</param> /// <param name="parser">Parser that is currently processing message.</param> /// <returns></returns> public Tools.IArgument ParseArgument(string key, Tools.Message message, Tools.Parser parser) { var prop = this._GetProperty(key); if (prop == null || prop.GetMethod == null) { return(null); } object instance = prop.GetMethod.IsStatic ? null : this; return(prop.GetMethod.Invoke(instance, new object[0]) as Tools.IArgument); }
/// <summary> /// Parse a function from this object. /// </summary> /// <param name="key">Keyword for function.</param> /// <param name="args">Arguments for function.</param> /// <param name="message">Message to parse for.</param> /// <param name="parser">Parser that is currently processing message.</param> /// <returns></returns> public string ParseFunction(string key, string[] args, Tools.Message message, Tools.Parser parser) { return(null); }