/// <summary> /// Parsers a command capturing its original parameters if the receiving collection /// is not null. /// </summary> public virtual string OnParseCommand(ICommand obj, IParameterCollection pc, bool nulls) { var str = obj.GetCommandText(iterable: false); if (str == null) { return(string.Empty); } if (obj.Parameters != null && obj.Parameters.Count != 0) { if (pc != null) // Capturing the original parameters... { foreach (var par in obj.Parameters) { var item = pc.AddCreate(par.Value); str = str.Replace(par.Name, item.Name); } } else // Border case: no receiving collection... { foreach (var par in obj.Parameters) { var value = Engine.TryTransform(par.Value); str = str.Replace(par.Name, Parse(value, null, nulls)); } } } return(str); }
/// <summary> /// Parsers a value or constant, capturing it into a parameter if such collection is /// available. /// </summary> protected virtual string OnParseConstant(object obj, IParameterCollection pc) { if (obj == null) { return(OnParseNull()); } if (pc != null) { return(pc.AddCreate(obj).Name); } else { return(obj.ToString()); } }
/// <summary> /// Parsers a value or constant, capturing it into a parameter if such collection is /// available. /// </summary> protected virtual string OnParseConstant(object obj, IParameterCollection pc) { if (obj == null) return OnParseNull(); if (pc != null) return pc.AddCreate(obj).Name; else return obj.ToString(); }
/// <summary> /// Parsers a command capturing its original parameters if the receiving collection /// is not null. /// </summary> public virtual string OnParseCommand(ICommand obj, IParameterCollection pc, bool nulls) { var str = obj.GetCommandText(iterable: false); if (str == null) return string.Empty; if (obj.Parameters != null && obj.Parameters.Count != 0) { if (pc != null) // Capturing the original parameters... { foreach (var par in obj.Parameters) { var item = pc.AddCreate(par.Value); str = str.Replace(par.Name, item.Name); } } else // Border case: no receiving collection... { foreach (var par in obj.Parameters) { var value = Engine.TryTransform(par.Value); str = str.Replace(par.Name, Parse(value, null, nulls)); } } } return str; }