Skip to content

Feature: Better Array support of ValueContainer #57

Description

@pksorensen

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions