private Registration Register(Registration registration)
        {
            var registrationType = _handlerTypeDescriptorProvider.GetRegistrationType(registration.Method);

            if (registrationType == null)
            {
                // vscode client throws if given an unknown registration type
                _logger.LogError("Unknown Registration Type {Method} {@Registration}", registration.Method, registration);
                throw new NotSupportedException($"Unknown Registration Type '{registration.Method}'");
            }

            var deserializedRegistration = new Registration {
                Id              = registration.Id,
                Method          = registration.Method,
                RegisterOptions = registration.RegisterOptions is JToken token
                    ? token.ToObject(registrationType, _serializer.JsonSerializer)
                    : registration.RegisterOptions
            };

            if (_logger.IsEnabled(LogLevel.Trace))
            {
                _logger.LogTrace("Registered handler for {Method} {@Registration}", deserializedRegistration.Method, deserializedRegistration.RegisterOptions);
            }

            return(deserializedRegistration);
        }
        private void Register(Registration registration)
        {
            var registrationType = _handlerTypeDescriptorProvider.GetRegistrationType(registration.Method);

            if (registrationType == null)
            {
                _registrations.AddOrUpdate(registration.Id, x => registration, (a, b) => registration);
                return;
            }

            var deserializedRegistration = new Registration {
                Id              = registration.Id,
                Method          = registration.Method,
                RegisterOptions = registration.RegisterOptions is JToken token
                    ? token.ToObject(registrationType, _serializer.JsonSerializer)
                    : registration.RegisterOptions
            };

            _registrations.AddOrUpdate(deserializedRegistration.Id, x => deserializedRegistration, (a, b) => deserializedRegistration);
        }