/// <inheritdoc/> public virtual void Write(RendererBase renderer, MustacheToken obj, Context context) { var typedRenderer = (TRenderer)renderer; var typedObj = (TToken)obj; Write(typedRenderer, typedObj, context); }
/// <inheritdoc/> public Task WriteAsync(RendererBase renderer, MustacheToken obj, Context context) { var typedRenderer = (TRenderer)renderer; var typedObj = (TToken)obj; return(WriteAsync(typedRenderer, typedObj, context)); }
/// <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); }
/// <inheritdoc/> public bool Accept(RendererBase renderer, MustacheToken obj) { return(obj is TToken); }