Пример #1
0
        public ResultAppValue(TValue value, IEnumerable <IErrorApplication> errors, IErrorApplication errorNull = null)
            : this(errors)
        {
            Errors = value switch
            {
                null when errorNull != null => Errors.Concat(errorNull).ToList(),
                null => throw new ArgumentNullException(nameof(value)),
                      _ => Errors
            };

            Value = value;
        }
Пример #2
0
 /// <summary>
 /// Преобразовать внутренний класс ошибок библиотеки в основной
 /// </summary>
 public static IErrorCommon ToErrorConverting(this IErrorApplication errorApplication) =>
 ErrorApplicationConverter.ToErrorConverting(errorApplication);
 /// <summary>
 /// Преобразовать коллекцию ответов в ответ с коллекцией
 /// </summary>
 public static IResultAppCollection <T> ToResultCollection <T>(this IResultAppValue <IEnumerable <T> > @this, IErrorApplication errorNull = null) =>
 @this != null
         ? new ResultAppCollection <T>(@this.OkStatus
                                          ? @this.Value
                                          : @this.Value ?? Enumerable.Empty <T>(),
                                       @this.Errors, errorNull)
         : throw new ArgumentNullException(nameof(@this));
 /// <summary>
 /// Преобразовать коллекцию ответов в ответ с коллекцией
 /// </summary>
 public static IResultAppCollection <T> ToResultCollection <T>(this IEnumerable <IResultAppCollection <T> > @this, IErrorApplication errorNull = null) =>
 @this != null
         ? @this.Aggregate((IResultAppCollection <T>) new ResultAppCollection <T>(), (resultCollectionMain, resultCollection) =>
                           resultCollectionMain.ConcatResult(resultCollection)).
 WhereBad(result => result.Value.Count > 0,
          badFunc: result => errorNull != null
                                        ? new ResultAppCollection <T>(errorNull)
                                        : result)
         : throw new ArgumentNullException(nameof(@this));
 public ResultApplication(IErrorApplication errorConverting)
     : this(errorConverting.AsEnumerable())
 {
 }
Пример #6
0
 public ResultAppValue(IErrorApplication error)
     : this(error.AsEnumerable())
 {
 }
Пример #7
0
 public ResultAppValue(TValue value, IErrorApplication errorNull = null)
     : this(value, Enumerable.Empty <IErrorApplication>(), errorNull)
 {
 }
 /// <summary>
 /// Найти элементы в словаре штампа по ключам
 /// </summary>
 public IResultAppCollection <TElement> FindElementsInStamp <TElement>(IEnumerable <string> fieldsSearch, IErrorApplication errorNull)
     where TElement : IElementMicrostation =>
 StampSubControls.
 ResultValueOk(subElements => FindElementsInFields <TElement>(subElements, fieldsSearch)).
 ToResultCollection().
 ResultValueContinue(fields => fields.Count > 0,
                     okFunc : fields => fields,
                     badFunc : fields => errorNull).
 ToResultCollection();
Пример #9
0
 /// <summary>
 /// Преобразовать внутренний класс ошибок библиотеки в основной
 /// </summary>
 public static IErrorCommon ToErrorConverting(IErrorApplication errorApplication) =>
 (errorApplication != null) ?
 new ErrorCommon(ToFileConvertErrorType(errorApplication.ErrorMicrostationType), errorApplication.Description) :
 throw new ArgumentNullException(nameof(errorApplication));
Пример #10
0
        public ResultAppCollection(IEnumerable <T> collection, IEnumerable <IErrorApplication> errors, IErrorApplication errorNull = null)
            : base(errors)
        {
            var collectionList = collection?.ToList();

            Errors = collectionList switch
            {
                null when errorNull != null => Errors.Concat(errorNull).ToList(),
                null => throw new ArgumentNullException(nameof(collection)),
                      _ => Errors
            };

            Value = collectionList ?? new List <T>();
        }
Пример #11
0
 public ResultAppCollection(IEnumerable <T> collection, IErrorApplication errorNull = null)
     : this(collection, Enumerable.Empty <IErrorApplication>(), errorNull)
 {
 }
Пример #12
0
 public ResultAppCollection(IErrorApplication error)
     : this(Enumerable.Empty <T>(), error.AsEnumerable())
 {
 }