Example #1
0
        public ZptViewEngine(IZptViewEngineConfiguration config = null,
                         string[] viewLocations = null,
                         IRenderingContextFactoryFactory contextFactoryFactory = null,
                         IContextVisitorFactory contextVisitorFactory = null)
        {
            InitialiseDefaultViewLocations(viewLocations);

              config = config?? GetConfiguration();

              if(config != null)
              {
            InitialiseFromConfig(config,
                             contextFactoryFactory?? new RenderingContextFactoryFactory(),
                             contextVisitorFactory?? new ContextVisitorFactory());
              }
              else
              {
            InitialiseDefaultOptions();
              }

              TemplateFactory = new ZptDocumentFactory();
        }
 public void Setup()
 {
     _sut = new RenderingContextFactoryFactory();
 }
Example #3
0
        private void InitialiseFromConfig(IZptViewEngineConfiguration config,
                                      IRenderingContextFactoryFactory contextFactoryFactory,
                                      IContextVisitorFactory contextVisitorFactory)
        {
            var defaultOptions = RenderingSettings.Default;

              if(config.ContextFactoryTypeName != null)
              {
            ContextFactory = contextFactoryFactory.Create(config.ContextFactoryTypeName);
              }
              else
              {
            ContextFactory = new MvcRenderingContextFactory();
              }

              if(config.ContextVisitorTypeNames != null)
              {
            ContextVisitors = contextVisitorFactory.CreateMany(config.ContextVisitorTypeNames);
              }
              else
              {
            ContextVisitors = defaultOptions.ContextVisitors;
              }

              if(!String.IsNullOrEmpty(config.ForceInputEncoding))
              {
            ForceInputEncoding = Encoding.GetEncoding(config.ForceInputEncoding);
              }
              else
              {
            ForceInputEncoding = null;
              }

              AddSourceFileAnnotation = config.AddSourceFileAnnotation;
              OutputEncoding = Encoding.GetEncoding(config.OutputEncoding);
              OmitXmlDeclaration = config.OmitXmlDeclaration;
              XmlIndentationCharacters = config.XmlIndentationCharacters;
              OutputIndentedXml = config.OutputIndentedXml;
              RenderingMode = (RenderingMode) Enum.Parse(typeof(RenderingMode), config.RenderingMode);
        }