internal async Task HandleInitializeRequest(EditInitializeParams initParams, RequestContext <EditInitializeResult> requestContext) { Func <Exception, Task> executionFailureHandler = (e) => SendSessionReadyEvent(requestContext, initParams.OwnerUri, false, e.Message); Func <Task> executionSuccessHandler = () => SendSessionReadyEvent(requestContext, initParams.OwnerUri, true, null); EditSession.Connector connector = () => connectionService.GetOrOpenConnection(initParams.OwnerUri, ConnectionType.Edit, alwaysPersistSecurity: true); EditSession.QueryRunner queryRunner = q => SessionInitializeQueryRunner(initParams.OwnerUri, requestContext, q); try { // Make sure we have info to process this request Validate.IsNotNullOrWhitespaceString(nameof(initParams.OwnerUri), initParams.OwnerUri); Validate.IsNotNullOrWhitespaceString(nameof(initParams.ObjectName), initParams.ObjectName); Validate.IsNotNullOrWhitespaceString(nameof(initParams.ObjectType), initParams.ObjectType); // Create a session and add it to the session list EditSession session = new EditSession(metadataFactory); if (!ActiveSessions.TryAdd(initParams.OwnerUri, session)) { throw new InvalidOperationException(SR.EditDataSessionAlreadyExists); } // Initialize the session session.Initialize(initParams, connector, queryRunner, executionSuccessHandler, executionFailureHandler); // Send the result await requestContext.SendResult(new EditInitializeResult()); } catch (Exception e) { await requestContext.SendError(e.Message); } }