コード例 #1
0
ファイル: RegionalKeyWrapper.cs プロジェクト: abayaz61/NCache
 public RegionalKeyWrapper(NCacheSessionStateSettings affinitySettings, ISessionKeyManager keyManager)
 {
     _affinitySettings = affinitySettings;
     _keyManager       = keyManager;
     foreach (DictionaryEntry entry in _affinitySettings.PrimaryCache)
     {
         _primaryPrefix = (string)entry.Key;
     }
 }
コード例 #2
0
 public TokenProvider(ISessionKeyManager sessionKeyManager)
 {
     this.sessionKeyManager = sessionKeyManager;
 }
コード例 #3
0
 public LoginController(IDataAccess dataAccess, ISessionKeyManager sessionKeyManager)
 {
     _dataAccess        = dataAccess;
     _sessionKeyManager = sessionKeyManager;
 }
コード例 #4
0
        public NCacheSessionStoreService(IOptions <NCacheSessionConfiguration> options, ISessionKeyManager keyManager)
        {
            _options    = options;
            _keyManager = keyManager;
            NameValueCollection nvc = new NameValueCollection {
                { "cacheName", _options.Value.CacheName }
            };

            if (_options.Value.ExceptionsEnabled != null)
            {
                nvc.Add("exceptionsEnabled", _options.Value.ExceptionsEnabled.Value.ToString());
            }

            if (_options.Value.WriteExceptionsToEventLog != null)
            {
                nvc.Add("writeExceptionsToEventLog", _options.Value.WriteExceptionsToEventLog.Value.ToString());
            }

            if (_options.Value.EnableLogs != null)
            {
                nvc.Add("enableLogs", _options.Value.EnableLogs.Value.ToString());
            }

            if (_options.Value.EnableDetailLogs != null)
            {
                nvc.Add("enableDetailLogs", _options.Value.EnableDetailLogs.Value.ToString());
            }

            if (_options.Value.EnableSessionLocking != null)
            {
                nvc.Add("enableSessionLocking", _options.Value.EnableSessionLocking.Value.ToString());
            }

            if (_options.Value.SessionAppId != null)
            {
                nvc.Add("sessionAppId", _options.Value.SessionAppId);
            }

            if (_options.Value.InprocDelay != null)
            {
                nvc.Add("inprocDelay", _options.Value.InprocDelay.Value.ToString());
            }

            if (_options.Value.OperationRetry != null)
            {
                nvc.Add("operationRetry", _options.Value.OperationRetry.Value.ToString());
            }

            if (_options.Value.OperationRetryInterval != null)
            {
                nvc.Add("operationRetryInterval", _options.Value.OperationRetryInterval.Value.ToString());
            }

            nvc.Add("defaultSessionTimeout", (_options.Value.RequestTimeout != 0? _options.Value.RequestTimeout.ToString():"120"));
            NCacheSessionStateSettings affinitySettings = null;

            if (_options.Value.EnableLocationAffinity != null && _options.Value.EnableLocationAffinity.Value)
            {
                affinitySettings = new NCacheSessionStateSettings
                {
                    PrimaryCache    = new Hashtable(),
                    SecondaryCaches = new Hashtable()
                };
                foreach (var cacheAffinity in _options.Value.AffinityMapping)
                {
                    if (cacheAffinity.CacheName == null || cacheAffinity.CachePrefix == null ||
                        cacheAffinity.CachePrefix.Length < 4)
                    {
                        throw new ConfigurationErrorsException("Invalid cache affinity settings specified. ");
                    }
                    if (affinitySettings.PrimaryCache.Count == 0 &&
                        cacheAffinity.CacheName.Equals(_options.Value.CacheName))
                    {
                        affinitySettings.PrimaryCache.Add(cacheAffinity.CachePrefix, cacheAffinity.CacheName);
                    }
                    else if (!affinitySettings.SecondaryCaches.ContainsKey(cacheAffinity.CachePrefix))
                    {
                        affinitySettings.SecondaryCaches.Add(cacheAffinity.CachePrefix, cacheAffinity.CacheName);
                    }
                }
                if (affinitySettings.PrimaryCache.Count == 0)
                {
                    throw new ConfigurationErrorsException(
                              "No affinity setting has been specified for the primary cache. ");
                }
                _keyManager = new RegionalKeyWrapper(affinitySettings, _keyManager);
            }
            _store = new NCacheCoreSessionStore();
            _store.Initialize(null, nvc, affinitySettings);
        }