private static bool IsEmpty(ISampleEdit sample, SampleTypes sampleType) { switch (sampleType) { case SampleTypes.Number: return sample.SampleNumeric == null; case SampleTypes.Boolean: return sample.SampleBoolean == null; case SampleTypes.Alphanumeric: return string.IsNullOrEmpty(sample.SampleAlphanumeric); default: throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "The sample type {0} is not supported.", sampleType)); } }
private void UpdateSample(ISampleEdit sample, SampleTypes sampleType) { switch (sampleType) { case SampleTypes.Number: sample.SampleNumeric = SafeTypeConverter.Convert<double?>(NewValue); break; case SampleTypes.Boolean: sample.SampleBoolean = SafeTypeConverter.Convert<bool?>(NewValue); break; case SampleTypes.Alphanumeric: sample.SampleAlphanumeric = SafeTypeConverter.Convert<string>(NewValue); break; default: throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "The sample type {0} is not supported.", sampleType)); } }
private static void ExtractSample(SampleModel item, ISampleEdit childModel) { childModel.Id = item.Id; childModel.ItemId = item.ItemId; childModel.Label = item.Label; childModel.SampleAlphanumeric = item.SampleAlphanumeric; childModel.SampleNumeric = item.SampleNumeric; childModel.SampleBoolean = item.SampleBoolean; childModel.SampleType = item.SampleType; childModel.LowerSpecLimit = item.LowerSpecLimit; childModel.UpperSpecLimit = item.UpperSpecLimit; }
/// <summary> /// Updates the specified sample. /// </summary> /// <param name="dataContext"> /// The data context. /// </param> /// <param name="sample"> /// The sample. /// </param> public void Update(IDataContext dataContext, ISampleEdit sample) { if (sample == null) throw new ArgumentNullException("sample"); var value = GetValue(dataContext); if (IsKey && !IsValidKey(value)) throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid value in key field \"{0}\".", FieldName)); Property.SetValue(sample, value); }
private static bool IsEmpty(ISampleEdit sample) { return sample.SampleNumeric == null && sample.SampleBoolean == null && string.IsNullOrEmpty(sample.SampleAlphanumeric); }
private void UpdateSample(IDataContext dataContext, ISampleEdit sample) { foreach (var valueMapping in ChildMappings) { valueMapping.Update(dataContext, sample); } }
private static bool IsMatch(ISampleEdit sample, IEnumerable<ColumnFilter> filters) { return filters.All(filter => AreEqual(sample.GetValueByPropertyName(filter.ColumnName), filter.Value)); }