public List <PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context) { var R = new List <PossibleMatch>(); if (State.Next == null) { return(R); } if ((Settings & ObjectMatcherSettings.UnderstandMe) == ObjectMatcherSettings.UnderstandMe) { if (State.Next.Value.ToUpper() == "ME") { var possibleMatch = new PossibleMatch(State.Arguments, State.Next.Next); possibleMatch.Arguments.Upsert(CaptureName, Context.ExecutingActor); R.Add(possibleMatch); } } foreach (var thing in ObjectSource.GetObjects(State, Context)) { var possibleMatch = new PossibleMatch(State.Arguments, State.Next); bool matched = false; while (possibleMatch.Next != null && thing.Nouns.Contains(possibleMatch.Next.Value.ToUpper())) { matched = true; possibleMatch.Next = possibleMatch.Next.Next; } if (matched) { possibleMatch.Arguments.Upsert(CaptureName, thing); R.Add(possibleMatch); } } return(R); }
override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context) { var useObjectScoring = ScoreResults != null; var R = new List <PossibleMatch>(); if (State.Next == null) { return(R); } if ((Settings & ObjectMatcherSettings.UnderstandMe) == ObjectMatcherSettings.UnderstandMe) { if (State.Next.Value.ToUpper() == "ME") { var possibleMatch = State.Advance(); possibleMatch.Upsert(CaptureName, Context.ExecutingActor); possibleMatch.Upsert(CaptureName + "-SOURCE", "ME"); R.Add(possibleMatch); } } foreach (var matchableMudObject in ObjectSource.GetObjects(State, Context)) { PossibleMatch possibleMatch = State; bool matched = false; while (possibleMatch.Next != null && matchableMudObject.GetProperty <NounList>("nouns").Match(possibleMatch.Next.Value.ToUpper(), Context.ExecutingActor)) { if (matched == false) { possibleMatch = State.Clone(); } matched = true; possibleMatch.Next = possibleMatch.Next.Next; } if (matched) { possibleMatch.Upsert(CaptureName, matchableMudObject); if (useObjectScoring) { var score = ScoreResults(Context.ExecutingActor, matchableMudObject); possibleMatch.Upsert(CaptureName + "-SCORE", score); var insertIndex = 0; for (insertIndex = 0; insertIndex < R.Count; ++insertIndex) { if (score > (R[insertIndex][CaptureName + "-SCORE"] as MatchPreference?).Value) { break; } } R.Insert(insertIndex, possibleMatch); } else { R.Add(possibleMatch); } } } return(R); }
/// <summary> /// Returns an <see cref="IQueryable{T}"/>. /// </summary> /// <typeparam name="T">Generic Argument of the returned <see cref="IQueryable{T}"/>.</typeparam> /// <returns>Returns an <see cref="IQueryable{T}"/>.</returns> public IQueryable <T> Get <T>() where T : class { return(objectSource.GetObjects <T>().AsQueryable()); }