예제 #1
0
        private static void FillField(DynamicDictionary vars, ObjectField field)
        {
            var value = field.Argument.Value;

            if (value is Argument[] array && array.Length == 1)
            {
                value = array[0].Value;
            }

            if (value is ObjectCreator subCreator)
            {
                // We can assume that the returned value is a document variable.
                // In every other case the Create call throws an exception.
                value = (subCreator.Create(typeof(DynamicDictionary), null) as DynamicObject) !;
            }
            else if (value is ObjectArray objectArray)
            {
                value = objectArray.Get(typeof(object), null);
            }

            vars.SetMember(field.Key, value);
        }