This library is designed for a future version of DarkRift Networking to provide dynamic filtering in streams of objects.
Some DarkRift plugins will need to filter certain messages depending on rules that could be defined by a user at runtime or in configuration. Given the number of possibilities of these filters it is not easy to write custom logic to filter messages without limiting what combinations are possible.
Therefore this library provides compilation of custom filtering functions that can handle the speeds at which DarkRift needs without sacrificing the possibilities of those filters.
The filtering language is designed to look similar to C# or that use in Wireshark.
Fast Object Filter works by using Expressions to compile the filter string into a Func<bool, T>
.
FastObjectFilter is available as a NuGet package!
A simple usage would look like:
var filter = new FastObjectFilterCompiler().Compile<DataObject>("Forename == \"Steve\"");
var data = new DataObject(Forename = "Steve", Surname = "Irwin", DOB = new DateTime(1962, 9, 22), LikesCats = true);
if (filter(data))
Console.WriteLine("Match");
else
Console.WriteLine("No match");
This would print out:
Match
Of course, this example is trivial, the real power of Fast Object Filter is found when a single filter string needs to be applied to thousands of different data objects.