示例#1
0
        /// <inheritdoc/>
        public virtual void Write(RendererBase renderer, MustacheToken obj, Context context)
        {
            var typedRenderer = (TRenderer)renderer;
            var typedObj      = (TToken)obj;

            Write(typedRenderer, typedObj, context);
        }
示例#2
0
        /// <inheritdoc/>
        public Task WriteAsync(RendererBase renderer, MustacheToken obj, Context context)
        {
            var typedRenderer = (TRenderer)renderer;
            var typedObj      = (TToken)obj;

            return(WriteAsync(typedRenderer, typedObj, context));
        }
示例#3
0
        /// <summary>
        /// Tries to get a token renderer for a given tag type
        /// </summary>
        /// <typeparam name="T">The type of the tag</typeparam>
        /// <param name="renderer">The base renderer being used to render</param>
        /// <param name="obj">The tag to get the renderer for</param>
        /// <returns>The tag renderer that matches or null</returns>
        public ITokenRenderer TryGetTokenRenderer <T>(RendererBase renderer, T obj)
            where T : MustacheToken
        {
            var objectType = obj.GetType();

            if (!renderersPerType.TryGetValue(objectType, out ITokenRenderer tokenRenderer))
            {
                for (int i = 0; i < tokenRenderers.Count; i++)
                {
                    var testRenderer = tokenRenderers[i];
                    if (testRenderer.Accept(renderer, obj))
                    {
                        renderersPerType[objectType] = tokenRenderer = testRenderer;
                        break;
                    }
                }
            }

            return(tokenRenderer);
        }
示例#4
0
 /// <inheritdoc/>
 public bool Accept(RendererBase renderer, MustacheToken obj)
 {
     return(obj is TToken);
 }