Пример #1
0
 public static IBusinessRule FileExists <T>(Expression <Func <T, string> > property)
 {
     return(CreateRule.For <T>()
            .Property(property)
            .WithRule((item, file) => FileHelper.FileExists(file))
            .WithError((item, file) => Validation.FileDoesNotExist(file)));
 }
Пример #2
0
 private IBusinessRule createTargetHasToBeSetRule()
 {
     return(CreateRule.For <EventAssignmentBuilderDTO>()
            .Property(x => x.ChangedEntityPath)
            .WithRule((dto, path) => !path.IsNullOrEmpty())
            .WithError(AppConstants.Validation.ChangedEntityNotSet));
 }
Пример #3
0
 public static IBusinessRule NonEmptyRule <T>(Expression <Func <T, string> > property, string error = Validation.ValueIsRequired)
 {
     return(CreateRule.For <T>()
            .Property(property)
            .WithRule((o, v) => v.StringIsNotEmpty())
            .WithError(error));
 }
 public static IEnumerable <IBusinessRule> All()
 {
     yield return(CreateRule.For <DTOValuePoint>()
                  .Property(x => x.XValue)
                  .WithRule(cannotRepeat)
                  .WithError((dto, timeValue) => AppConstants.Validation.XDimensionColumnMustNotHaveRepeatedValues(dto._tableFormulaDTO.XDisplayName)));
 }
Пример #5
0
 private IBusinessRule moleuleNameShouldBePresentInProjectRule()
 {
     return(CreateRule.For <ApplicationBuilderDTO>()
            .Property(x => x.MoleculeName)
            .WithRule((dto, moleculeName) => _getMoleculeNames().Contains(moleculeName))
            .WithError(AppConstants.Exceptions.AppliedMoleculeNotInProject));
 }
 private static IBusinessRule notEmptyTransportNameRule()
 {
     return(CreateRule.For <TransporterMoleculeContainerDTO>()
            .Property(x => x.TransportName)
            .WithRule((dto, name) => !name.Trim().IsNullOrEmpty())
            .WithError(AppConstants.Validation.EmptyTransportName));
 }
Пример #7
0
 public static IBusinessRule ParameterIsValid()
 {
     return(CreateRule.For <IParameterDTO>()
            .Property(p => p.Value)
            .WithRule((p, value) => rulesFor(p, value).IsEmpty)
            .WithError((p, value) => rulesFor(p, value).Message));
 }
Пример #8
0
 public static IBusinessRule ParameterIsValid <TParameterContainer, TProperty>(Expression <Func <TParameterContainer, TProperty> > parameterValue, Func <TParameterContainer, IParameterDTO> parmeterDelegate)
 {
     return(CreateRule.For <TParameterContainer>()
            .Property(parameterValue)
            .WithRule((parameterContainer, value) => rulesFor(parmeterDelegate(parameterContainer), value).IsEmpty)
            .WithError((parameterContainer, value) => rulesFor(parmeterDelegate(parameterContainer), value).Message));
 }
 private IBusinessRule createNonEmptyNameRule()
 {
     return(CreateRule.For <FormulaInfoDTO>()
            .Property(x => x.Name)
            .WithRule((dto, name) => dto.nameIsValid(name))
            .WithError(AppConstants.Validation.EmptyName));
 }
Пример #10
0
 private IBusinessRule createRelativeContainerPathNotEmptyRule()
 {
     return(CreateRule.For <ApplicationMoleculeBuilderDTO>()
            .Property(x => x.RelativeContainerPath)
            .WithRule((dto, path) => !path.IsNullOrEmpty())
            .WithError(AppConstants.Validation.RelativeContainerPathNotSet));
 }
 private static IBusinessRule uniqueTransportNameRule()
 {
     return(CreateRule.For <TransporterMoleculeContainerDTO>()
            .Property(x => x.TransportName)
            .WithRule((dto, name) => dto.IsNameUnique(name))
            .WithError(AppConstants.Validation.TransportNameAllreadyUsed));
 }
Пример #12
0
 public static IBusinessRule NotNull <T, U>(Expression <Func <T, U> > property) where U : class
 {
     return(CreateRule.For <T>()
            .Property(property)
            .WithRule((o, u) => u != null)
            .WithError(Validation.ValueIsRequired));
 }
Пример #13
0
 private IBusinessRule warningRule(string warning)
 {
     return(CreateRule.For <IParameter>()
            .Property(item => item.Value)
            .WithRule((param, value) => false)
            .WithError((param, value) => warning));
 }
Пример #14
0
            private static IBusinessRule mustHaveAllPreviousPathElementsSet(Expression <Func <StartValueDTO <T>, string> > propertyToCheck)
            {
                var index = getPathIndex(propertyToCheck);

                return(CreateRule.For <StartValueDTO <T> >()
                       .Property(propertyToCheck).WithRule((dto, pathElement) => areAllPreviousPathElementsNonEmpty(dto, pathElement, index))
                       .WithError((dto, pathElement) => AppConstants.Validation.CannotSetPathElementWhenPreviousElementsAreEmpty));
            }
Пример #15
0
            private static IBusinessRule mustNotAlreadyContainStartValue(Expression <Func <StartValueDTO <T>, string> > propertyToCheck)
            {
                var index = getPathIndex(propertyToCheck);

                return(CreateRule.For <StartValueDTO <T> >()
                       .Property(propertyToCheck)
                       .WithRule((dto, pathElement) => noDuplicatesInBuildingBlockRule(dto, pathElement, index))
                       .WithError((dto, pathElement) => AppConstants.Validation.PathIsIdenticalToExistingPath(newPathWithReplacement(dto, pathElement, index))));
            }
Пример #16
0
 private static IBusinessRule createMinLessThanOrEqualToMaxRuleForAxis() => CreateRule.For <Axis>()
 .Property(axis => axis.Min)
 .WithRule((axis, value) => !value.HasValue || !axis.Max.HasValue || axis.Max >= value)
 .WithError((axis, value) => Validation.AxisMinMustBeLessThanOrEqualToAxisMax(axis.Max));
Пример #17
0
 private static IBusinessRule renameMustNotCauseCollision()
 {
     return(CreateRule.For <StartValueDTO <T> >()
            .Property(x => x.Name).WithRule(namedOnlyElementDoesNotExist)
            .WithError((dto, name) => AppConstants.Validation.NameIsAlreadyUsedInThisContainer(dto.ContainerPath.ToString(), name)));
 }
Пример #18
0
 private static IBusinessRule createMaxGreaterThanOrEqualToMinRuleForAxis() => CreateRule.For <Axis>()
 .Property(axis => axis.Max)
 .WithRule((axis, value) => !value.HasValue || !axis.Min.HasValue || value >= axis.Min)
 .WithError((axis, value) => Validation.AxisMaxMustBeGreaterThanOrEqualToAxisMin(axis.Min));
Пример #19
0
 private static IBusinessRule createMaxGreaterThanZeroRuleForLogarithmicAxis() => CreateRule.For <Axis>()
 .Property(axis => axis.Max)
 .WithRule((axis, value) => !value.HasValue || axis.Scaling != Scalings.Log || value > 0F)
 .WithError((axis, value) => Validation.LogAxisMaxMustBeGreaterThanZero);