Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Variant Into Two Types #49

Open
ghost opened this issue Oct 25, 2019 · 2 comments
Open

Refactor Variant Into Two Types #49

ghost opened this issue Oct 25, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Oct 25, 2019

https://github.com/metasys-server/basic-services-dotnet/blob/f1d936984908af6b5e4640f35d514281a97a279f/MetasysServices/Models/Variant.cs#L151

I think this points to the fact that Variant should be decomposed into two types.

  1. Variant which is a type that can hold one of String, Number, Boolean, or Array.
  2. AttributeValue which holds an id, attribute, Variant, (and culture for localization)

Then Variant is appropriate to use for property values as well as cells in an array. AttributeValue would be used only for property values.

@ghost
Copy link
Author

ghost commented Oct 25, 2019

If you do this decomposition, then Variant could have an internal Factory method that takes a JToken for use by MetasysClient.

But it could also have implicit conversion operators to convert numbers, bools, strings, etc to Variant. For convenience, and testing.

So you could do things like the following.

var v:Variant = 35
var x:Variant = "My string"

Or just have public constructors that take all the basic types that need to be supported.

@SavannahEvans SavannahEvans changed the title It's odd that id and attribute are stored for every cell of an array Refactor Variant Into Two Types Nov 4, 2019
@SavannahEvans SavannahEvans added the enhancement New feature or request label Nov 4, 2019
@michaelgwelch
Copy link
Member

@Federico-Artioli something to consider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants