/// <summary> /// initilaise /// </summary> protected virtual void Initialize() { CacheService cacheService = null; if (RuntimeContext.CurrentContext == RtContextValue.JVCACHE) { cacheService = new JvCacheRPCService(_address, _port); cacheService.OnGetSecurityCredentials += new EventHandler <CredentialsEventArgs>(OnGetSecurityCredentials); } else { cacheService = new NCacheRPCService(_address, _port); } try { _server = cacheService.GetCacheServer(TimeSpan.FromSeconds(7)); } catch (SshAuthenticationException) { throw new Exception("Could not authenticate on server. Incorrect Username or Password."); } catch (Exception) { throw; } finally { cacheService.Dispose(); } }
/// <summary> /// Creates and returns an instance of NCache. /// </summary> /// <param name="data"></param> /// <param name="timeout"></param> /// <returns>A reference to <see cref="Cache"/> object.</returns> private static Alachisoft.NCache.Caching.Cache ConnectCacheInstance(CacheConfig data, TimeSpan timeout, bool autoStart) { CacheService ncache; if (RuntimeContext.CurrentContext == RtContextValue.JVCACHE) { ncache = new JvCacheRPCService(data.ServerName, (int)data.Port); } else { ncache = new NCacheRPCService(data.ServerName, (int)data.Port); } try { ncache.UseTcp = data.UseTcp; ncache.ServerName = data.ServerName; ncache.Port = data.Port; if (ncache.ServerName == null || ncache.ServerName.Length < 1 || ncache.ServerName.CompareTo(".") == 0 || ncache.ServerName.CompareTo("localhost") == 0) { ncache.ServerName = Environment.MachineName; } } catch (Exception) { throw; } finally { ncache.Dispose(); } return(null); }