public static Task <DebugAdapterClient> From(Action <DebugAdapterClientOptions> optionsAction, IServiceProvider?outerServiceProvider, CancellationToken cancellationToken)
        {
            var options = new DebugAdapterClientOptions();

            optionsAction(options);
            return(From(options, outerServiceProvider, cancellationToken));
        }
        public static DebugAdapterClient Create(Action <DebugAdapterClientOptions> optionsAction, IServiceProvider?outerServiceProvider)
        {
            var options = new DebugAdapterClientOptions();

            optionsAction(options);
            return(Create(options, outerServiceProvider));
        }
        public static async Task <DebugAdapterClient> From(DebugAdapterClientOptions options, IServiceProvider?outerServiceProvider, CancellationToken cancellationToken)
        {
            var server = Create(options, outerServiceProvider);
            await server.Initialize(cancellationToken).ConfigureAwait(false);

            return(server);
        }
 public static DebugAdapterClientOptions ConfigureConfiguration(
     this DebugAdapterClientOptions options,
     Action <IConfigurationBuilder> builderAction
     )
 {
     options.ConfigurationBuilderAction = builderAction;
     return(options);
 }
 public static DebugAdapterClientOptions ConfigureLogging(
     this DebugAdapterClientOptions options,
     Action <ILoggingBuilder> builderAction
     )
 {
     options.LoggingBuilderAction = builderAction;
     return(options);
 }
 public static Task <DebugAdapterClient> From(DebugAdapterClientOptions options) => From(options, null, CancellationToken.None);
 public static DebugAdapterClient Create(DebugAdapterClientOptions options, IServiceProvider?outerServiceProvider) =>
 CreateContainer(options, outerServiceProvider).Resolve <DebugAdapterClient>();
Ejemplo n.º 8
0
 /// <summary>
 /// Sets the scheduler use during writing output
 /// </summary>
 /// <param name="options"></param>
 /// <param name="outputScheduler"></param>
 /// <returns></returns>
 public static DebugAdapterClientOptions WithOutputScheduler(this DebugAdapterClientOptions options, IScheduler outputScheduler)
 {
     options.OutputScheduler = outputScheduler;
     return(options);
 }
 public static DebugAdapterClient Create(DebugAdapterClientOptions options) => Create(options, null);
 internal static IContainer CreateContainer(DebugAdapterClientOptions options, IServiceProvider?outerServiceProvider) =>
 JsonRpcServerContainer.Create(outerServiceProvider)
 .AddDebugAdapterClientInternals(options, outerServiceProvider);
Ejemplo n.º 11
0
        internal static IContainer AddDebugAdapterClientInternals(
            this IContainer container, DebugAdapterClientOptions options, IServiceProvider?outerServiceProvider
            )
        {
            container = container.AddDebugAdapterProtocolInternals(options);

            if (options.OnUnhandledException != null)
            {
                container.RegisterInstance(options.OnUnhandledException);
            }
            else
            {
                container.RegisterDelegate(_ => new OnUnhandledExceptionHandler(_ => { }), Reuse.Singleton);
            }

            container.RegisterInstance <IOptionsFactory <DebugAdapterClientOptions> >(new ValueOptionsFactory <DebugAdapterClientOptions>(options));

            container.RegisterInstance(
                new InitializeRequestArguments
            {
                Locale                       = options.Locale,
                AdapterId                    = options.AdapterId,
                ClientId                     = options.ClientId,
                ClientName                   = options.ClientName,
                PathFormat                   = options.PathFormat,
                ColumnsStartAt1              = options.ColumnsStartAt1,
                LinesStartAt1                = options.LinesStartAt1,
                SupportsMemoryReferences     = options.SupportsMemoryReferences,
                SupportsProgressReporting    = options.SupportsProgressReporting,
                SupportsVariablePaging       = options.SupportsVariablePaging,
                SupportsVariableType         = options.SupportsVariableType,
                SupportsRunInTerminalRequest = options.SupportsRunInTerminalRequest,
            }
                );
            container.RegisterInstance(options.RequestProcessIdentifier);

            container.RegisterMany <DebugAdapterClientProgressManager>(nonPublicServiceTypes: true, reuse: Reuse.Singleton);
            container.RegisterMany <DebugAdapterClient>(
                serviceTypeCondition: type => type == typeof(IDebugAdapterClient) || type == typeof(DebugAdapterClient),
                reuse: Reuse.Singleton,
                setup: Setup.With(condition: req => req.IsResolutionRoot || req.Container.Resolve <IInsanceHasStarted>().Started)
                );
            container.RegisterMany <DefaultDebugAdapterClientFacade>(
                serviceTypeCondition: type => type.IsClass || (!type.Name.Contains("Proxy") && typeof(DefaultDebugAdapterClientFacade).GetInterfaces()
                                                               .Except(typeof(DefaultDebugAdapterClientFacade).BaseType !.GetInterfaces()).Any(z => type == z)),
                reuse: Reuse.Singleton
                );

            // container.
            var providedConfiguration =
                options.Services.FirstOrDefault(z => z.ServiceType == typeof(IConfiguration) && z.ImplementationInstance is IConfiguration);

            container.RegisterDelegate <IConfiguration>(
                _ =>
            {
                var builder = new ConfigurationBuilder();
                if (outerServiceProvider != null)
                {
                    var outerConfiguration = outerServiceProvider.GetService <IConfiguration>();
                    if (outerConfiguration != null)
                    {
                        builder.CustomAddConfiguration(outerConfiguration, false);
                    }
                }

                if (providedConfiguration != null)
                {
                    builder.CustomAddConfiguration((providedConfiguration.ImplementationInstance as IConfiguration) !);
                }

                return(builder.Build());
            },
                Reuse.Singleton
                );

            return(container);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Sets the default scheduler to be used when scheduling other tasks
 /// </summary>
 /// <param name="options"></param>
 /// <param name="defaultScheduler"></param>
 /// <returns></returns>
 public static DebugAdapterClientOptions WithDefaultScheduler(this DebugAdapterClientOptions options, IScheduler defaultScheduler)
 {
     options.DefaultScheduler = defaultScheduler;
     return(options);
 }
 public static DebugAdapterClientOptions WithSerializer(this DebugAdapterClientOptions options, ISerializer serializer)
 {
     options.Serializer = serializer;
     return(options);
 }
 public static Task <DebugAdapterClient> From(DebugAdapterClientOptions options, CancellationToken cancellationToken) => From(options, null, cancellationToken);
 public static DebugAdapterClientOptions AddDefaultLoggingProvider(this DebugAdapterClientOptions options)
 {
     options.AddDefaultLoggingProvider = true;
     return(options);
 }
 public static DebugAdapterClientOptions OnStarted(this DebugAdapterClientOptions options, OnDebugAdapterClientStartedDelegate @delegate)
 {
     options.Services.AddSingleton(@delegate);
     return(options);
 }
 public static DebugAdapterClientOptions OnInitialized(this DebugAdapterClientOptions options, OnDebugAdapterClientInitializedDelegate initializedDelegate)
 {
     options.Services.AddSingleton(initializedDelegate);
     return(options);
 }
 public static DebugAdapterClientOptions WithRequestProcessIdentifier(this DebugAdapterClientOptions options, IRequestProcessIdentifier requestProcessIdentifier)
 {
     options.RequestProcessIdentifier = requestProcessIdentifier;
     return(options);
 }
 public static Task <DebugAdapterClient> From(DebugAdapterClientOptions options, IServiceProvider?outerServiceProvider) =>
 From(options, outerServiceProvider, CancellationToken.None);
Ejemplo n.º 20
0
 public static DebugAdapterClient Create(DebugAdapterClientOptions options)
 {
     return(Create(options, null));
 }
Ejemplo n.º 21
0
        internal static IContainer AddDebugAdapterClientInternals(this IContainer container, DebugAdapterClientOptions options, IServiceProvider?outerServiceProvider)
        {
            container = container.AddDebugAdapterProtocolInternals(options);

            if (options.OnUnhandledException != null)
            {
                container.RegisterInstance(options.OnUnhandledException);
            }
            else
            {
                container.RegisterDelegate(_ => new OnUnhandledExceptionHandler(_ => { }), Reuse.Singleton);
            }

            container.RegisterInstance <IOptionsFactory <DebugAdapterClientOptions> >(new ValueOptionsFactory <DebugAdapterClientOptions>(options));

            container.RegisterInstance(
                new InitializeRequestArguments {
                Locale                       = options.Locale,
                AdapterId                    = options.AdapterId !,
                ClientId                     = options.ClientId,
                ClientName                   = options.ClientName,
                PathFormat                   = options.PathFormat,
                ColumnsStartAt1              = options.ColumnsStartAt1,
                LinesStartAt1                = options.LinesStartAt1,
                SupportsMemoryReferences     = options.SupportsMemoryReferences,
                SupportsProgressReporting    = options.SupportsProgressReporting,
                SupportsVariablePaging       = options.SupportsVariablePaging,
                SupportsVariableType         = options.SupportsVariableType,
                SupportsRunInTerminalRequest = options.SupportsRunInTerminalRequest,
            }
Ejemplo n.º 22
0
 /// <summary>
 /// Sets the scheduler used during reading input
 /// </summary>
 /// <param name="options"></param>
 /// <param name="inputScheduler"></param>
 /// <returns></returns>
 public static DebugAdapterClientOptions WithInputScheduler(this DebugAdapterClientOptions options, IScheduler inputScheduler)
 {
     options.InputScheduler = inputScheduler;
     return(options);
 }