public ViewNode AddView(IViewToken view, Type conditionType = null) { var node = new ViewNode(view); if (conditionType != null && conditionType != typeof(Always)) { node.Condition(conditionType); } Writers.AddToEnd(node); return(node); }
public WriteWithFormatter AddFormatter <T>() where T : IFormatter { var formatter = new WriteWithFormatter(_resourceType, typeof(T)); WriterNode existing = Writers.FirstOrDefault(x => x.Equals(formatter)); if (existing != null) { return(existing as WriteWithFormatter); } Writers.AddToEnd(formatter); return(formatter); }
public WriteHtml AddHtml() { WriteHtml existing = Writers.OfType <WriteHtml>().FirstOrDefault(); if (existing != null) { return(existing); } var write = new WriteHtml(_resourceType); Writers.AddToEnd(write); return(write); }
public Writer AddWriter <T>() { var writerType = typeof(IMediaWriter <>).MakeGenericType(_resourceType); if (!typeof(T).CanBeCastTo(writerType)) { throw new ArgumentOutOfRangeException("{0} cannot be cast to {1}".ToFormat(typeof(T).FullName, writerType.FullName)); } var writer = new Writer(typeof(T)); Writers.AddToEnd(writer); return(writer); }
public void AddWriter(Type writerType) { var writer = new Writer(writerType, _resourceType); Writers.AddToEnd(writer); }