/// <summary> /// Gets the authorization strategy's NHibernate filter definitions and a functional delegate for determining when to apply them. /// </summary> /// <returns>A read-only list of filter application details to be applied to the NHibernate configuration and mappings.</returns> public IReadOnlyList <FilterApplicationDetails> GetFilters() { var filters = new List <FilterApplicationDetails> { new FilterApplicationDetails( "Namespace", @"(Namespace IS NOT NULL AND Namespace LIKE :Namespace)", @"({currentAlias}.Namespace IS NOT NULL AND {currentAlias}.Namespace LIKE :Namespace)", (c, w, p, jt) => { // Ensure the Namespace parameter is represented as an object array var namespacePrefixes = p["Namespace"] as object[] ?? new [] { p["Namespace"] }; // Combine the namespace filters using OR (only one must match to grant authorization) var namespacesDisjunction = new Disjunction(); foreach (var namespacePrefix in namespacePrefixes) { namespacesDisjunction.Add(Restrictions.Like("Namespace", namespacePrefix)); } // Add the final namespaces criteria to the supplied WHERE clause (junction) w.Add( new AndExpression( Restrictions.IsNotNull("Namespace"), namespacesDisjunction)); }, (t, p) => !DescriptorEntitySpecification.IsEdFiDescriptorEntity(t) && p.HasPropertyNamed("Namespace")), }.AsReadOnly(); return(filters); }
private void FilterContentPublishedCriteria(ICriteria crit, ContentCategory cc, ContentType ct) { crit.Add(Expression.Eq("Category", cc)); crit.Add(Expression.Eq("Type", ct)); crit.Add(Expression.Eq("Status", ContentPublishedStatus.Enabled)); Conjunction c1 = new Conjunction(); c1.Add(Expression.Ge("ScheduleFrom", DateTime.Today)); c1.Add(Expression.IsNull("ScheduleTo")); Conjunction c2 = new Conjunction(); c2.Add(Expression.IsNull("ScheduleFrom")); c2.Add(Expression.IsNull("ScheduleTo")); Conjunction c3 = new Conjunction(); c3.Add(Expression.Ge("ScheduleFrom", DateTime.Today)); c3.Add(Expression.Le("ScheduleTo", DateTime.Today)); Disjunction d = new Disjunction(); d.Add(c1); d.Add(c2); d.Add(c3); crit.Add(d); crit.AddOrder(new Order("CreatedOn", false)); crit.AddOrder(new Order("ScheduleFrom", false)); }
protected override Expression VisitTypeIs(TypeBinaryExpression expr) { var visitor = new MemberNameVisitor(rootCriteria); visitor.Visit(expr); string memberName = visitor.MemberName + ".class"; var metaData = session.SessionFactory.GetClassMetadata(expr.TypeOperand); if (metaData.HasSubclasses) { //make sure to include any subtypes var disjunction = new Disjunction(); foreach (string entityName in ((IEntityPersister)metaData).EntityMetamodel.SubclassEntityNames) { var metadata = session.SessionFactory.GetClassMetadata(entityName); disjunction.Add(Property.ForName(memberName).Eq(metadata.GetMappedClass(EntityMode.Poco))); } visitor.CurrentCriteria.Add(disjunction); } else { visitor.CurrentCriteria.Add(Property.ForName(memberName).Eq(expr.TypeOperand)); } return(expr); }
public static Any Of(IEvaluatable argument) { var newJunction = new Disjunction(); JunctionHelper.AddArgumentToJunction <Disjunction>(newJunction, argument); return(new Any(newJunction)); }
public bool UpdatePlayer(PlayerPatchDto dto, Guid id) { var player = Session.Get <PlayerModel>(id); if (player == null) { return(false); } var groupDisjunction = new Disjunction(); foreach (var groupName in dto.GroupNames) { groupDisjunction.Add(Restrictions.InsensitiveLike(Projections.Property <GroupModel>(p => p.Players), dto.GroupNames)); } var groups = Session.QueryOver <GroupModel>() .Where(groupDisjunction).Future().ToList(); using (var transaction = Session.BeginTransaction()) { player.FirstName = dto.FirstName; player.LastName = dto.LastName; player.Email = dto.Email; player.Rating = dto.Rating; player.IsActive = dto.IsActive; player.Groups = groups; Session.Update(player); transaction.Commit(); } return(true); }
public ICriteria SearchCriteria(string info, DateTime?fromDate, DateTime?toDate, ImportStatus?status) { ICriteria crit = GetCriteria(); if (!string.IsNullOrEmpty(info)) { Disjunction d = new Disjunction(); d.Add(Restrictions.InsensitiveLike("Description", info, MatchMode.Anywhere)); d.Add(Restrictions.InsensitiveLike("File", info, MatchMode.Anywhere)); crit.Add(d); } if (fromDate != null) { crit.Add(Expression.Ge("DateImported", fromDate)); } if (toDate != null) { crit.Add(Expression.Le("DateImported", toDate)); } if (status != null) { crit.Add(Expression.Eq("ImportStatus", status)); } return(crit); }
/// <summary> /// Ruft Seitenweise die beantragten Nutzer der Plattform ab. /// </summary> /// <param name="pageable">Informationen über aufzurufende Seite und Seitengröße</param> /// <param name="searchTerm"></param> /// <returns></returns> public IPage <ProposedUser> FindProposedUser(IPageable pageable, string searchTerm) { Require.NotNull(pageable, "pageable"); Action <ICriteria> criterionsDelegate = delegate(ICriteria criteria) { if (!string.IsNullOrEmpty(searchTerm)) { /*Die Prüfung ob die Properties die Suchzeichenfolge enthalten per Oder verknüpfen*/ Disjunction orCriterias = new Disjunction(); orCriterias.Add(Restrictions.Like(Objects.GetPropertyName <ProposedUser>(user => user.UserName), searchTerm, MatchMode.Anywhere)); orCriterias.Add(Restrictions.Like(Objects.GetPropertyName <ProposedUser>(user => user.Email), searchTerm, MatchMode.Anywhere)); orCriterias.Add(Restrictions.Like(Objects.GetPropertyName <ProposedUser>(user => user.FirstName), searchTerm, MatchMode.Anywhere)); orCriterias.Add(Restrictions.Like(Objects.GetPropertyName <ProposedUser>(user => user.LastName), searchTerm, MatchMode.Anywhere)); criteria.Add(orCriterias); } }; /*Sortierung hinzufügen*/ Action <ICriteria> ordersDelegate = delegate(ICriteria criteria) { criteria.AddOrder(Order.Asc("LastName")); criteria.AddOrder(Order.Asc("FirstName")); }; return(Find(pageable, criterionsDelegate, ordersDelegate)); }
public void AddRootCondition() { Disjunction dis = new Disjunction(); dis.AddRootCondition(); and.Add(dis); }
private ICriteria ListSearchCriteria(string search, Type type, CategoryBase parent) { ICriteria crit = GetCriteria(); if (type != null) { crit = NHibernateSession.CreateCriteria(type); } if (!string.IsNullOrEmpty(search)) { Disjunction d = new Disjunction(); d.Add(Expression.InsensitiveLike("Name", search, MatchMode.Anywhere)); d.Add(Expression.InsensitiveLike("Description", search, MatchMode.Anywhere)); d.Add(Expression.InsensitiveLike("NameEnglish", search, MatchMode.Anywhere)); d.Add(Expression.InsensitiveLike("DescripionEnglish", search, MatchMode.Anywhere)); crit.Add(d); } if (parent != null) { crit.Add(Expression.Eq("Parent", parent)); } return(crit); }
private ICriteria ListLevelOnePagesCriteria(string search, CatalogPage parent, CategoryPageStatus?status) { ICriteria crit = GetCriteria(); if (!string.IsNullOrEmpty(search)) { Disjunction d = new Disjunction(); d.Add(Expression.InsensitiveLike("Name", search, MatchMode.Anywhere)); d.Add(Expression.InsensitiveLike("Description", search, MatchMode.Anywhere)); d.Add(Expression.InsensitiveLike("NameEnglish", search, MatchMode.Anywhere)); d.Add(Expression.InsensitiveLike("DescripionEnglish", search, MatchMode.Anywhere)); crit.Add(d); } if (parent != null) { crit.Add(Expression.Eq("Parent", parent)); } if (status != null) { crit.Add(Expression.Eq("CategoryPageStatus", status)); } DetachedCriteria levelOneCriteria = DetachedCriteria.For <CatalogPage>().SetProjection(Projections.Property("ID")) .Add(Expression.IsNull("Parent")); ICriterion levelOneSubquery = Subqueries.PropertyIn("Parent", levelOneCriteria); crit.Add(levelOneSubquery); return(crit); }
public void IsClosed_CreateBetaRuleFromDisjunctionWithAdditionalLiteralsContradictingBothBranches_ExpectedParentClosed() { // Arrange Disjunction disjunction = (Disjunction)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Disjunction.SYMBOL); Negation negatedLeftLiteral = new Negation(); negatedLeftLiteral.LeftSuccessor = disjunction.LeftSuccessor; Negation negatedRightLiteral = new Negation(); negatedRightLiteral.LeftSuccessor = disjunction.RightSuccessor; HashSet <Proposition> propositions = new HashSet <Proposition>() { negatedLeftLiteral, disjunction, negatedRightLiteral }; // Act SemanticTableauxElement betaRuleElement = new SemanticTableauxElement(propositions); bool parentClosed = betaRuleElement.IsClosed(); // Assert parentClosed.Should().BeTrue("Because the beta rule contains two contradictions, each of which should close one of the branches"); }
// By dumb luck this could fail if it generated two identical successors for the disjunction! public void Constructor_CreateAlphaRuleFromNegationOfDisjunctionOfLiterals_SetOfLengthTwoReturnedWithTwoNegatedLiterals() { // Arrange Disjunction disjunction = (Disjunction)PropositionGenerator.CreateBinaryConnectiveWithRandomSymbols(Disjunction.SYMBOL); Negation negatedDisjunction = new Negation(); negatedDisjunction.LeftSuccessor = disjunction; HashSet <Proposition> propositions = new HashSet <Proposition>() { negatedDisjunction }; SemanticTableauxElement alphaRuleElement = new SemanticTableauxElement(propositions); SemanticTableauxElement child = alphaRuleElement.LeftChild; // Act HashSet <Proposition> childPropositions = child.Propositions; int actualNumberOfLiterals = childPropositions.Count; int expectedNumberOfLiterals = 2; // Assert actualNumberOfLiterals.Should().Be(expectedNumberOfLiterals, "Because a disjunction of two literals was given"); foreach (Proposition p in childPropositions) { p.Should().BeOfType <Negation>("Because for this alpha rule, the negation of both literals is returned"); } }
public void NodeLabel_CreateNodeLabelWithBothChildrenAndNotClosed_ExpectedLabelWithChildrenIncluded() { // Arrange Disjunction disjunction = new Disjunction(); disjunction.LeftSuccessor = new Proposition('B'); disjunction.RightSuccessor = new Proposition('R'); HashSet <Proposition> propositions = new HashSet <Proposition>() { disjunction }; SemanticTableauxElement semanticTableauxElement = new SemanticTableauxElement(propositions); semanticTableauxElement.NodeNumber = 1; semanticTableauxElement.LeftChild.NodeNumber = 2; semanticTableauxElement.RightChild.NodeNumber = 3; // Act string actualNodeLabel = semanticTableauxElement.NodeLabel(); string expectedNodeLabel = $"node{semanticTableauxElement.NodeNumber}[ label = \"(B | R)\" ]\n"; expectedNodeLabel += $"node1 -- node2\n"; expectedNodeLabel += $"node{semanticTableauxElement.NodeNumber + 1}[ label = \"B\" ]\n"; expectedNodeLabel += $"node1 -- node3\n"; expectedNodeLabel += $"node{semanticTableauxElement.NodeNumber + 2}[ label = \"R\" ]\n"; // Assert actualNodeLabel.Should().Be(expectedNodeLabel, "Because that's the format required for graphviz plus our own choice of display"); }
public void DisjoinsCriteria() { var spec1 = new IntegerPredicate(i => i == 0); var spec2 = new IntegerPredicate(i => i > 0); var criteria1 = spec1.Criteria; var criteria2 = spec2.Criteria; var disjoinedSpec = new Disjunction<int>(spec1, spec2); var disjoinedCriteria = disjoinedSpec.Criteria; Assert.That(disjoinedCriteria.Body, Is.AssignableTo<BinaryExpression>()); var binary = (BinaryExpression)disjoinedCriteria.Body; Assert.That(binary.NodeType, Is.EqualTo(ExpressionType.OrElse)); Assert.That(binary.Conversion, Is.Null); Assert.That(binary.Left.ToString(), Is.EqualTo(criteria1.Body.ToString())); Assert.That(binary.Right.ToString(), Is.EqualTo(criteria2.Body.ToString())); Assert.That(binary.Method, Is.Null); Assert.That(binary.IsLifted, Is.False); Assert.That(binary.IsLiftedToNull, Is.False); ExpressionWriter.Write(disjoinedCriteria); }
protected void btnDelete_Click(object sender, EventArgs e) { try { string[] idlst = txtIdListHidden.Value.Split(new char[] { '|' }); ObjectQuery oq = new ObjectQuery(); Disjunction dis = new Disjunction(); foreach (string id in idlst) { dis.Add(Expression.Eq("Id", id)); } oq.AddCriterion(dis); IList <PaymentOrderDetial> list = model.QueryDetial(oq); if (model.Delete(list as IList)) { UtilClass.MessageBox(this, "删除成功!"); GridViewSource1.GetData(); SumMoney(); Clear(); } else { UtilClass.MessageBox(this, "删除失败!"); } } catch (Exception) { UtilClass.MessageBox(this, "操作失误,请重试!"); } }
private static Symbol SpecialSymbol(string str, ref int index) { ++index; if (index >= str.Length) { throw new ArgumentException( $"a tag was expected, but there is no tag before the symbol \\ with the number {index - 1}"); } var tag = GetTag(str, ref index); if (tag.Length == 0) { throw new ArgumentException( $"a tag was expected, but there is no tag before the symbol \\ with the number {index - 1}"); } return(tag switch { "lnot" => Negation.GetInstance(), "lor" => Disjunction.GetInstance(), "land" => Conjunction.GetInstance(), "to" => Implication.GetInstance(), "forall" => UniversalQuantifier.GetInstance(), "exists" => ExistentialQuantifier.GetInstance(), "over" => Division.GetInstance(), "func" => GetFunction(str, ref index), // \func{name arity} "pr" => GetPredicate(str, ref index), // \pr{name arity} _ => throw new ArgumentException($"unknown tag {tag} before the symbol with the number {index}") });
public void TrueExample1() { Disjunction disj = new Disjunction(A, B); Conjunction conj = new Conjunction(disj, C); Assert.True(conj.Is_NNF()); }
public List <Student> Search(StudentSearchCriteria criteria) { var students = session.QueryOver <Student>(); if (!String.IsNullOrEmpty(criteria.PartialName)) { string pn = String.Format("%{0}%", criteria.PartialName.Substring(0, Math.Min(50, criteria.PartialName.Length))); Disjunction disjunction = new Disjunction(); disjunction.Add(Restrictions.On <Student>(e => e.FirstName).IsLike(pn)); disjunction.Add(Restrictions.On <Student>(e => e.LastName).IsLike(pn)); students = students.Where(disjunction); } if (criteria.Id.HasValue) { students = students.Where(x => x.Id == criteria.Id); } if (criteria.MathGeniusId.HasValue) { students = students.Where(x => x.MathGeniusId == criteria.MathGeniusId); } if (criteria.GraduationYear.HasValue) { students = students.Where(x => x.GraduationYear == criteria.GraduationYear); } return(students.List <Student>().ToList()); }
public IList<Friend> Search(RegisteredUser user, string friend, FriendStatus status, int limit) { ICriteria crit = NHibernateSession.Current.CreateCriteria(typeof(Friend)); crit.SetFetchMode("User", FetchMode.Join); crit.Add(Restrictions.Eq("BasicUser.Id", user.Id)); crit.Add(Expression.Not(Expression.Eq("Status", FriendStatus.Denied))); if(status != FriendStatus.All) crit.Add(Expression.Eq("Status", status)); Disjunction d = new Disjunction(); if (!string.IsNullOrEmpty(friend)) { ICriteria critUser = crit.CreateCriteria("User"); d.Add(Expression.Like("FirstName", friend, MatchMode.Anywhere)); d.Add(Expression.Like("LastName", friend, MatchMode.Anywhere)); d.Add(Expression.Like("EmailAddress", friend, MatchMode.Anywhere)); critUser.Add(d); } if (limit > 0) crit.SetMaxResults(limit); return crit.List<Friend>(); }
public IList <TransactionHistoryWeekly> GetInfo(int productID, int week, int year, int period) { ICriteria crit = GetCriteria(); crit.Add(Expression.Eq("ProductID", new Product(productID))); int weekDif = (week - period); if (weekDif <= 0) { Disjunction dis = new Disjunction(); dis.Add(new AndExpression(new BetweenExpression("Week", 52 + weekDif, 52), new EqExpression("Year", year - 1))); dis.Add(new AndExpression(new BetweenExpression("Week", 1, week), new EqExpression("Year", year))); crit.Add(dis); } else { crit.Add(new AndExpression(new BetweenExpression("Week", week - period, week), new EqExpression("Year", year))); } crit.AddOrder(new Order("Year", false)); crit.AddOrder(new Order("Week", false)); return(crit.List <TransactionHistoryWeekly>()); }
public static SequentFormula Apply(SequentFormula first, SequentFormula second, SequentFormula third) { if (Disjunction.GetInstance().Equals(first.Consequent.TopConnective) == false) { return(null); } if (second.Consequent == null || third.Consequent == null) { return(null); } if (second.Consequent.Equals(third.Consequent) == false) { return(null); } var newAntecedents = new HashSet <Formula>(); foreach (var antecedent in first) { newAntecedents.Add(antecedent); } foreach (var antecedent in second) { newAntecedents.Add(antecedent); } foreach (var antecedent in third) { newAntecedents.Add(antecedent); } var newConsequent = second.Consequent; return(new SequentFormula(newAntecedents, newConsequent)); }
public IList <HandHistory> GetGames(IEnumerable <long> gameNumbers, short pokersiteId) { var handHistoryParserFactory = ServiceLocator.Current.GetInstance <IHandHistoryParserFactory>(); var handHistoryParser = handHistoryParserFactory.GetFullHandHistoryParser((EnumPokerSites)pokersiteId); using (var session = ModelEntities.OpenSession()) { List <HandHistory> historyList = new List <HandHistory>(); Disjunction restriction = Restrictions.Disjunction(); restriction.Add(Restrictions.Conjunction() .Add(Restrictions.On <Handhistory>(x => x.Gamenumber).IsIn(gameNumbers.ToList())) .Add(Restrictions.Where <Handhistory>(x => x.PokersiteId == pokersiteId))); var list = session.QueryOver <Handhistory>() .Where(restriction) .List(); foreach (var history in list) { var result = handHistoryParser.ParseFullHandHistory(history.HandhistoryVal); if (result == null) { continue; } historyList.Add(result); } return(historyList); } }
public IList <Campaign> GetActive(string applicationName, bool onlyFixed) { ICriteria crit = GetCriteria( ); // Check Schedule Range Conjunction range = new Conjunction(); range.Add(Expression.Le("StartDate", DateTime.Today)); range.Add(Expression.Ge("EndDate", DateTime.Today)); // If EndDate is null, avoid range check Disjunction nullDate = new Disjunction( ); nullDate.Add(new NullExpression("EndDate")); nullDate.Add(range); // Apply filters crit.AddOrder(new Order("StartDate", false)) .Add(Expression.Eq("Status", CampaignStatus.Enabled)) .Add(Expression.Eq("ApplicationName", applicationName)) .Add(nullDate); // If fixed only, check dynamic code is null if (onlyFixed) { crit.Add(new NullExpression("DynamicCode")); } return(crit.List <Campaign>( )); }
public void Copy_CopyingDisjunctionWithTwoRandomVariableSymbols_ExpectedDifferentReferencesForConnective() { // Arrange // Act // Assert Disjunction disjunction = generateDisjunction(); Copy_CopyingBinaryConnectiveWithTwoRandomVariableSymbols_ExpectedDifferentReferencesForConnective(disjunction); }
public void TestDisjunctionIdentity() { BooleanExpression actual = new Disjunction(A, BooleanExpression.FALSE).Simplify(); BooleanExpression expected = A; Assert.Equal(expected, actual); }
public IList <OutfitUpdater> GetOnly(params OutfitUpdaterStatus[] status) { ICriteria crit = Session.CreateCriteria(typeof(OutfitUpdater)); crit.Add(Expression.Eq("Season", SeasonHelper.CurrentSeason)); Disjunction d = new Disjunction(); foreach (OutfitUpdaterStatus ous in status) { d.Add(Expression.Eq("Status", ous)); } crit.Add(d); // Fetch everything we can to avoid select on the loops. crit.SetFetchMode("Silouhette", FetchMode.Join); crit.SetFetchMode("Silouhette.Structure", FetchMode.Join); crit.SetFetchMode("Silouhette.Shape", FetchMode.Join); crit.SetFetchMode("ColorFamily", FetchMode.Join); crit.SetFetchMode("ColorFamily.AnalogousFamily", FetchMode.Join); crit.SetFetchMode("ColorFamily.AnalogousFamily2", FetchMode.Join); crit.SetFetchMode("ColorFamily.ComplimentaryFamily", FetchMode.Join); crit.SetFetchMode("Pattern", FetchMode.Join); return(crit.List <OutfitUpdater>()); }
public IList <TransactionHistoryWeekly> GetSalesTotal(Product productID, int week, int year) { List <TransactionHistoryWeekly> info = new List <TransactionHistoryWeekly>(); for (int interval = 4; interval <= 52;) { ICriteria crit = GetCriteria(); crit.Add(Expression.Eq("ProductID", productID)); int weekDif = (week - interval); if (weekDif <= 0) { Disjunction dis = new Disjunction(); dis.Add(new AndExpression(new BetweenExpression("Week", 52 + weekDif, 52), new EqExpression("Year", year - 1))); dis.Add(new AndExpression(new BetweenExpression("Week", 1, week), new EqExpression("Year", year))); crit.Add(dis); } else { crit.Add(new AndExpression(new BetweenExpression("Week", week - interval, week), new EqExpression("Year", year))); } crit.SetProjection(Projections.ProjectionList() .Add(Projections.Sum("Sale")) .Add(Projections.GroupProperty("ProductID")) ); crit.SetResultTransformer(new NHibernate.Transform.AliasToBeanConstructorResultTransformer(typeof(TransactionHistoryWeekly).GetConstructors()[1])); TransactionHistoryWeekly res = crit.UniqueResult <TransactionHistoryWeekly>(); if (res == null) { res = new TransactionHistoryWeekly(); res.Sale = 0; } info.Add(res); switch (interval) { case 4: interval = 13; break; case 13: interval = 26; break; case 26: interval = 52; break; case 52: interval = 60; break; } } return(info); }
public void Visit(Disjunction visitable) {// β-rule for | var tableauxRoot = visitable.Belongs; var p = BinaryTree.CloneNode(visitable.LeftNode, _binaryTree); var q = BinaryTree.CloneNode(visitable.RightNode, _binaryTree); var nodeLeft = new TableauxNode(p, visitable, tableauxRoot, RuleType.RuleBeta); var nodeRight = new TableauxNode(q, visitable, tableauxRoot, RuleType.RuleBeta); }
public void Calculate_CalculateAllPossibleTruthValues_ExpectedTrueWhenLeftOrRightAreTrue(bool leftTruthValue, bool rightTruthValue, bool expectedTruthValue) { // Arrange Disjunction disjunction = generateDisjunction(); string message = "because disjunction is true when either left or right are true"; Calculate_DetermineAllPossibleValuesBetweenTwoPropositionVariables(disjunction, message, leftTruthValue, rightTruthValue, expectedTruthValue); }
public void TrueExample2() { Disjunction disj = new Disjunction(new Negation(B), C); Conjunction conj = new Conjunction(A, disj, new Negation(C)); Disjunction outerDisj = new Disjunction(conj, D); Assert.True(outerDisj.Is_NNF()); }
internal override WalkedToken Walk(WalkedToken left, WalkedToken right) { Disjunction crit = new Disjunction(); crit.Add(left.Criterion); crit.Add(right.Criterion); return(WalkedToken.FromCriterion(crit)); }
internal override WalkedToken Walk(WalkedToken left, WalkedToken right) { Disjunction crit = new Disjunction(); crit.Add(left.Criterion); crit.Add(right.Criterion); return WalkedToken.FromCriterion(crit); }
public void SelectsDisjunction() { var spec1 = new IntegerGreaterThanZero(); var spec2 = new IntegerEqualToZero(); var disjoinedSpec = new Disjunction<int>(spec1, spec2); Assert.That(disjoinedSpec.IsSatisfiedBy(1), Is.True); Assert.That(disjoinedSpec.IsSatisfiedBy(0), Is.True); Assert.That(disjoinedSpec.IsSatisfiedBy(-1), Is.False); }
public double Satisfy (State s, Disjunction disjunct) { return 1 - disjunct.Expressions.Select (x => 1 - Satisfy (s, x)).Aggregate (1d, (acc, val) => acc * val); }