コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        public bool Put(TemplateCacheKey key, T templateInfo, TimeSpan slidingExpiration)
        {
            Contract.Requires <ArgumentNullException>(key != null);
            Contract.Requires <ArgumentException>(slidingExpiration.Ticks > 0);

            throw new NotImplementedException();
        }
コード例 #4
0
        /// <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;
        }
コード例 #5
0
        public TemplateCacheItem <T> Get(TemplateCacheKey key)
        {
            Contract.Requires <ArgumentNullException>(key != null);

            throw new NotImplementedException();
        }
コード例 #6
0
        public bool ContainsKey(TemplateCacheKey key)
        {
            Contract.Requires <ArgumentNullException>(key != null);

            throw new NotImplementedException();
        }