Reply to Re: Overthinking it
If you don't have an account, just leave the password field blank.
Just a reminder, not that important, don't bang your heads too hard
I'll keep it simple, then build on (ignore potential issues). Suppose you have a class Human with two properties:
When I instantiate that class, I wanna do it by using lambda expression that will set parameters to call certain functions within that class, which determine whether the input (set) is acceptable or not... Phew
Again, keeping it simple, let's say that if someone wanna set Human's age to 137, he can't do that because there's a limit. I'm aware that the class has no implementation for that yet.
So the constructor should look like this:
The values of minimum and maximum age can be a field, or properties of a nested class within Human.
If I also wanna be able to implement some restrictions to Name property, I'll add a function that will be called when setting the Name property. Some regular expression that will filter out strings containing characters or numbers. Don't worry about the function itself, just how to get this lambda to work.
Use nested classes, delegates, whatever... If this has no solution, the other thing I'll accept as a replacement is some class, say... Factory. So you can pass any generic class to it, and do the same as above.
I know this post is a bit messy. If anything remained unclear, ask... Bottom line, make a class where restrictions on property values are defined in a constructor, via lambda expression...
I'll keep it simple, then build on (ignore potential issues). Suppose you have a class Human with two properties:
class Human { public string Name {get; set;} public int Age {get; set;} }
When I instantiate that class, I wanna do it by using lambda expression that will set parameters to call certain functions within that class, which determine whether the input (set) is acceptable or not... Phew
Again, keeping it simple, let's say that if someone wanna set Human's age to 137, he can't do that because there's a limit. I'm aware that the class has no implementation for that yet.
So the constructor should look like this:
var human = new Human(cfg => cfg.Age.MaximumAge = 70, cfg.Age.MinimumAge = 0 );
The values of minimum and maximum age can be a field, or properties of a nested class within Human.
If I also wanna be able to implement some restrictions to Name property, I'll add a function that will be called when setting the Name property. Some regular expression that will filter out strings containing characters or numbers. Don't worry about the function itself, just how to get this lambda to work.
var human = new Human(cfg => cfg.Age.MaximimumAge = 70, cfg.Age.MinimumAge = 0, cfg.Name.ContainSymbols = false, cfg.Name.ContainNumbers = true );
Use nested classes, delegates, whatever... If this has no solution, the other thing I'll accept as a replacement is some class, say... Factory. So you can pass any generic class to it, and do the same as above.
var crap = new Factory<Human> (cfg => cfg.Name.ContainSymbols = false // etc );
I know this post is a bit messy. If anything remained unclear, ask... Bottom line, make a class where restrictions on property values are defined in a constructor, via lambda expression...