コード例 #1
0
        /// <summary>
        /// Fetch the target that would be bound to this parameter given the passed <see cref="ICompileContext"/>
        /// </summary>
        /// <param name="context">The current compile context - a new one is created for the <see cref="Parameter"/> type</param>
        /// <returns>The target that should be used for the parameter, or null if no target could be found.
        ///
        /// Note that if the returned target's <see cref="ITarget.UseFallback"/> property is set to <c>true</c>,
        /// then it means either the parameter's default value is being used, or that the target fetched from the
        /// target container in the context is a stub (e.g. empty enumerable)</returns>
        /// <remarks>During compilation - you should not use the target returned by this function as a direct
        /// part of your expression tree - you should </remarks>
        public virtual ITarget Resolve(ICompileContext context)
        {
            if (Target is ResolvedTarget rezolvedTarget)
            {
                return(rezolvedTarget.Bind(context.NewContext(Parameter.ParameterType)));
            }

            return(Target);
        }