Background
I am starting work on a small OSS library called Sieve.NET .
A signature allows someone to define Sieve as follows:
new EqualitySieve<ABusinessObject>().ForProperty(x => x.AnInt);
This actually returns Sieve<ABusinessObject, int> , but I did my best to prevent users from taking too much care of this part.
Task
I would like to find a way to put an interface on it where I donβt need a property type at all - only it is consistent in everything.
So essentially, I would like to be able to declare ISieve<TFilterObjectType> , and also have that interface to define:
ISieve<TFilterObjectType, TTypeIDontCareAbout> ForValue(TTypeIDontCareAbout);
My goal is to have a class consisting of ISieve<ABusinessObject> , not ISieve<ABusinessObject, int> .
Question
- Is there a way for an interface to declare a type that is effectively a wildcard, and says: "I don't care what type it is, only that it is consistent?"
My initial research says no, but I hope it turns out to be erroneous.
Updates and Clarifications
I am really trying to understand:
- I allow users to create
EqualitySieve<ABusinessObject>().ForProperty(x=>x.AnInt) . - This actually returns the user
EqualitySieve<ABusinessObject, int> , but since this is a free interface, I remove them from the need to take care of this part. - I would like
EqualitySieve , LessThanSieve etc. implement ISieve<ABusinessObject> . - I would like
ISieve<ABusinessObject to execute a contract under which I could let someone call ForValues() and expect him to return ISieve with updated values. - However, at this point,
EqualitySieve<ABusinessObject> is actually EqualitySieve<ABusinessObject, int> . But I don't really care about the type of properties at this point. - Essentially, since I am abstracting the
EqualitySieve<ABusinessObject, int> , I also wanted to see if I can abstract this when accessing objects through the interface. - The long-term plan is that I want to have a SieveLocator where classes can implement
IFindableSieve<ABusinessObject> , which would ideally return ISieve<ABusinessObject> . Then my goal would be to find these sieves for a given object. - So, I think that this is most likely a limitation of my design, and I have to find another way. Any suggestions on this or links to a template that I might not have seen would also be helpful.
source share