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

Feature: Better Array support of ValueContainer #57

Open
pksorensen opened this issue Nov 30, 2021 · 0 comments
Open

Feature: Better Array support of ValueContainer #57

pksorensen opened this issue Nov 30, 2021 · 0 comments
Assignees

Comments

@pksorensen
Copy link
Member

In the below example, getting the values of the array ValueContainer type is abit bloated and requires one to explicite do GetValue<IList<ValueContainer>>(), using ValueContainer[] or Object[] would throw exceptions.

        public override ValueTask<ValueContainer> ExecuteFunction(params ValueContainer[] parameters)
        {
            var relationship = parameters[0]?.ToString()?.ToLower();
            var data = _formDataAccessor.Data;

            if (data.ContainsKey(relationship))
            {
                var array = data[relationship];
                if(array.Type() == ValueType.Array)
                {
                    var arrayData = array.GetValue<IList<ValueContainer>>();
                    return new ValueTask<ValueContainer>(new ValueContainer(arrayData.Count > 0));
                }
            }


            return new ValueTask<ValueContainer>(new ValueContainer(false));

        }

consider ValueContainer to implement IEnumerable ? as short cuts to return properties for objects or items for arrays. Or just a better AsArray?

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

No branches or pull requests

2 participants