public override string ToString() { if (TemplateKey.IsDefaultTemplateType(_templateType)) { return(string.Format("{0} => {1}", Name, CompiledType)); } else { return(string.Format("{0} ({2}) => {1}", Name, CompiledType, Type)); } }
public HxlCompiledTemplateInfo FindTemplate(string name, string type) { if (name == null) { throw new ArgumentNullException("name"); } if (string.IsNullOrEmpty(name)) { throw Failure.EmptyString("name"); } var candidates = _templates[name]; Func <HxlCompiledTemplateInfo, bool> predicate = t => t.Type == type || TemplateKey.IsDefaultTemplateType(t.Type); return(candidates.FirstOrDefault(predicate)); }
public HxlTemplate CreateTemplate(string templateName, string templateType, IServiceProvider serviceProvider) { if (templateName == null) { throw new ArgumentNullException("templateName"); } if (string.IsNullOrEmpty(templateName)) { throw Failure.EmptyString("templateName"); } // Optimize by reusing previous factory by name IHxlTemplateFactory previous; var key = new TemplateKey(templateName, templateType); if (previousCache.TryGetValue(key, out previous)) { var result = previous.CreateTemplate(templateName, templateType, serviceProvider); if (result != null) { return(result); } } foreach (var f in values) { var template = f.CreateTemplate(templateName, templateType, serviceProvider); if (template != null) { previousCache[key] = f; return(template); } } return(null); }
public bool Equals(TemplateKey other) { return(string.Equals(_templateName, other._templateName, StringComparison.OrdinalIgnoreCase) && string.Equals(_templateType, other._templateType, StringComparison.OrdinalIgnoreCase)); }