/// <inheritdoc />
        public override async Task <IEnumerable <DocumentItemExecution> > Render(IByteCounterStream outputStream, ContextObject context, ScopeData scopeData)
        {
            await Task.CompletedTask;

            context = context.CloneForEdit();
            return(Children.WithScope(context));
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public async Task <ContextObject> GetValue(ContextObject contextObject, ScopeData scopeData)
        {
            contextObject = contextObject.CloneForEdit();
            foreach (var expression in Expressions)
            {
                contextObject = await expression.GetValue(contextObject, scopeData);
            }

            return(contextObject);
        }
        /// <inheritdoc />
        public override async Task <IEnumerable <DocumentItemExecution> > Render(IByteCounterStream outputStream, ContextObject context, ScopeData scopeData)
        {
            await Task.CompletedTask;

            context = context.CloneForEdit();
            foreach (var expression in Children.OfType <IValueDocumentItem>())
            {
                context = await expression.GetValue(context, scopeData);
            }
            scopeData.Alias[Value] = context;
            return(new DocumentItemExecution[0]);
        }
Ejemplo n.º 4
0
        /// <inheritdoc />
        public async ContextObjectPromise GetValue(ContextObject contextObject, ScopeData scopeData)
        {
            if (!PathParts.Any() && Formats.Count == 1 && FormatterName == "")
            {
                //indicates the usage of brackets
                return(await Formats[0].GetValue(contextObject, scopeData));
            }

            var contextForPath = contextObject.GetContextForPath(PathParts, scopeData, this);

            if (!Formats.Any() && FormatterName == null)
            {
                return(contextForPath);
            }

            if (contextForPath == contextObject)
            {
                contextForPath = contextObject.CloneForEdit();
            }

            var arguments    = new FormatterArgumentType[Formats.Count];
            var naturalValue = contextObject.FindNextNaturalContextObject();

            for (var index = 0; index < Formats.Count; index++)
            {
                var formatterArgument = Formats[index];
                var value             = await formatterArgument.MorestachioExpression.GetValue(naturalValue, scopeData);

                arguments[index] = new FormatterArgumentType(index, formatterArgument.Name, value?.Value);
            }
            //contextForPath.Value = await contextForPath.Format(FormatterName, argList, scopeData);

            if (Cache == null)
            {
                Cache = contextForPath.PrepareFormatterCall(
                    contextForPath.Value?.GetType() ?? typeof(object),
                    FormatterName,
                    arguments,
                    scopeData);
            }

            if (Cache != null /* && !Equals(Cache.Value, default(FormatterCache))*/)
            {
                contextForPath.Value = await scopeData.ParserOptions.Formatters.Execute(Cache, contextForPath.Value, scopeData.ParserOptions, arguments);

                contextForPath.MakeSyntetic();
            }
            return(contextForPath);
        }