Maxle5.FinderGenerator is a high performance library used for finding all instances of a given Type from a complex object.
Built without reflection by leveraging .NET Source Code Generators that were introduced in .NET 5!
- method has the
[FinderGenerator]
Attribute - method is marked as
static partial
- method returns an
IEnumerable<T>
(T
is the type to find) - method accepts a single argument (argument is the Type to look through)
public static partial class IntegerFinder
{
[FinderGenerator]
public static partial IEnumerable<int> FindInts(MyComplexObject test);
}
// Sample Object To Look through
public class MyComplexObject
{
public int Id { get; set; }
public string Name { get; set; }
public IEnumerable<int> Numbers { get; set; }
}
public static partial class IntegerFinder
{
public static partial IEnumerable<int> FindInts(MyComplexObject test)
{
var instances = new List<int>();
instances.Add(test.Id);
foreach (var y in test.Numbers)
{
instances.Add(y);
}
return instances;
}
}