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)); }
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; }
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)); }
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); }
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); }
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); }
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);
public void InvertItemValidity <T>(IHaveToken <T> token, string file, int line, string member) => store.ItemInversions.Add(token.Token, DiagInfo.Create(file, line, member));
IFor <T> IRegister.For <T>(IHaveToken <T> haveToken) => reg.For(haveToken);
public static IEnumerable <Tuple <IFailure, T> > Candidates <T>(this IMatcher matcher, IHaveToken <T> token) => matcher.Candidates(token.Token);
public static IEnumerable <T> BestCandidates <T>(this IMatcher matcher, IHaveToken <T> token) => matcher.BestCandidates(token.Token);
public static IEnumerable <IResolutionContext <T> > All <T>(this IMatcher matcher, IHaveToken <T> token) => matcher.All(token.Token);
public static T Value <T>(this IMatcher matcher, IHaveToken <T> token) => matcher.Value(token.Token);
IForToken <T1, T2> IForToken <T1> .For <T2>(IHaveToken <T2> haveToken) => Inner.For(haveToken);
public CollectionValueDependency(IHaveToken <TItem> haveToken) { this.haveToken = haveToken; }
public SingleValueDependency(IHaveToken <TItem> haveToken) { this.haveToken = haveToken; }
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); }
IForToken <T> ITokenRegister.For <T>(IHaveToken <T> haveToken) => inner.For(haveToken);
IFor <IEnumerable <T> > IRegister.ForCollection <T>(IHaveToken <T> haveToken) => reg.ForCollection(haveToken);
IForToken <IEnumerable <T> > ITokenRegister.ForCollection <T>(IHaveToken <T> haveToken) => inner.ForCollection(haveToken);