示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#5
0
        public void AddWriter(Type writerType)
        {
            var writer = new Writer(writerType, _resourceType);

            Writers.AddToEnd(writer);
        }