private async Task <Type> ResolveTemplateTypeAsync <T>(string path, CultureInfo culture) { var cacheKey = new TemplateCacheKey(path, culture); try { var cacheItem = _cache.Get(cacheKey); if (cacheItem != null) { return(cacheItem.TemplateInfo); } var templateStream = _resourceProvider.Get(path, culture); var type = await _compiler.CompileAsync(templateStream, typeof(T)); _cache.Put(cacheKey, type, _cacheExpiration); return(type); } catch (ResourceNotFoundException ex) { throw new TemplateEngineException(ex); } catch (CompilationException ex) { throw new TemplateEngineException(ex); } catch (Exception ex) { throw new TemplateEngineException("Can't resolve template type.", ex); } }
private Type ResolveTemplateType(string path, CultureInfo culture, object model) { Contract.Requires(culture != null); var cacheKey = new TemplateCacheKey(path, culture); try { var cacheItem = _cache.Get(cacheKey); if (cacheItem != null) { return(cacheItem.TemplateInfo); } var templateStream = _resourceProvider.Get(path, culture); var type = _compiler.Compile(templateStream, model.GetType()); _cache.Put(cacheKey, type, _cacheExpiration); return(type); } catch (ResourceNotFoundException ex) { throw new TemplateEngineException(ex); } catch (CompilationException ex) { throw new TemplateEngineException(ex); } catch (Exception ex) { throw new TemplateEngineException("Can't resolve template type.", ex); } }
public bool Put(TemplateCacheKey key, T templateInfo, TimeSpan slidingExpiration) { Contract.Requires <ArgumentNullException>(key != null); Contract.Requires <ArgumentException>(slidingExpiration.Ticks > 0); throw new NotImplementedException(); }
/// <summary> /// Constructor for dimensional model based on full specific data /// </summary> /// <param name="length">Length parameter of the model</param> /// <param name="height">Height parameter of the model</param> /// <param name="width">Width parameter of the model</param> /// <param name="backingDataKey">dimensional model backing data id</param> /// <param name="materialComps">The material compositions</param> public DimensionalModel(int length, int height, int width, int vacuity, int surfaceCavitation, TemplateCacheKey backingDataKey, HashSet <IModelPartComposition> materialComps) { Length = length; Height = height; Width = width; Vacuity = vacuity; SurfaceCavitation = surfaceCavitation; Composition = materialComps; _modelTemplate = backingDataKey; }
public TemplateCacheItem <T> Get(TemplateCacheKey key) { Contract.Requires <ArgumentNullException>(key != null); throw new NotImplementedException(); }
public bool ContainsKey(TemplateCacheKey key) { Contract.Requires <ArgumentNullException>(key != null); throw new NotImplementedException(); }