public CacheProfile GetCacheProfile(CacheProfiles cacheProfile)
        {
            var cacheProfileKey = cacheProfile.ToString().ToLowerInvariant();

            if (_cacheProfiles == null || !_cacheProfiles.ContainsKey(cacheProfileKey))
            {
                throw new ErrorditeCacheException("CacheProfile with key {0} does not exist.".FormatWith(cacheProfileKey));
            }

            return(_cacheProfiles[cacheProfileKey]);
        }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

            // Get config options
            services.AddConfigRegistration(Configuration);

            // Configure database
            services.AddDatabase(Configuration, Logging, env);

            // Configure application services
            services.AddServiceRegistration();

            // Adds profiler service for performance checking
            services.AddMiniProfiler();

            // Adds response caching and compression
            services.AddCachingAndCompression();

            // Configure AAD
            services.AddAzureADAuth(Configuration);

            // Adds server side Application Insights
            services.AddApplicationInsightsTelemetry();

            // Configure cookie policy options
            services.ConfigureCookiePolicy();

            // Configure antiforgery token options
            services.AddAntiforgery(opts => opts.Cookie.Name = CookieNames.AntiForgery);

            // Add controllers + views instead of razor pages
            services.AddControllersWithViews();

            // Add/configure MVC
            services.AddMvc(options =>
            {
                // require user is logged in to access anything by default unless in dev
                if (env != "Development")
                {
                    AuthOptions.AddAuthOptions(options);
                }

                // Automatically add an anti-forgery token to any http request method that alters server state
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());

                // add cache profiles
                CacheProfiles.AddCacheProfiles(options);
            });
        }
Example #3
0
 public ErrorditeCacheProfileNotFoundException(CacheProfiles cacheProfile)
     : base("CacheProfile with key {0} could not be found in cache configuration.".FormatWith(cacheProfile.ToString()))
 {
 }
 public CacheInvalidationItem(CacheProfiles cacheProfile, string cacheItemKey)
     : this(cacheProfile, cacheItemKey, false)
 {
 }
 public CacheInvalidationItem(CacheProfiles cacheProfile, string cacheItemKey, bool isKeyPrefix)
 {
     IsKeyPrefix  = isKeyPrefix;
     CacheItemKey = cacheItemKey;
     CacheProfile = cacheProfile;
 }
Example #6
0
 public CacheProfile GetCacheProfile(CacheProfiles cacheProfile)
 {
     return(new CacheProfile(1, "test", ObjectFactory.GetObject <ICacheEngine>()));
 }
Example #7
0
 public CacheProfile GetCacheProfile(CacheProfiles cacheProfile)
 {
     return(new CacheProfile(1, "", new NullCacheEngine()));
 }