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

            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.
                inner = (subCreator.Create(typeof(DocumentVariable), null) as DocumentVariable) !;
            }
            else
            {
                inner = new DocumentVariable(value);
            }

            vars[field.Key] = inner;
        }
예제 #2
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);
        }