/// <summary> /// Extract value from a raw parameter string. /// "paraInputText" must be just a single value and not a multiple value parameters /// </summary> /// <param name="paraType"></param> /// <param name="paraInputText"></param> /// <param name="paraName"></param> /// <remarks> /// Complex parameter input can be as such, /// pipe "|" is used to split multiple values, comma "," is used to split Start and End value of a range. /// /// -a "date:(01-01-2001,28-02-2001)|(02-01-2002,31-10-2002)|(02-08-2002,31-12-2002)" /// -a "Client:(Ace Soft Inc,Best Computer Inc)|(Xtreme Bike Inc,Zebra Design Inc)" /// </remarks> /// <returns></returns> private ParameterValue GetSingleParamValue(DiscreteOrRangeKind paraType, string paraInputText, string paraName) { ParameterValues paraValues = new ParameterValues(); bool isDiscreateType = paraType == DiscreteOrRangeKind.DiscreteValue ? true : false; bool isDiscreateAndRangeType = paraType == DiscreteOrRangeKind.DiscreteAndRangeValue ? true : false; bool isRangeType = paraType == DiscreteOrRangeKind.RangeValue ? true : false; bool paraTextIsRange = paraInputText.IndexOf("(") != -1 ? true : false; if (isDiscreateType || (isDiscreateAndRangeType && !paraTextIsRange)) { var paraValue = new ParameterDiscreteValue() { Value = paraInputText }; _logger.Write(string.Format("Discrete Parameter : {0} = {1}", paraName, ((ParameterDiscreteValue)paraValue).Value)); return(paraValue); } else if (isRangeType || (isDiscreateAndRangeType && paraTextIsRange)) { // sample of range parameter (01-01-2001,28-02-2001) var paraValue = new ParameterRangeValue() { StartValue = Helper.GetStartValue(paraInputText), EndValue = Helper.GetEndValue(paraInputText) }; _logger.Write(string.Format("Range Parameter : {0} = {1} to {2} ", paraName, ((ParameterRangeValue)paraValue).StartValue, ((ParameterRangeValue)paraValue).EndValue)); return(paraValue); } return(null); }
private static void AddParameter(ref ParameterValues pValues, DiscreteOrRangeKind DoR, string inputString, string pName) { ParameterValue paraValue; if (DoR == DiscreteOrRangeKind.DiscreteValue || (DoR == DiscreteOrRangeKind.DiscreteAndRangeValue && inputString.IndexOf("(") == -1)) { paraValue = new ParameterDiscreteValue(); ((ParameterDiscreteValue)paraValue).Value = inputString; Console.WriteLine("Discrete Parameter : {0} = {1}", pName, ((ParameterDiscreteValue)paraValue).Value); if (enableLog) { WriteLog("Discrete Parameter : " + pName + " = " + ((ParameterDiscreteValue)paraValue).Value); } pValues.Add(paraValue); paraValue = null; } else if (DoR == DiscreteOrRangeKind.RangeValue || (DoR == DiscreteOrRangeKind.DiscreteAndRangeValue && inputString.IndexOf("(") != -1)) { paraValue = new ParameterRangeValue(); ((ParameterRangeValue)paraValue).StartValue = GetStartValue(inputString); ((ParameterRangeValue)paraValue).EndValue = GetEndValue(inputString); Console.WriteLine("Range Parameter : {0} = {1} to {2} ", pName, ((ParameterRangeValue)paraValue).StartValue, ((ParameterRangeValue)paraValue).EndValue); if (enableLog) { WriteLog("Range Parameter : " + pName + " = " + ((ParameterRangeValue)paraValue).StartValue + " to " + ((ParameterRangeValue)paraValue).EndValue); } pValues.Add(paraValue); paraValue = null; } }