public void IsEmptyTest() { JobParameters jp = TearUp(); Assert.IsFalse(jp.IsEmpty()); JobParameters jp2 = new JobParameters(); Assert.IsTrue(jp2.IsEmpty()); }
/// <summary> /// Use the same suffixes to create properties (omitting the string suffix /// because it is the default). Non-identifying parameters will be prefixed /// with the <see cref="NonIdentifyingFlag"/>. However, since parameters are /// identifying by default, they will <em>not</em> be prefixed with the /// <see cref="IdentifyingFlag"/>. /// </summary> /// <param name="parms"></param> /// <returns></returns> public NameValueCollection GetProperties(JobParameters parms) { if (parms == null || parms.IsEmpty()) { return(new NameValueCollection()); } IDictionary <string, JobParameter> parameters = parms.GetParameters(); NameValueCollection result = new NameValueCollection(); foreach (KeyValuePair <string, JobParameter> entry in parameters) { string key = entry.Key; JobParameter jobParameter = entry.Value; Object value = jobParameter.Value; if (value != null) { key = (!jobParameter.Identifying ? NonIdentifyingFlag : "") + key; if (jobParameter.Type == JobParameter.ParameterType.Date) { result.Set(key + DateType, string.Format(_dateFormat, value)); } else if (jobParameter.Type == JobParameter.ParameterType.Long) { result.Set(key + LongType, string.Format(_numberFormat, value)); } else if (jobParameter.Type == JobParameter.ParameterType.Double) { result.Set(key + DoubleType, string.Format(_decimalFormat, (double)value)); } else { result.Set(key, "" + value); } } } return(result); }
/// <summary> /// Use the same suffixes to create properties (omitting the string suffix /// because it is the default). Non-identifying parameters will be prefixed /// with the <see cref="NonIdentifyingFlag"/>. However, since parameters are /// identifying by default, they will <em>not</em> be prefixed with the /// <see cref="IdentifyingFlag"/>. /// </summary> /// <param name="parms"></param> /// <returns></returns> public NameValueCollection GetProperties(JobParameters parms) { if (parms == null || parms.IsEmpty()) { return new NameValueCollection(); } IDictionary<string, JobParameter> parameters = parms.GetParameters(); NameValueCollection result = new NameValueCollection(); foreach (KeyValuePair<string, JobParameter> entry in parameters) { string key = entry.Key; JobParameter jobParameter = entry.Value; Object value = jobParameter.Value; if (value != null) { key = (!jobParameter.Identifying ? NonIdentifyingFlag : "") + key; if (jobParameter.Type == JobParameter.ParameterType.Date) { result.Set(key + DateType, string.Format(_dateFormat, value)); } else if (jobParameter.Type == JobParameter.ParameterType.Long) { result.Set(key + LongType, string.Format(_numberFormat, value)); } else if (jobParameter.Type == JobParameter.ParameterType.Double) { result.Set(key + DoubleType, string.Format(_decimalFormat, (double)value)); } else { result.Set(key, "" + value); } } } return result; }