Blazor Design: Expression Service That Depends on other Objects
For a Blazor project, I have a group of Expression components that calculates values based on text input and referencing each other for values. Users can use a tag like [value1] to reference other components. For example,
I'm considering using a service to handle this
What I'm worried about is if I have a directory page to search groups, I could end up loading dozens of this service and it could cause issues.
Question: do I have the right approach? Can I use a service to have a group of components to register with it to be easily searched and not have it balloon into a mess? Or should the service be like a singleton and have a single instance and the grouped expressions register and then handle referencing? If not, what would be a cleaner approach?
Alternatively, I was thinking of making a Parent reference in each of the expression components that would reference the group. Then the group would have a method to handle the expression.
3 Replies
Could you elaborate a bit on what you are exactly trying to accomplish?
What exactly should the user be able to do?
They should be able to enter in formulas in a text field that can reference other formulas or number fields and use them as parameters
so you have a number field that has "400" in it and this component could have "10 * [other component]" = 4000
And they define the names and values of those other components?
Maybe a single service that manages a dictionary<string, component> would suffice