Пример #1
0
 public LazyConverter(TTo to, Func <TTo, TFrom> backwardConvert)
 {
     backwardConvert.EnsureNotNull(nameof(backwardConvert));
     //
     _toHolder        = new ValueHolderClass <TTo>(value: to);
     _fromHolder      = null;
     _backwardConvert = backwardConvert;
     _convert         = null;
 }
Пример #2
0
 public LazyConverter(TFrom from, Func <TFrom, TTo> convert)
 {
     convert.EnsureNotNull(nameof(convert));
     //
     _toHolder        = null;
     _fromHolder      = new ValueHolderClass <TFrom>(value: from);
     _backwardConvert = null;
     _convert         = convert;
 }
Пример #3
0
 public static void Dispose <T>(this ValueHolderClass <T> holder, Exception exception = default)
     where T : IDisposable
 {
     if (!(holder is null))
     {
         try {
             holder.ValueExceptionTolerant?.Dispose();
         }
         catch (Exception secondException) {
             if (exception is null)
             {
                 throw;
             }
             else
             {
                 throw new AggregateException(exception, secondException);
             }
         }
     }
 }