public void Connect(IDictionary <string, string> properties) { using (new LogMethodExecution(ConnectorTypeDescription, methodInfo.GetCurrentMethodName())) { try { // validate & get connection properties var connectionProps = ScriptRunnerConnectionHelper.GetConnectionProperties(properties); service = new ScriptRunnerService(); service.Connect(connectionProps); metadataProvider = new ScriptRunnerMetadataProvider(service); } catch (InvalidConnectionException) { clearLocals(); throw; } catch (Exception exception) { clearLocals(); unhandledExecptionHandler(methodInfo.GetCurrentMethodName(), exception); } } }
internal ScriptRunnerMetadataProvider(ScriptRunnerService service) { methodInfo = new MethodInfo(GetType().Name); if (service == null || service.IsConnected == false) { throw new ApplicationException("Must connect creating Metadata Provider"); } this.service = service; }
private void clearLocals() { if (metadataProvider != null) { metadataProvider.Dispose(); metadataProvider = null; } if (service != null) { service.Disconnect(); service = null; } }
protected virtual void Dispose(bool disposing) { // free managed resources service = null; }