Exemplo n.º 1
0
        public StandaloneHtmlHelpers(ITemplateService templateService, dynamic viewBag, TModel model)
        {
            this._model           = model;
            this._executeContext  = (viewBag == null) ? new ExecuteContext() : new ExecuteContext(viewBag);
            this._templateService = templateService ?? new TemplateService();
            this._viewSettings    = viewBag == null ? null : viewBag.ViewSettings as ViewSettings;

            //this._viewSettings = UtilHelper.GetDynamicMember(viewBag, "ViewSettings") as ViewSettings;
        }
Exemplo n.º 2
0
        public virtual void RegisterHelpers(ViewSettings viewSettings)
        {
            var helpers = new HandlebarsHelpers(_hbsService, viewSettings, ResourcesNamespace);

            var methods = helpers.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance)
                          .Where(m => m.Name.StartsWith("Register"));

            foreach (var method in methods)
            {
                method.Invoke(helpers, new object[0]);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="templateResolver"></param>
 /// <param name="viewSettings"></param>
 public TemplateService(ITemplateResolver templateResolver, ViewSettings viewSettings)
 {
     _templateResolver = templateResolver;
     _hbsService       = Handlebars.Create();
     RegisterHelpers(viewSettings);
     _templateResolver.GetAllPartialTemplates().ForEach(template =>
     {
         try
         {
             _hbsService.RegisterTemplate(template.Key, template.Value);
         }
         catch (System.Exception ex)
         {
             throw new System.Exception($"Error at template key = {template.Key}", ex);
         }
     });
 }
Exemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="hbsService"></param>
 /// <param name="viewSettings"></param>
 public HandlebarsHelpers(IHandlebars hbsService, ViewSettings viewSettings, string resourcesDefaultNamespace)
 {
     _hbsService   = hbsService;
     _viewSettings = viewSettings;
     _resourcesDefaultNamespace = resourcesDefaultNamespace;
 }
 public StandaloneUrlHelpers(dynamic viewBag, TModel model)
 {
     this._model   = model;
     _viewSettings = viewBag.ViewSettings as ViewSettings;
 }