public DefaultCacheOptions(IEnvironmentSettings env)
 {
     Item ??= new CacheOptions
     {
         UseDistributedCache = SettingsEnvironmental.Get(env, "Cache:Distributed", "true").ToBool(true),
         UseLocalCache       = SettingsEnvironmental.Get(env, "Cache:Local", "true").ToBool(true)
     };
 }
Exemple #2
0
 public HealthCheck(HealthReport r, IEnvironmentSettings env)
 {
     Status  = r.Status.ToString();
     Version = SafeTry.IgnoreException(() =>
                                       SettingsEnvironmental.Get(env, "version") ?? Assembly.GetEntryAssembly()?.GetName().Version.ToString(),
                                       "Unknown"
                                       );
     Errors = r.Entries.Select(e => new { key = e.Key, value = e.Value.Status.ToString() });
 }
Exemple #3
0
        public static void CacheInvalidation(IServiceProvider sp)
        {
            var env     = ServiceLocator.Get <IEnvironmentSettings>(sp);
            var url     = SettingsEnvironmental.Get(env, "URL:Hub:Cache");
            var logger  = ServiceLocator.Get <ILogger>(sp);
            var signalR = ServiceLocator.Get <ISignalR>(sp);
            var memory  = ServiceLocator.Get <IMemoryCache>(sp);

            _ = SafeTry.LogException(logger, async() => await SignalRHub.Receive <string>(signalR, url, "Invalidate Cache", memory.Remove));
        }
        protected string CleanIpAddress(string ipAddress)
        {
            var ip = ipAddress.Replace("\"", "");

            // ReSharper disable once InvertIf
            if (ip.Equals("::1"))
            {
                var env = SettingsEnvironmental.Get(EnvSettings, "ASPNETCORE_ENVIRONMENT");
                if (env.Equals("localhost", BearerAndLocalhostComparison))
                {
                    return("127.0.0.1");
                }
            }
            return(ipAddress.KeepBefore(':').KeepBefore(','));
        }
Exemple #5
0
 public static string RedisUrl(IEnvironmentSettings env) => SettingsEnvironmental.Get(env, "URL:Redis");