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

            Writers.AddToEnd(writer);
        }