コード例 #1
0
        /// <summary>
        /// Initialize a `DataReaderLoadResult` using the state of another one.
        /// </summary>
        protected DataReaderLoadResult(DataReaderLoadResult <T> fromOtherResult)
        {
            if (fromOtherResult == null)
            {
                throw new ArgumentNullException(nameof(fromOtherResult));
            }

            if (fromOtherResult.IsError)
            {
                IsError        = true;
                ExceptionInfo  = fromOtherResult.ExceptionInfo;
                _value         = default(T);         // can't use fromOtherResult.Value because it will throw an exception
                IsValuePresent = false;
            }
            else
            {
                _value         = fromOtherResult.Value;
                IsValuePresent = fromOtherResult.IsValuePresent;
                IsError        = false;
            }
        }
コード例 #2
0
        private DataReaderLoadResult <T> GetAdjustedReadResult(DataReaderLoadResult <T> result)
        {
            // Check for error condition
            if (result.IsError && CheckMode(DefaultValueDataPersisterDecoratorMode.ReadErrorToCustomDefault))
            {
                return(new DataReaderLoadResult <T>(_customDefaultValue));
            }

            // Check for empty condition
            if (!result.IsValuePresent && CheckMode(DefaultValueDataPersisterDecoratorMode.ReadEmptyToCustomDefault))
            {
                return(new DataReaderLoadResult <T>(_customDefaultValue));
            }

            // Check for value present condition where condition == default(T) -- using supplied EqualityComparer, obviously
            if (CheckMode(DefaultValueDataPersisterDecoratorMode.ReadDefaultToCustomDefault) && _comparer.Equals(result.Value, default(T)))
            {
                return(new DataReaderLoadResult <T>(_customDefaultValue));
            }

            // The original result could be used "as-is"
            return(result);
        }
コード例 #3
0
 /// <summary>
 /// Create an instance from a load result
 /// </summary>
 public DataPersisterTransactionContext(DataReaderLoadResult <T> fromResult) : base(fromResult)
 {
 }
コード例 #4
0
 /// <summary>
 /// ctor using a DataReaderLoadResult<T> as result state
 /// </summary>
 public DataPersisterUpdateResult(DataReaderLoadResult <T> result, bool isUpdated) : base(result)
 {
     IsUpdated = isUpdated;
 }