public static void AddError(this ObservableCollection <ShaftSectionFeatureError> source,
                                    ShaftSectionFeatureError newError,
                                    Func <bool> errorCancellationCondition)
        {
            void ResolveCondition()
            {
                bool satisfies = errorCancellationCondition.Invoke();

                if (satisfies)
                {
                    source.Remove(newError);
                    Shaft.ShaftFeaturesErrors.Remove(newError);
                }
            }

            void TryResolve(object sender, PropertyChangedEventArgs args)
            {
                if (sender.Equals(newError.Section) && args.PropertyName != nameof(ShaftSection.NextSection) &&
                    args.PropertyName != nameof(ShaftSection.PreviousSection) &&
                    args.PropertyName != nameof(ShaftSection.FirstLine) &&
                    args.PropertyName != nameof(ShaftSection.SecondLine) &&
                    args.PropertyName != nameof(ShaftSection.ThirdLine) &&
                    args.PropertyName != nameof(ShaftSection.AvailableFirstEdgeFeatures) &&
                    args.PropertyName != nameof(ShaftSection.AvailableSecondEdgeFeatures))
                {
                    ResolveCondition();
                }
            }

            source.Add(newError);
            Shaft.ShaftFeaturesErrors.Add(newError);
            if (newError.Section.IsBore)
            {
                if (newError.Section.BoreFromEdge == BoreFromEdge.FromLeft)
                {
                    Shaft.BoreOnTheLeft.ItemPropertyChanged += TryResolve;
                }
                else
                {
                    Shaft.BoreOnTheRight.ItemPropertyChanged += TryResolve;
                }
            }
            else
            {
                Shaft.Sections.ItemPropertyChanged += TryResolve;
            }

            newError.Feature.PropertyChanged += (sender, args) => ResolveCondition();

            if (newError.Feature is ISectionSubFeature)
            {
                newError.Section.SubFeatures.CollectionChanged += (sender, args) => ResolveCondition();
            }
        }
 public static bool ContainsError(this IEnumerable <ShaftSectionFeatureError> source,
                                  ShaftSectionFeatureError errorToCheck)
 {
     return(source.Contains(errorToCheck));
 }