コード例 #1
0
        protected void CheckPath(IUsingFormula entity, IObjectPath objectPathToCheck, ResolveErrorBehavior resolveErrorBehavior)
        {
            var builder            = _buildConfiguration.BuilderFor(entity);
            var objectWithError    = builder ?? entity;
            var entityAbsolutePath = _objectPathFactory.CreateAbsoluteObjectPath(entity).ToString();
            var entityType         = _objectTypeResolver.TypeFor(entity);

            if (containsKeyWords(objectPathToCheck))
            {
                addNotificationType(NotificationType.Error, objectWithError, Validation.PathContainsReservedKeywords(entity.Name, entityType, entityAbsolutePath, objectPathToCheck.ToPathString()));
                return;
            }

            //found, we continue
            if (objectPathToCheck.Resolve <IFormulaUsable>(entity) != null)
            {
                return;
            }

            string message = Validation.ErrorUnableToFindReference(entity.Name, entityType, entityAbsolutePath, objectPathToCheck.ToPathString());

            if (resolveErrorBehavior == ResolveErrorBehavior.Error)
            {
                addNotificationType(NotificationType.Error, objectWithError, message);
            }
            else
            {
                var parent = entity.ParentContainer;
                parent?.RemoveChild(entity);

                if (resolveErrorBehavior == ResolveErrorBehavior.Delete)
                {
                    return;
                }

                addNotificationType(NotificationType.Warning, objectWithError, message);
            }
        }