popcorn
popcorn
CC#
Created by popcorn on 3/18/2024 in #help
Delegate function with params
Okay, thank you for your opinion ❤️
21 replies
CC#
Created by popcorn on 3/18/2024 in #help
Delegate function with params
I guess sacrificing the complexity of the "library" is better for the comfort of user defined functions.
21 replies
CC#
Created by popcorn on 3/18/2024 in #help
Delegate function with params
Cool, didn't know about that one. Thanks
21 replies
CC#
Created by popcorn on 3/18/2024 in #help
Delegate function with params
So I would have X number of variables with these functions I guess?
21 replies
CC#
Created by popcorn on 3/18/2024 in #help
Delegate function with params
But then I would have to overload x number of times the generic method. So I would have:
public OptionBuilder<T> ValidationFunc(Func<T, T, bool> validator) { // Save the func to variable }

public OptionBuilder<T> ValidationFunc(Func<T, T, T, bool> validator) { // Save the func to variable }
public OptionBuilder<T> ValidationFunc(Func<T, T, bool> validator) { // Save the func to variable }

public OptionBuilder<T> ValidationFunc(Func<T, T, T, bool> validator) { // Save the func to variable }
And I then I would have to somehow decide which function was actually provided and call that
21 replies
CC#
Created by popcorn on 3/18/2024 in #help
Delegate function with params
Like this:
public static Func<int, int, bool> IsExact2 = (val, expected) => val == expected;

public static Func<int, int, int, bool> IsInBounds = (val, upperBound, lowerBound) => lowerBound >= val && val <= upperBound;
public static Func<int, int, bool> IsExact2 = (val, expected) => val == expected;

public static Func<int, int, int, bool> IsInBounds = (val, upperBound, lowerBound) => lowerBound >= val && val <= upperBound;
21 replies
CC#
Created by popcorn on 3/18/2024 in #help
Delegate function with params
Yeah, I'm thinking about just supporting limited number of parameters, just as it is with the generic Func<> where you can only have up to 16 params
21 replies
CC#
Created by popcorn on 3/18/2024 in #help
Delegate function with params
Ah okay. Then this must be enough 😄
21 replies
CC#
Created by popcorn on 3/18/2024 in #help
Delegate function with params
I need to take the function from user and I only know that the return type is bool and that any number of params is T type. But I don't know how many params
21 replies
CC#
Created by popcorn on 3/18/2024 in #help
Fluent Syntax - generic methods
That's right. Well thank you for your time and help. Appreciate it
29 replies
CC#
Created by popcorn on 3/18/2024 in #help
Fluent Syntax - generic methods
Oh, so this is more of a bad design decision then?
29 replies
CC#
Created by popcorn on 3/18/2024 in #help
Fluent Syntax - generic methods
So that we ensure that every Control placed in the canvas has coordinates
29 replies
CC#
Created by popcorn on 3/18/2024 in #help
Fluent Syntax - generic methods
But that up to the implementation of the .PlacedIn(canvas) to do "nothing" if it's not followed by the .At() method
29 replies
CC#
Created by popcorn on 3/18/2024 in #help
Fluent Syntax - generic methods
Thanks a lot
29 replies
CC#
Created by popcorn on 3/18/2024 in #help
Fluent Syntax - generic methods
Right, I get it now. Neat solution
29 replies
CC#
Created by popcorn on 3/18/2024 in #help
Fluent Syntax - generic methods
Hmm, I dont see how it could be done using interfaces? Also some type of generic parameter at interface?
29 replies
CC#
Created by popcorn on 3/18/2024 in #help
Fluent Syntax - generic methods
Exactly
29 replies
CC#
Created by popcorn on 3/18/2024 in #help
Fluent Syntax - generic methods
Thanks, I'll try to implement the details and see if it works.
29 replies
CC#
Created by popcorn on 3/18/2024 in #help
Fluent Syntax - generic methods
Oh right I can have the .At() method in the builder 🤦‍♂️ I was still thinking about the method extensions and just didn't know how to return the generic Type in there. You basically meant something like this, right?
public static PositionableControl<T> PlacedIn<T>(this T control, Canvas canvas) where T : Control { }

public class PositionableControl<T> where T : Control {
public T At(int x, int y) { }
}
public static PositionableControl<T> PlacedIn<T>(this T control, Canvas canvas) where T : Control { }

public class PositionableControl<T> where T : Control {
public T At(int x, int y) { }
}
29 replies
CC#
Created by popcorn on 11/6/2023 in #help
❔ query all items that match both properties.
Okay, thanks
19 replies