Ejemplo n.º 1
0
        private void GenerateHtml(IRazorEngineService service)
        {
            var SampleTemplate = File.ReadAllText("SampleTemplate.cshtml");
            var SubSample      = File.ReadAllText("SubSample.cshtml");

            //service.AddTemplate("part", SubSample);

            // If you leave the second and third parameters out the current model will be used.
            // If you leave the third we assume the template can be used for multiple types and use "dynamic".
            // If the second parameter is null (which is default) the third parameter is ignored.
            // To workaround in the case you want to specify type "dynamic" without specifying a model use Include("p", new object(), null)
            //service.AddTemplate("template", SampleTemplate);

            service.Compile(SampleTemplate, "template", typeof(MyModel));
            service.Compile(SubSample, "part", typeof(SubModel));

            var result = service.Run("template", typeof(MyModel), new MyModel
            {
                SubModelTemplateName = "part",
                ModelProperty        = "model1<@><b>rob</b></@>.com &lt;",
                RawProperty          = "model1<@><b>rob</b></@>.com &lt;",
                SubModel             = new SubModel {
                    SubModelProperty = "submodel2"
                }
            });

            Console.WriteLine("Result is: {0}", result);

            DisplayHtml(result);
        }
Ejemplo n.º 2
0
        public RazorTransform(IContext context) : base(context, context.Field.Type)
        {
            _input = MultipleInput();

            var key = GetHashCode(context.Transform.Template, _input);

            if (!Cache.TryGetValue(key, out _service))
            {
                var config = new TemplateServiceConfiguration {
                    DisableTempFileLocking = true,
                    EncodedStringFactory   = Context.Transform.ContentType == "html"
                        ? (IEncodedStringFactory) new HtmlEncodedStringFactory()
                        : new RawStringFactory(),
                    Language        = Language.CSharp,
                    CachingProvider = new DefaultCachingProvider(t => { })
                };
                _service = RazorEngineService.Create(config);
            }

            try {
                _service.Compile(Context.Transform.Template, Context.Key, typeof(ExpandoObject));
                Cache[key] = _service;
            } catch (Exception ex) {
                Context.Warn(Context.Transform.Template.Replace("{", "{{").Replace("}", "}}"));
                Context.Warn(ex.Message);
                throw;
            }
        }
        public virtual void OnAppStartup()
        {
            TemplateServiceConfiguration config = new TemplateServiceConfiguration();

            AppEnvironment activeAppEnvironment = AppEnvironmentProvider.GetActiveAppEnvironment();

            config.Debug                = activeAppEnvironment.DebugMode;
            config.Language             = Language.CSharp;
            config.EncodedStringFactory = new NullCompatibleEncodedStringFactory();

            IRazorEngineService service = RazorEngineService.Create(config);

            Engine.Razor = service;

            string defaultPageTemplateFilePath = PathProvider.StaticFileMapPath(activeAppEnvironment.GetConfig("DefaultPageTemplatePath", "defaultPageTemplate.cshtml"));

            if (File.Exists(defaultPageTemplateFilePath))
            {
                string defaultPageTemplateContents = File.ReadAllText(defaultPageTemplateFilePath);

                Engine.Razor.Compile(name: "defaultPageTemplate", modelType: typeof(IDependencyResolver),
                                     templateSource: new LoadedTemplateSource(defaultPageTemplateContents, defaultPageTemplateFilePath));
            }

            string ssoPageTemplateFilePath = PathProvider.StaticFileMapPath(activeAppEnvironment.GetConfig("SsoPageTemplatePath", "ssoPageTemplate.cshtml"));

            if (File.Exists(ssoPageTemplateFilePath))
            {
                string ssoPageTemplateContents = File.ReadAllText(ssoPageTemplateFilePath);

                Engine.Razor.Compile(name: "ssoPageTemplate", modelType: typeof(IDependencyResolver),
                                     templateSource: new LoadedTemplateSource(ssoPageTemplateContents, ssoPageTemplateFilePath));
            }
        }
Ejemplo n.º 4
0
 private IRazorEngineService GetEngine()
 {
     if (_service == null)
     {
         _cache = new DefaultCachingProvider();
         var config = new TemplateServiceConfiguration
         {
             BaseTemplateType = typeof(MixberryTemplate <>),
             Namespaces       = new SortedSet <string>(new[]
             {
                 "System",
                 "System.Linq",
                 "DotOrg.Mixberry.Web.Core.Templating",
                 "DotOrg.Mixberry.Models",
                 "DotOrg.Core.Helpers"
             }),
             AllowMissingPropertiesOnDynamic = true,
             CachingProvider   = _cache,
             ReferenceResolver = new UseCurrentAssembliesReferenceResolver()
                                 //ReferenceResolver = new RazorEngineReferenceResolver()
         };
         _service = RazorEngineService.Create(config);
     }
     return(_service);
 }
Ejemplo n.º 5
0
        public void Generate(List <object> providers)
        {
            if (Directory.Exists(_root))
            {
                Directory.Delete(_root, true);
            }

            Directory.CreateDirectory(_root);

            var config = new TemplateServiceConfiguration()
            {
                DisableTempFileLocking = false,
                CachingProvider        = new DefaultCachingProvider(t => { }),
            };

            using (IRazorEngineService razor = RazorEngineService.Create(config))
            {
                CacheViews(razor);
                GenerateHome(razor, providers);
                GenerateTeams(razor);
                GenerateRecords <ICareerRecordProvider>(razor, "career-record-list", providers, x => x.GetData());
                GenerateRecords <ISeasonRecordProvider>(razor, "season-record-list", providers, x => x.GetData());
                GenerateRecords <IGameRecordProvider>(razor, "game-record-list", providers, x => x.GetData());
                GenerateRecords <IIndividualGameRecordProvider>(razor, "individual-game-record-list", providers, x => x.GetData());
                GenerateRecords <IStreakRecordProvider>(razor, "streak-record-list", providers, x => x.GetData());
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Компиляция и кеширование шаблонов для последующего использования
 /// </summary>
 /// <param name="service"></param>
 private static void PrepareTemplates(IRazorEngineService service)
 {
     service.Compile("Emails/Invite", typeof(InviteEmailModel));
     service.Compile("Emails/Registered", typeof(RegisteredEmailModel));
     service.Compile("Emails/ChangePassword", typeof(ChangePasswordEmailModel));
     service.Compile("Emails/RestorePassword", typeof(RestorePasswordEmailModel));
 }
        /// <summary>
        /// Finishes constructor work.
        /// </summary>
        private void Initialize(IEnumerable <string> templateFolderRoots, EncodingMode encodingMode)
        {
            if (templateFolderRoots == null)
            {
                throw new ArgumentNullException(nameof(templateFolderRoots));
            }

            this.TemplateFolderRoots = templateFolderRoots;

            var configuration = new TemplateServiceConfiguration()
            {
#if DEBUG
                Debug = true,
#endif
                TemplateManager = new ResolvePathTemplateManager(templateFolderRoots),
            };

            switch (encodingMode)
            {
            case EncodingMode.RawText:
                configuration.EncodedStringFactory = new RawStringFactory();
                break;

            default:
                configuration.EncodedStringFactory = new HtmlEncodedStringFactory();
                break;
            }

            this.razorEngineService = RazorEngineService.Create(configuration);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///   Create instance of EmailService with specified providers
        /// </summary>
        /// <param name="mailProvider"></param>
        /// <param name="templateProvider"></param>
        /// <param name="emailTemplateConfiguration"></param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="EmailSettingsException"></exception>
        public EmailService(IMailProvider mailProvider, IMessageTemplateProvider templateProvider,
                            IEmailTemplateConfiguration emailTemplateConfiguration)
        {
            _log = LogManager.GetLogger(GetType());

            if (mailProvider == null)
            {
                throw new ArgumentNullException(nameof(mailProvider));
            }
            if (emailTemplateConfiguration == null)
            {
                throw new ArgumentNullException(nameof(emailTemplateConfiguration));
            }
            _emailSettings = new Settings().EmailSettings;

            if (_emailSettings == null)
            {
                throw new EmailSettingsException();
            }

            _mailProvider               = mailProvider;
            _templateProvider           = templateProvider;
            _emailTemplateConfiguration = emailTemplateConfiguration;
            _engineService              = RazorEngineService.Create((ITemplateServiceConfiguration)_emailTemplateConfiguration);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 初始化
        /// </summary>
        public static void Init()
        {
            SetManager();
            //添加文件修改监控,以便在cshtml文件修改时重新编译该文件
            watcher.Path = Cache._Path.Web;
            watcher.IncludeSubdirectories = true;
            watcher.Filter              = "*.*html";
            watcher.NotifyFilter        = NotifyFilters.LastWrite | NotifyFilters.FileName;
            watcher.Created            += new FileSystemEventHandler(OnChanged);
            watcher.Changed            += new FileSystemEventHandler(OnChanged);
            watcher.Deleted            += new FileSystemEventHandler(OnChanged);
            watcher.EnableRaisingEvents = true;

            var config = new TemplateServiceConfiguration()
            {
                Namespaces = new HashSet <string>()
                {
                    "Microsoft.CSharp", "MM.Engine"
                },                                                                      // 引入命名空间
                Language               = Language.CSharp,
                EncodedStringFactory   = new HtmlEncodedStringFactory(),
                DisableTempFileLocking = true,
                TemplateManager        = mg,
                BaseTemplateType       = typeof(MmTemplateBase <>),
                CachingProvider        = cache
            };

            cache.InvalidateAll();
            razor = RazorEngineService.Create(config);
        }
Ejemplo n.º 10
0
 public DebugController(IUserRepository UserRep, UserService UserRegServ, IRazorEngineService TemplateServ, AccessRolesService AccessRolesServ)
 {
     this.UserRep         = UserRep;
     this.UserRegServ     = UserRegServ;
     this.TemplateServ    = TemplateServ;
     this.AccessRolesServ = AccessRolesServ;
 }
Ejemplo n.º 11
0
        public override IEnumerable <IRow> Operate(IEnumerable <IRow> rows)
        {
            var fileBasedTemplate = Context.Process.Templates.FirstOrDefault(t => t.Name == Context.Operation.Template);

            if (fileBasedTemplate != null)
            {
                Context.Operation.Template = fileBasedTemplate.Content;
            }

            var input   = MultipleInput();
            var matches = Context.Entity.GetFieldMatches(Context.Operation.Template);

            _input = input.Union(matches).ToArray();

            if (!Run)
            {
                yield break;
            }

            var key = GetHashCode(Context.Operation.Template, _input);

            if (!Cache.TryGetValue(key, out _service))
            {
                var config = new TemplateServiceConfiguration {
                    DisableTempFileLocking = true,
                    EncodedStringFactory   = Context.Field.Raw ? (IEncodedStringFactory) new HtmlEncodedStringFactory() : new RawStringFactory(),
                    Language        = Language.CSharp,
                    CachingProvider = new DefaultCachingProvider(t => { })
                };
                _service = RazorEngineService.Create(config);
                Cache.TryAdd(key, _service);
            }

            var first = true;

            foreach (var row in rows)
            {
                if (first)
                {
                    try {
                        var output = _service.RunCompile((string)Context.Operation.Template, (string)Context.Key, typeof(ExpandoObject), row.ToFriendlyExpandoObject(_input), null);
                        row[Context.Field] = _convert(output);
                        first = false;
                    } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex) {
                        Context.Error(ex.Message.Replace("{", "{{").Replace("}", "}}"));
                        yield break;
                    } catch (TemplateCompilationException ex) {
                        Context.Error(ex.Message.Replace("{", "{{").Replace("}", "}}"));
                        yield break;
                    }
                    yield return(row);
                }
                else
                {
                    var output = _service.Run(Context.Key, typeof(ExpandoObject), row.ToFriendlyExpandoObject(_input));
                    row[Context.Field] = _convert(output);
                    yield return(row);
                }
            }
        }
Ejemplo n.º 12
0
 private void GenerateHome(IRazorEngineService razor, List <object> providers)
 {
     using (var writer = new StreamWriter(_root + "index.htm"))
     {
         object model = providers.Select(p => p.GetType()).OrderBy(t => t.Name).ToList();
         razor.RunCompile("home", writer, null, model);
     }
 }
Ejemplo n.º 13
0
 public void Dispose()
 {
     if (_Engine != null)
     {
         _Engine.Dispose();
         _Engine = null;
     }
 }
Ejemplo n.º 14
0
 public MainController(IDocumentsRepository documentsRepository,
                       IDocumentSessionsRepository documentSessionsRepository,
                       IRazorEngineService razorEngineService)
 {
     this.documentsRepository        = documentsRepository;
     this.documentSessionsRepository = documentSessionsRepository;
     this.razorEngineService         = razorEngineService;
 }
Ejemplo n.º 15
0
 public AnubisDBMSSecurityEmailService(string templateDirectory)
 {
     _serviceConfiguration.BaseTemplateType = typeof(HtmlTemplateBase <>);
     _service = RazorEngineService.Create(_serviceConfiguration);
     var creacionUsuarioTemplateFile = Path.Combine(templateDirectory, "CreacionUsuario.html");
     var creacionUsuarioTemplate     = new LoadedTemplateSource("creacionUsuario", creacionUsuarioTemplateFile);
     //_service.AddTemplate("key", );
 }
Ejemplo n.º 16
0
        static CodeBuilder()
        {
            //初始化Razor
            var config = new TemplateServiceConfiguration();

            config.BaseTemplateType = typeof(InfinityServerTemplate <>);
            _razor = RazorEngineService.Create(config);
        }
Ejemplo n.º 17
0
        public RazorEngineRenderer()
        {
            ITemplateServiceConfiguration config = new TemplateServiceConfiguration
            {
                Debug = false,
            };

            _razorEngineService = RazorEngineService.Create(config);
        }
Ejemplo n.º 18
0
        public CSJSHandler()
        {
            config = new TemplateServiceConfiguration {
                ReferenceResolver = new CSJSReferenceResolver(),
                BaseTemplateType  = typeof(CSJSSupportTemplateBase <>)
            };

            service = RazorEngineService.Create(config);
        }
Ejemplo n.º 19
0
		public ProcessTemplateBase()
		{
			razorEngine = RazorEngineService.Create(
				new TemplateServiceConfiguration
				{
					//DisableTempFileLocking = true,
					//CachingProvider = new DefaultCachingProvider(x => { })
				});
		}
Ejemplo n.º 20
0
        public TemplateManager(string path)
        {
            _Path = path;
            var configuration = new TemplateServiceConfiguration();

            configuration.TemplateManager = _TemplateManager;
            configuration.CachingProvider = _CachingProvider;
            _Engine = RazorEngineService.Create(configuration);
        }
Ejemplo n.º 21
0
        static ThresholdCalculationEmailSubsystem()
        {
            var configuration = new TemplateServiceConfiguration {
                Debug = Debugger.IsAttached,
                DisableTempFileLocking = !Debugger.IsAttached
            };

            _razorEngineService = RazorEngineService.Create(configuration);
        }
        /// <summary>
        /// Adds and compiles a new template using the specified <paramref name="templateSource"/> and returns a <see cref="TemplateRunner{TModel}"/>.
        /// </summary>
        /// <typeparam name="TModel">The model type</typeparam>
        /// <param name="service"></param>
        /// <param name="templateSource"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ITemplateRunner <TModel> CompileRunner <TModel>(this IRazorEngineService service, string templateSource, string name)
        {
            var key = service.GetKey(name);

            service.AddTemplate(key, templateSource);
            service.Compile(key, typeof(TModel));

            return(new TemplateRunner <TModel>(service, key));
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Конструктор
 /// </summary>
 public UserInviteService(
     IInviteCodeRepository InviteRep,
     IUserRepository UserRep,
     IRazorEngineService TemplateServ)
 {
     this.InviteRep    = InviteRep;
     this.UserRep      = UserRep;
     this.TemplateServ = TemplateServ;
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RazorGenerator" /> class.
 /// </summary>
 /// <param name="templateManager">The template manager.</param>
 public RazorGenerator(ITemplateManager templateManager)
 {
     service = RazorEngineService.Create(new TemplateServiceConfiguration()
     {
         Language             = RazorEngine.Language.CSharp,
         EncodedStringFactory = new RawStringFactory(),
         TemplateManager      = templateManager,
     });
 }
Ejemplo n.º 25
0
 public ShopOrderService(IRazorEngineService razorService, IShopClientService clientService, IMailService mailService, ISettingsService settingsService, IShopService shopService, IShopPickupPointService pickupPointService, IShopPackService shopPackService)
 {
     _razorService       = razorService;
     _clientService      = clientService;
     _mailService        = mailService;
     _settingsService    = settingsService;
     _shopService        = shopService;
     _pickupPointService = pickupPointService;
     _shopPackService    = shopPackService;
 }
Ejemplo n.º 26
0
            /// <summary>
            /// 视图模板
            /// </summary>
            static Razor()
            {
                var config = new TemplateServiceConfiguration
                {
                    Debug           = true,
                    CachingProvider = new DefaultCachingProvider(t => { })
                };

                razor = RazorEngineService.Create(config);
            }
Ejemplo n.º 27
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static DesignedEmailHandler()
        {
            // Configure RazorEngine.
            var razorConfig = new TemplateServiceConfiguration()
            {
                Debug = Debugger.IsAttached
            };

            RazorService = RazorEngineService.Create(razorConfig);
        }
    public TemplatingService(Assembly assembly, string templatesNamespace)
    {
        var config = new TemplateServiceConfiguration();

        config.TemplateManager = new EmbeddedResourceTemplateService(assembly, templatesNamespace);
    #if DEBUG
        config.Debug = true;
    #endif
        this._razorEngineService = RazorEngineService.Create(config);
    }
Ejemplo n.º 29
0
 public RazorTemplateEngine(PipelineContext context, Configuration.Template template, IReader templateReader) {
     _context = context;
     _template = template;
     _templateReader = templateReader;
     var config = new FluentTemplateServiceConfiguration(
         c => c.WithEncoding(_template.ContentType == "html" ? Encoding.Html : Encoding.Raw)
               .WithCodeLanguage(Language.CSharp)
     );
     _service = RazorEngineService.Create(config);
 }
Ejemplo n.º 30
0
 public AccountController(ApplicationUserManager userManager,
                          ApplicationSignInManager signInManager,
                          IAuthenticationManager authManager,
                          IRazorEngineService razorEngine)
 {
     this.authManager   = authManager;
     this.razorEngine   = razorEngine;
     this.userManager   = userManager;
     this.signInManager = signInManager;
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Gets an instance of the Razor Engine Service
        /// </summary>
        /// <returns>RazorEngine Service</returns>
        public static IRazorEngineService getInstance()
        {
            if (service == null)
            {
                TemplateServiceConfiguration config = new TemplateServiceConfiguration();
                config.Language = RazorEngine.Language.CSharp;

                service = RazorEngineService.Create(config);
            }
            return service;
        }
Ejemplo n.º 32
0
        public RazorBusinessService()
        {
            var config = new TemplateServiceConfiguration
            {
                BaseTemplateType = typeof(MvcTemplateBase <>),
                CachingProvider  = new DefaultCachingProvider()
            };

            _service     = RazorEngineService.Create(config);
            Engine.Razor = _service;
        }
Ejemplo n.º 33
0
        static void Main(string[] args)
        {
            string template = "Hello @Model.Name, welcome to RazorEngine!";
            var    result   = Engine.Razor.RunCompile(template, "templateKey", null, new { Name = "World" });

            Console.WriteLine(result);

            string templateFilePath   = "HelloWorld.cshtml";
            var    templateFile       = File.ReadAllText(templateFilePath);
            string templateFileResult = Engine.Razor.RunCompile(templateFile, Guid.NewGuid().ToString(), null, new
            {
                Name = "World"
            });

            Console.WriteLine(templateFileResult);

            string copyRightTemplatePath = "CopyRightTemplate.cshtml";
            var    copyRightTemplate     = File.ReadAllText(copyRightTemplatePath);
            string copyRightResult       = Engine.Razor.RunCompile(copyRightTemplate, Guid.NewGuid().ToString(), typeof(CopyRightUserInfo), new CopyRightUserInfo
            {
                CreateTime   = DateTime.Now,
                EmailAddress = "*****@*****.**",
                UserName     = "******"
            });

            Console.WriteLine(copyRightResult);

            ITemplateServiceConfiguration configuration = new TemplateServiceConfiguration()
            {
                Language             = Language.CSharp,
                EncodedStringFactory = new RawStringFactory(),
                Debug = true
            };

            configuration.Namespaces.Add("Helpers");

            IRazorEngineService service = RazorEngineService.Create(configuration);

            string template2 = @"Hello @Model.Name, @TextHelper.Decorate(Model.Name)";
            string result2   = service.RunCompile(template2, "templateKey", null, new { Name = "World" });

            Console.WriteLine(result2);

            Engine.Razor = service;

            string template3     = "Hello @Model.Name, welcome to RazorEngine!";
            string templateFile3 = "C:/mytemplate.cshtml";
            var    result3       =
                Engine.Razor.RunCompile(new LoadedTemplateSource(template3, templateFile3), "templateKey3", null, new { Name = "World" });

            Console.WriteLine(result3);

            Console.ReadKey();
        }
Ejemplo n.º 34
0
        public string Parse(string rootView, object model)
        {
            var config = new TemplateServiceConfiguration();
            config.DisableTempFileLocking = true;
            config.CachingProvider = new DefaultCachingProvider(s => { });

            using (engine = RazorEngineService.Create(config))
            {
                LoadTemplates();

                var result = engine.Run(rootView, null, model);
                return result;
            }
        }
        public RazorResultController()
        {
            // Find templates in a web application
            _webPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin", "templates");

            var config = new TemplateServiceConfiguration
            {
                //Use this template manager when loading from template files. In attini we store in DB so need to load from strings
                //TemplateManager = new ResolvePathTemplateManager(new[] { _webPath })

                //Use this template manager when loading from template strings. In attini we store in DB so need to load from strings
                TemplateManager = new DelegateTemplateManager()
            };

            _service = RazorEngineService.Create(config);
        }
        internal IsolatedRazorEngineService(IConfigCreator configCreator, IAppDomainFactory appDomainFactory)
        {
            _appDomain = CreateAppDomain(appDomainFactory ?? new DefaultAppDomainFactory());
            var config = configCreator ?? new DefaultConfigCreator();

            ObjectHandle handle =
                Activator.CreateInstanceFrom(
                    _appDomain, typeof(SanboxHelper).Assembly.ManifestModule.FullyQualifiedName,
                    typeof(SanboxHelper).FullName
                );

            using (var helper = (SanboxHelper)handle.Unwrap())
            {
                _proxy = helper.CreateEngine(config);
            }
        }
		public RazorViewService(TemplateServiceConfiguration config)
		{
			config.Debug = true;
			_service = RazorEngineService.Create(config);
		}
Ejemplo n.º 38
0
        private RazorService()
        {
            TemplateServiceConfiguration config = new TemplateServiceConfiguration();
            config.DisableTempFileLocking = true; // loads the files in-memory (gives the templates full-trust permissions)
            config.CachingProvider = new DefaultCachingProvider(t => { }); //disables the warnings
            config.EncodedStringFactory = new RazorEngine.Text.RawStringFactory(); // Raw string encoding.

            // Use the config
            _service = RazorEngineService.Create(config); // new API
        }
 public DynamicWrapperService(IRazorEngineService origin, bool mustSerialize, bool allowMissingPropertiesOnDynamic)
 {
     _origin = origin;
     _mustSerialize = mustSerialize;
     _allowMissingPropertiesOnDynamic = allowMissingPropertiesOnDynamic;
 }
Ejemplo n.º 40
0
            public void Initialize()
            {
                string templateSource;
                var stream = typeof(Program).Assembly.GetManifestResourceStream("DescentGlovePie.Generator.Views." + TemplateName);
                if (stream == null)
                    throw new ApplicationException("Missing assembly resource for Razor view " + TemplateName);

                using (stream)
                {
                    templateSource = new StreamReader(stream).ReadToEnd();
                }

                // This template uses iSynaptic.Commons, so let's make sure the runtime loads it
                templateSource = templateSource.ToMaybe().Value;

                var config = new TemplateServiceConfiguration
                {
                    EncodedStringFactory = new RawStringFactory()
                };

                _razor = RazorEngineService.Create(config);

                _razor.Compile(templateSource, TemplateName, typeof(MapInfo));
            }