Example #1
0
 public static void DepartmentHasType(this ITokenRegister register,
                                      IHaveToken <Department> department,
                                      DepartmentType departmentType)
 {
     register.For(department)
     .IsTrue(dep => dep.Type == departmentType);
 }
 public static void DepartmentHasType(this ITokenRegister register,
     IHaveToken<Department> department,
     DepartmentType departmentType)
 {
     register.For(department)
             .IsTrue(dep => dep.Type == departmentType);
 }
 public static void DepartmentHasProjectWithBudget(this ITokenRegister register,
     IHaveToken<Department> department,
     int budget)
 {
     var project = register.For(department)
                           .Exists(dep => dep.Projects);
     register.For(project)
             .IsTrue(proj => proj.Budget >= budget);
 }
        public static void InsuranceHasFederalTax(this ITokenRegister register, IHaveToken <Insurance> insurance)
        {
            var taxToken = register
                           .For(insurance)
                           .Exists(x => x.Taxes);

            register.For(taxToken)
            .IsTrue(x => x.Type == TaxType.Federal);
        }
 public static void AssignmentHasMorePeopleThanAssignments
     (this ITokenRegister reg,
      IHaveToken<Assignment> assignmentToken,
      IHaveToken<Assignment> assignmentsToken)
 {
     reg.For(assignmentToken)
        .ForCollection(assignmentsToken)
        .IsTrue((assignment, assignments) => assignment.HeadCount > assignments.Sum(y => y.HeadCount));
 }
        public IFor <T> For <T>(IHaveToken <T> haveToken)
        {
            if (haveToken == null)
            {
                throw new ArgumentNullException(nameof(haveToken));
            }

            return(GetRegistration1(store, new SingleValueDependency <T>(haveToken), groupToken, priority));
        }
        public IFor <IEnumerable <T> > ForCollection <T>(IHaveToken <T> haveToken)
        {
            if (haveToken == null)
            {
                throw new ArgumentNullException(nameof(haveToken));
            }

            return(GetRegistration1(store, new CollectionValueDependency <T>(haveToken), groupToken, priority));
        }
 public static void AssignmentHasMorePeopleThanAssignments
     (this ITokenRegister reg,
     IHaveToken <Assignment> assignmentToken,
     IHaveToken <Assignment> assignmentsToken)
 {
     reg.For(assignmentToken)
     .ForCollection(assignmentsToken)
     .IsTrue((assignment, assignments) => assignment.HeadCount > assignments.Sum(y => y.HeadCount));
 }
Example #9
0
        public static void DepartmentHasProjectWithBudget(this ITokenRegister register,
                                                          IHaveToken <Department> department,
                                                          int budget)
        {
            var project = register.For(department)
                          .Exists(dep => dep.Projects);

            register.For(project)
            .IsTrue(proj => proj.Budget >= budget);
        }
 public static IHaveToken<Employee> DepartmentHasEmployeeOfType(this ITokenRegister register,
     IHaveToken<Department> department,
     EmploymentType employmentType)
 {
     var employee = register.For(department)
                            .Exists(dep => dep.Employees);
     register.For(employee)
             .IsTrue(emp => emp.EmploymentType == employmentType);
     return employee;
 }
Example #11
0
        public IFor <T1, IEnumerable <T2> > ForCollection <T2>(IHaveToken <T2> haveToken)
        {
            if (haveToken == null)
            {
                throw new ArgumentNullException(nameof(haveToken));
            }

            var dependency2 = new CollectionValueDependency <T2>(haveToken);

            return(GetRegistration2(store, dependency, dependency2, groupToken, priority));
        }
Example #12
0
        public static IHaveToken <Employee> DepartmentHasEmployeeOfType(this ITokenRegister register,
                                                                        IHaveToken <Department> department,
                                                                        EmploymentType employmentType)
        {
            var employee = register.For(department)
                           .Exists(dep => dep.Employees);

            register.For(employee)
            .IsTrue(emp => emp.EmploymentType == employmentType);
            return(employee);
        }
Example #13
0
        public void WhenINeedDepartmentToEitherBeTypeOrHaveEmployeeOrHaveProjectWithBudjetOrMore(string departmentName,
                                                                                                 DepartmentType departmentType,
                                                                                                 EmploymentType employeeType,
                                                                                                 int amount)
        {
            IHaveToken <Employee> employee = null;
            var department = context.GetToken <Department>(departmentName);

            context.Either(x => x.DepartmentHasType(department, departmentType),
                           x => employee = x.DepartmentHasEmployeeOfType(department, employeeType),
                           x => x.DepartmentHasProjectWithBudget(department, amount));
            context.Storage.Set(employee);
        }
Example #14
0
        public void WhenINeedDepartmentToNOTHaveAllThreeTypeEmployeeProjectBudjetOrMore(string departmentName,
                                                                                        DepartmentType departmentType,
                                                                                        EmploymentType employeeType,
                                                                                        int amount)
        {
            IHaveToken <Employee> employee = null;
            var department = context.GetToken <Department>(departmentName);

            context.Not(x =>
            {
                x.DepartmentHasType(department, departmentType);
                employee = x.DepartmentHasEmployeeOfType(department, employeeType);
                x.DepartmentHasProjectWithBudget(department, amount);
            });
            context.Storage.Set(employee);
        }
Example #15
0
 public void SetToken <T>(string name, IHaveToken <T> haveToken, string file, int line, string member)
 => store.SaveToken(DiagInfo.Create(file, line, member), name, haveToken.Token);
Example #16
0
 public void InvertItemValidity <T>(IHaveToken <T> token, string file, int line, string member)
 => store.ItemInversions.Add(token.Token, DiagInfo.Create(file, line, member));
Example #17
0
 IFor <T> IRegister.For <T>(IHaveToken <T> haveToken) => reg.For(haveToken);
Example #18
0
 public static IEnumerable <Tuple <IFailure, T> > Candidates <T>(this IMatcher matcher, IHaveToken <T> token)
 => matcher.Candidates(token.Token);
Example #19
0
 public static IEnumerable <T> BestCandidates <T>(this IMatcher matcher, IHaveToken <T> token)
 => matcher.BestCandidates(token.Token);
Example #20
0
 public static IEnumerable <IResolutionContext <T> > All <T>(this IMatcher matcher, IHaveToken <T> token)
 => matcher.All(token.Token);
Example #21
0
 public static T Value <T>(this IMatcher matcher, IHaveToken <T> token)
 => matcher.Value(token.Token);
Example #22
0
 IForToken <T1, T2> IForToken <T1> .For <T2>(IHaveToken <T2> haveToken) => Inner.For(haveToken);
 public CollectionValueDependency(IHaveToken <TItem> haveToken)
 {
     this.haveToken = haveToken;
 }
Example #24
0
 public SingleValueDependency(IHaveToken <TItem> haveToken)
 {
     this.haveToken = haveToken;
 }
Example #25
0
 IForToken <T1, IEnumerable <T2> > IForToken <T1> .ForCollection <T2>(IHaveToken <T2> haveToken) => Inner.ForCollection(haveToken);
 public static void InsuranceHasMaximumDependents(this ITokenRegister register, IHaveToken <Insurance> insurance)
 {
     register.For(insurance)
     .IsTrue(x => x.MaximumDependents > 0);
 }
        public static void InsuranceHasDependentAssignment(this ITokenRegister register, IHaveToken <Insurance> insurance)
        {
            var assignmentToken = register
                                  .For(insurance)
                                  .Exists(x => x.Assignments);

            register.For(assignmentToken)
            .IsTrue(x => x.Type == AssignmentType.Dependent);
        }
Example #28
0
 IForToken <T> ITokenRegister.For <T>(IHaveToken <T> haveToken) => inner.For(haveToken);
Example #29
0
 IFor <IEnumerable <T> > IRegister.ForCollection <T>(IHaveToken <T> haveToken) => reg.ForCollection(haveToken);
Example #30
0
 IForToken <IEnumerable <T> > ITokenRegister.ForCollection <T>(IHaveToken <T> haveToken) => inner.ForCollection(haveToken);