コード例 #1
0
        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));
            }
        }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
ファイル: ProcessController.cs プロジェクト: mparsin/Elements
 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;
 }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
 private static bool IsEmpty(ISampleEdit sample)
 {
     return sample.SampleNumeric == null && sample.SampleBoolean == null && string.IsNullOrEmpty(sample.SampleAlphanumeric);
 }
コード例 #6
0
 private void UpdateSample(IDataContext dataContext, ISampleEdit sample)
 {
     foreach (var valueMapping in ChildMappings)
     {
         valueMapping.Update(dataContext, sample);
     }
 }
コード例 #7
0
 private static bool IsMatch(ISampleEdit sample, IEnumerable<ColumnFilter> filters)
 {
     return filters.All(filter => AreEqual(sample.GetValueByPropertyName(filter.ColumnName), filter.Value));
 }