private bool IsStructured(IVariable variable)
        {
            var result = HasProperties(variable) || HasIndexes(variable);

            if (!result)
            {
                if (variable.DataType == DataType.Object)
                {
                    var obj = variable.AsObject();
                    result = obj is IEnumerable <KeyAndValueImpl>;
                }
            }
            return(result);
        }
        private List <IVariable> GetChildVariables(IVariable src)
        {
            var variables = new List <IVariable>();

            if (HasProperties(src))
            {
                FillProperties(src, variables);
            }
            else if (src.AsObject() is IEnumerable <KeyAndValueImpl> collection)
            {
                FillKeyValueProperties(collection, variables);
            }

            if (HasIndexes(src))
            {
                FillIndexedProperties(src, variables);
            }

            return(variables);
        }
        private void FillProperties(IVariable src, List <IVariable> variables)
        {
            var obj        = src.AsObject();
            var propsCount = obj.GetPropCount();

            for (int i = 0; i < propsCount; i++)
            {
                string propName = obj.GetPropName(i);

                IVariable value;

                try
                {
                    value = MachineVariable.Create(obj.GetPropValue(i), propName);
                }
                catch (Exception e)
                {
                    value = MachineVariable.Create(ValueFactory.Create(e.Message), propName);
                }

                variables.Add(value);
            }
        }
        private void FillIndexedProperties(IVariable src, List <IVariable> variables)
        {
            var obj = src.AsObject();

            if (obj is ICollectionContext cntx)
            {
                var itemsCount = cntx.Count();
                for (int i = 0; i < itemsCount; i++)
                {
                    IValue value;

                    try
                    {
                        value = obj.GetIndexedValue(ValueFactory.Create(i));
                    }
                    catch (Exception)
                    {
                        continue;
                    }

                    variables.Add(MachineVariable.Create(value, i.ToString()));
                }
            }
        }