• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ITemplateKey类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ITemplateKey的典型用法代码示例。如果您正苦于以下问题:C# ITemplateKey类的具体用法?C# ITemplateKey怎么用?C# ITemplateKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ITemplateKey类属于命名空间,在下文中一共展示了ITemplateKey类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: KeysHaveEqualModifiedTime

        private bool KeysHaveEqualModifiedTime(ITemplateKey key1, ITemplateKey key2)
        {
            var keyWithTime1 = (FullPathWithModifiedTimeTemplateKey)key1;
            var keyWithTime2 = (FullPathWithModifiedTimeTemplateKey)key2;

            return keyWithTime1.ModifiedTime == keyWithTime2.ModifiedTime;
        }
开发者ID:RoboBurned,项目名称:RazorEngine,代码行数:7,代码来源:InvalidatingByModifiedTimeCachingProvider.cs


示例2: AddDynamic

 public void AddDynamic(ITemplateKey key, ITemplateSource source)
 {
     // You can disable dynamic templates completely, but 
     // then all convenience methods (Compile and RunCompile) with
     // a TemplateSource will no longer work (they are not really needed anyway).
     throw new NotImplementedException("dynamic templates are not supported!");
 }
开发者ID:RodionKulin,项目名称:SignaloBot,代码行数:7,代码来源:RazorTemplateManager.cs


示例3: AddDynamic

 public void AddDynamic(ITemplateKey key, ITemplateSource source)
 {
     if (!_templates.ContainsKey(key))
     {
         _templates.Add(key, source);
     }
 }
开发者ID:impressive-mark,项目名称:pretzel,代码行数:7,代码来源:IncludesResolver.cs


示例4: GetKey

 /// <summary>
 /// Get the given key.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="resolveType"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 public ITemplateKey GetKey(string name, ResolveType resolveType, ITemplateKey context)
 {
     if (File.Exists (name))
     {
         return new FullPathTemplateKey(name, name, resolveType, context);
     }
     else
     {
         var resolved = layoutRoots.Select(l =>
             {
                 var p = Path.Combine(l, name);
                 if (File.Exists(p))
                 {
                     return p;
                 }
                 else if (File.Exists(p + ".cshtml"))
                 {
                     return p + ".cshtml"; 
                 } 
                 else
                 {
                     return null;
                 }
             }).Where(l => l != null).FirstOrDefault();
         if (resolved == null)
         {
             throw new InvalidOperationException(string.Format("Could not resolve template {0}", name));
         }
         else
         {
             return new FullPathTemplateKey(name, resolved, resolveType, context);
         }
     }
 }
开发者ID:MatthewSJones,项目名称:RazorEngine,代码行数:41,代码来源:ResolvePathTemplateManager.cs


示例5: GetKey

        public ITemplateKey GetKey(string name, ResolveType resolveType, ITemplateKey context)
        {
            if (ManifestResourceHelper.checkExistsManifestResource(name))
            {
                return new ResourcePathTemplateKey(name, name, resolveType, context);
            }

            var existsResourceNames = layoutRoots.Select(m =>
            {
                string resourcePath = string.Format(m, name);
                if (ManifestResourceHelper.checkExistsManifestResource(resourcePath))
                {
                    return resourcePath;
                }
                resourcePath += ".cshtml";
                if (ManifestResourceHelper.checkExistsManifestResource(resourcePath))
                {
                    return resourcePath;
                }
                return null;               
            });

            var resourceName = existsResourceNames.Where(m => !string.IsNullOrEmpty(m)).FirstOrDefault();
            if (resourceName == null)
            {
                throw new InvalidOperationException(string.Format("Could not resolve template {0}", name));
            }

            return new ResourcePathTemplateKey(name, resourceName, resolveType, context);
        }
开发者ID:wanlitao,项目名称:Aspnet.WebApi.HelpPage,代码行数:30,代码来源:ResolveManifestTemplateManager.cs


示例6: GetKey

        /// <summary>
        /// Get the given key.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="resolveType"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public new ITemplateKey GetKey(string name, ResolveType resolveType, ITemplateKey context)
        {
            var fullPath = ResolveFilePath(name);
            var modifiedTime = File.GetLastWriteTimeUtc(fullPath);

            return new FullPathWithModifiedTimeTemplateKey(name, fullPath, modifiedTime, resolveType, context);
        }
开发者ID:RoboBurned,项目名称:RazorEngine,代码行数:14,代码来源:ResolvePathCheckModifiedTimeTemplateManager.cs


示例7: GetKey

 public ITemplateKey GetKey(string name, ResolveType resolveType, ITemplateKey context)
 {
     // If you can have different templates with the same name depending on the
     // context or the resolveType you need your own implementation here!
     // Otherwise you can just use NameOnlyTemplateKey.
     return new NameOnlyTemplateKey(name, resolveType, context);
 }
开发者ID:aviatrix,项目名称:RazorEngineTest,代码行数:7,代码来源:TemplateManager.cs


示例8: CacheTemplateHelper

 private void CacheTemplateHelper(ICompiledTemplate template, ITemplateKey templateKey, Type modelTypeKey)
 {
     var uniqueKey = templateKey.GetUniqueKeyString();
     _cache.AddOrUpdate(uniqueKey, key =>
     {
         // new item added
         _assemblies.Add(template.TemplateAssembly);
         var dict = new ConcurrentDictionary<Type, ICompiledTemplate>();
         dict.AddOrUpdate(modelTypeKey, template, (t, old) => {
             throw new Exception("Expected the dictionary to be empty."); });
         return dict;
     }, (key, dict) =>
     {
         dict.AddOrUpdate(modelTypeKey, t =>
         {
             // new item added (template was not compiled with the given type).
             _assemblies.Add(template.TemplateAssembly);
             return template;
         }, (t, old) =>
         {
             // item was already added before
             return template;
         });
         return dict;
     });
 }
开发者ID:MatthewSJones,项目名称:RazorEngine,代码行数:26,代码来源:InvalidatingCachingProvider.cs


示例9: Resolve

        public ITemplateSource Resolve(ITemplateKey key)
        {
            if (_templates.ContainsKey(key))
            {
                return _templates[key];
            }

            var templatePath = Path.Combine(includesPath, key.Name);
            var templateExists = fileSystem.File.Exists(templatePath);
            if (!templateExists)
            {
                foreach (var ext in new[] { ".cshtml", ".html", ".htm" })
                {
                    var testPath = String.Concat(templatePath, ext);
                    templateExists = fileSystem.File.Exists(testPath);
                    if (templateExists)
                    {
                        templatePath = testPath;
                        break;
                    }
                }
            }

            var template = templateExists ? fileSystem.File.ReadAllText(templatePath) : String.Empty;

            return new LoadedTemplateSource(template, null);
        }
开发者ID:impressive-mark,项目名称:pretzel,代码行数:27,代码来源:IncludesResolver.cs


示例10: Compile

 /// <summary>
 /// Compiles the specified template.
 /// </summary>
 /// <param name="key">The string template.</param>
 /// <param name="modelType">The model type.</param>
 public ICompiledTemplate Compile(ITemplateKey key, Type modelType)
 {
     Contract.Requires(key != null);
     var source = Resolve(key);
     var result = CreateTemplateType(source, modelType);
     return new CompiledTemplate(result.Item2, key, source, result.Item1, modelType);
 }
开发者ID:SharpeRAD,项目名称:RazorEngine,代码行数:12,代码来源:RazorEngineCore.cs


示例11: Resolve

        //методы
        public ITemplateSource Resolve(ITemplateKey key)
        {
            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _templateFolder, key.Name);
            string template = File.ReadAllText(filePath);

            // Provide a non-null file to improve debugging
            return new LoadedTemplateSource(template, filePath);
        }
开发者ID:RodionKulin,项目名称:SignaloBot,代码行数:9,代码来源:RazorTemplateManager.cs


示例12: CompiledTemplate

 public CompiledTemplate(CompilationData tempFiles, ITemplateKey key, ITemplateSource source, Type templateType, Type modelType)
 {
     _tempFiles = tempFiles;
     _key = key;
     _source = source;
     _templateType = templateType;
     _modelType = modelType;
 }
开发者ID:MatthewSJones,项目名称:RazorEngine,代码行数:8,代码来源:CompiledTemplate.cs


示例13: InternalTemplateService

        public InternalTemplateService(RazorEngineCore service, ITemplateKey template)
        {
            Contract.Requires(service != null);
            Contract.Requires(template != null);

            _service = service;
            _template = template;
        }
开发者ID:rmeshksar,项目名称:RazorEngine,代码行数:8,代码来源:InternalTemplateService.cs


示例14: Resolve

 public ITemplateSource Resolve(ITemplateKey key)
 {
     ResourcePathTemplateKey resourcePathTemplateKey = key as ResourcePathTemplateKey;
     if (resourcePathTemplateKey == null)
     {
         throw new NotSupportedException("You can only use ResourcePathTemplateKey with this manager");
     }
     return new LoadedTemplateSource(ManifestResourceHelper.getManifestResourceString(resourcePathTemplateKey.ResourcePath),
         resourcePathTemplateKey.ResourcePath);
 }
开发者ID:wanlitao,项目名称:Aspnet.WebApi.HelpPage,代码行数:10,代码来源:ResolveManifestTemplateManager.cs


示例15: Resolve

 /// <summary>
 /// Resolve the given key
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public ITemplateSource Resolve(ITemplateKey key)
 {
     var full = key as FullPathTemplateKey;
     if (full == null)
     {
         throw new NotSupportedException("You can only use FullPathTemplateKey with this manager");
     }
     var template = File.ReadAllText(full.FullPath);
     return new LoadedTemplateSource(template, full.FullPath);
 }
开发者ID:MatthewSJones,项目名称:RazorEngine,代码行数:15,代码来源:ResolvePathTemplateManager.cs


示例16: Resolve

 /// <summary>
 /// Resolves the template content with the specified key.
 /// </summary>
 /// <param name="key">The key of the template to resolve.</param>
 /// <returns>The template content.</returns>
 public ITemplateSource Resolve(ITemplateKey key)
 {
     ITemplateSource result;
     if (_dynamicTemplates.TryGetValue(key, out result))
     {
         return result;
     }
     var templateString = _resolver.Resolve(key.Name);
     return new LoadedTemplateSource(templateString);
 }
开发者ID:MatthewSJones,项目名称:RazorEngine,代码行数:15,代码来源:WrapperTemplateManager.cs


示例17: Resolve

 /// <summary>
 ///     Resolves the template with the specified key.
 /// </summary>
 /// <param name="key">The key which should be resolved to a template source.</param>
 /// <returns>
 ///     The template content.
 /// </returns>
 public ITemplateSource Resolve(ITemplateKey key)
 {
     var fullPath = _viewsPathResolver.ResolveFullPath(key.Name);
     string template;
     using (var fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     using (var sr = new StreamReader(fs, Encoding.UTF8))
     {
         template = sr.ReadToEnd();
     }
     return new LoadedTemplateSource(template);
 }
开发者ID:riberk,项目名称:Rib.Common,代码行数:18,代码来源:TemplateManager.cs


示例18: AddDynamic

 /// <summary>
 /// Adds a template dynamically.
 /// </summary>
 /// <param name="key">the key of the template</param>
 /// <param name="source">the source of the template</param>
 public void AddDynamic(ITemplateKey key, ITemplateSource source)
 {
     _dynamicTemplates.AddOrUpdate(key, source, (k, oldSource) =>
     {
         if (oldSource.Template != source.Template)
         {
             throw new InvalidOperationException("The same key was used for another template!");
         }
         return source;
     });
 }
开发者ID:MatthewSJones,项目名称:RazorEngine,代码行数:16,代码来源:WrapperTemplateManager.cs


示例19: GetKey

		public ITemplateKey GetKey(string name, ResolveType resolveType, ITemplateKey context)
		{
			var itk = context as IdentityTemplateKey;

			if (itk != null)
			{
				return new IdentityTemplateKey(name, itk.ClientId, itk.Tenant, resolveType);
			}

			return null;
		}
开发者ID:vdaron,项目名称:IdentityServer.RazorViewEngine,代码行数:11,代码来源:IdentityTemplateManager.cs


示例20: ResolveInternal

 internal override ITemplate ResolveInternal(string cacheName, object model, Type modelType, DynamicViewBag viewbag, ResolveType resolveType, ITemplateKey context)
 {
     var templateKey = GetKey(cacheName, resolveType, context);
     ICompiledTemplate compiledTemplate;
     if (!Configuration.CachingProvider.TryRetrieveTemplate(templateKey, modelType, out compiledTemplate))
     {
         compiledTemplate = Compile(templateKey, modelType);
         Configuration.CachingProvider.CacheTemplate(compiledTemplate, templateKey);
     }
     return CreateTemplate(compiledTemplate, model, viewbag);
 }
开发者ID:lijianguang,项目名称:RazorEngine,代码行数:11,代码来源:RazorEngineCoreWithCache.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ITermAttribute类代码示例发布时间:2022-05-24
下一篇:
C# ITemplate类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap