当前位置: 首页>>代码示例>>C#>>正文


C# TemplateService.AddNamespace方法代码示例

本文整理汇总了C#中TemplateService.AddNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# TemplateService.AddNamespace方法的具体用法?C# TemplateService.AddNamespace怎么用?C# TemplateService.AddNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TemplateService的用法示例。


在下文中一共展示了TemplateService.AddNamespace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConnectionList

 /// <summary>
 /// </summary>
 /// <returns></returns>
 internal static string ConnectionList()
 {
     var fileName = FilePath + "\\ConnectionList.htm";
     String content;
     var stream = new StreamReader(fileName);
     content = stream.ReadToEnd();
     var connectionList = String.Empty;
     foreach (var item in
         RuntimeMongoDBContext._mongoConnectionConfigList.Values)
     {
         if (item.ReplSetName == String.Empty)
         {
             connectionList += "<li><a href = 'Connection?" + item.ConnectionName + "'>" + item.ConnectionName +
                               "@" + (item.Host == String.Empty ? "localhost" : item.Host)
                               + (item.Port == 0 ? String.Empty : ":" + item.Port) + "</a></li>" +
                               Environment.NewLine;
         }
         else
         {
             connectionList += "<li><a href = 'Connection?" + item.ConnectionName + "'>" + item.ConnectionName +
                               "</a></li>" + Environment.NewLine;
         }
     }
     var config = new TemplateServiceConfiguration();
     //config.ReferenceResolver = (IReferenceResolver)((new UseCurrentAssembliesReferenceResolver()).GetReferences(null));
     config.Debug = true;
     var ser = new TemplateService(config);
     ser.AddNamespace("MongoUtility.Core");
     ser.AddNamespace("SystemUtility");
     Razor.SetTemplateService(ser);
     content = Razor.Parse(content, new {SystemConfig.config.ConnectionList});
     return content;
 }
开发者ID:jango2015,项目名称:MongoCola,代码行数:36,代码来源:GetPage.cs

示例2: Main

        static void Main()
        {
            string dirsrc = Directory.GetCurrentDirectory();
            Directory.SetCurrentDirectory(Path.Combine(dirsrc, @"..\BBQ"));

            using (var service = new TemplateService())
            {
                service.AddNamespace("test_RazorHandy");

                service.GetTemplate(File.ReadAllText(@".\Views\Shared\_L.cshtml"), null, "~/Views/Shared/_L.cshtml");
                var result = service.Parse(File.ReadAllText(@".\Views\bbq\Index.cshtml"), new { }, null, "page");

                Directory.SetCurrentDirectory(dirsrc);

                File.WriteAllText(@".\BBQ_static\index.html", result);

            }
        }
开发者ID:alejandraa,项目名称:TaskMQ,代码行数:18,代码来源:create_BBQ_static_html.cs

示例3: AddDefaultNamespacesFromWebConfig

        /// <summary>
        /// Add the namespaces found in the ASP.NET MVC configuration section of the Web.config file to the provided TemplateService instance.
        /// </summary>
        private static void AddDefaultNamespacesFromWebConfig(TemplateService templateService)
        {
            var webConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web.config");
            if (!File.Exists(webConfigPath))
                return;

            var fileMap = new ExeConfigurationFileMap() { ExeConfigFilename = webConfigPath };
            var configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            var razorConfig = configuration.GetSection("system.web.webPages.razor/pages") as RazorPagesSection;

            if (razorConfig == null)
                return;

            foreach (NamespaceInfo namespaceInfo in razorConfig.Namespaces)
            {
                templateService.AddNamespace(namespaceInfo.Namespace);
            }
        }
开发者ID:dperlyuk,项目名称:RazorEngineEmails,代码行数:21,代码来源:Program.cs

示例4: AssertAllViewsInAssemblyCanBeCompiled

        private void AssertAllViewsInAssemblyCanBeCompiled(Assembly assembly)
        {
            var config = new TemplateServiceConfiguration();
            config.BaseTemplateType = typeof(MvcTemplateBase<>);

            var processor = new TemplateService(config);

            var resourceNames = assembly.GetManifestResourceNames();

            foreach (var resource in resourceNames)
            {
                if (resource.EndsWith(".cshtml", StringComparison.OrdinalIgnoreCase))
                {
                    var content = this.GetEmbeddedViewContent(resource, assembly);

                    // The namespace for ChildActionExtensions
                    processor.AddNamespace("System.Web.Mvc.Html");

                    processor.AddNamespace("System.Web");

                    this.AssertViewCanBeCompiled(content, resource, processor);
                }
            }

            processor.Dispose();
        }
开发者ID:RichiL,项目名称:feather-widgets,代码行数:26,代码来源:ViewsCompilationTests.cs


注:本文中的TemplateService.AddNamespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。