Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public WriteHtml AddHtml()
        {
            WriteHtml existing = Writers.OfType <WriteHtml>().FirstOrDefault();

            if (existing != null)
            {
                return(existing);
            }

            var write = new WriteHtml(_resourceType);

            Writers.AddToEnd(write);

            return(write);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        public void AddWriter(Type writerType)
        {
            var writer = new Writer(writerType, _resourceType);

            Writers.AddToEnd(writer);
        }