Beispiel #1
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            builder.RegisterInstance <Func <HttpClient> >(() => new HttpClient(new TestDataMessageHandler()))
            .As <Func <HttpClient> >()
            .SingleInstance();

            var testApiPolicy = ApiPolicySetup.CreatePolicy()
                                .Namespace("System.Globalization", ApiAccess.Neutral, n => n.Type(typeof(CultureInfo), ApiAccess.Neutral, t => t.Setter(nameof(CultureInfo.CurrentCulture), ApiAccess.Allowed)));

            builder.RegisterInstance(testApiPolicy)
            .AsSelf()
            .SingleInstance();

            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(new Dictionary <string, string> {
                { "App:Explanations:Urls:CSharp", "http://testdata/language-syntax-explanations/csharp.yml" },
                { "App:Explanations:UpdatePeriod", "01:00:00" }
            })
                                .Build();

            builder.RegisterInstance <IConfiguration>(configuration)
            .SingleInstance();
        }
Beispiel #2
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterInstance(ApiPolicySetup.CreatePolicy())
            .AsSelf()
            .SingleInstance();

            builder.Register(_ => {
                var dataTarget = DataTarget.AttachToProcess(Current.ProcessId, suspend: false);
                return(dataTarget.ClrVersions.Single(c => c.Flavor == ClrFlavor.Core).CreateRuntime());
            }).SingleInstance();

            builder.RegisterType <Pool <ClrRuntime> >()
            .AsSelf()
            .SingleInstance();

            builder.RegisterType <ExecutionResultSerializer>()
            .AsSelf()
            .SingleInstance();

            builder.RegisterType <FlowReportingRewriter>()
            .As <IAssemblyRewriter>()
            .SingleInstance();

            builder.RegisterType <MemoryGraphArgumentNamesRewriter>()
            .As <IAssemblyRewriter>()
            .SingleInstance();

            builder.RegisterType <FSharpEntryPointRewriter>()
            .As <IAssemblyRewriter>()
            .As <IContainerAssemblyRewriter>()
            .SingleInstance();

            builder.RegisterType <Executor>()
            .As <IExecutor>()
            .SingleInstance();

            var containerHostUrl = Environment.GetEnvironmentVariable("SHARPLAB_CONTAINER_HOST_URL")
                                   ?? throw new Exception("Required environment variable SHARPLAB_CONTAINER_HOST_URL was not provided.");

            builder.RegisterType <ContainerFlowReportingRewriter>()
            .As <IContainerAssemblyRewriter>()
            .SingleInstance();

            builder.Register(c => {
                var secretsClient = c.Resolve <ISecretsClient>();
                var containerAuthorizationToken = secretsClient.GetSecret("ContainerHostAuthorizationToken");
                return(new ContainerClientSettings(new Uri(containerHostUrl), containerAuthorizationToken));
            }).SingleInstance()
            .AsSelf();

            builder.RegisterType <ContainerClient>()
            .As <IContainerClient>()
            .SingleInstance();

            builder.RegisterType <ContainerExecutor>()
            .As <IContainerExecutor>()
            .SingleInstance();

            RegisterRuntime(builder);
        }
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <Executor>()
            .As <IExecutor>()
            .SingleInstance();

            builder.RegisterInstance(ApiPolicySetup.CreatePolicy())
            .AsSelf()
            .SingleInstance();

            builder.RegisterType <ExecutionResultSerializer>()
            .AsSelf()
            .SingleInstance();

            builder.RegisterType <FlowReportingRewriter>()
            .As <IAssemblyRewriter>()
            .SingleInstance();

            builder.RegisterType <MemoryGraphArgumentNamesRewriter>()
            .As <IAssemblyRewriter>()
            .SingleInstance();

            builder.RegisterType <FSharpEntryPointRewriter>()
            .As <IAssemblyRewriter>()
            .SingleInstance();
        }
Beispiel #4
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            builder.RegisterInstance <Func <HttpClient> >(() => new HttpClient(new TestDataMessageHandler()))
            .As <Func <HttpClient> >()
            .SingleInstance();

            var testApiPolicy = ApiPolicySetup.CreatePolicy()
                                .Namespace("System.Globalization", ApiAccess.Neutral, n => n.Type(typeof(CultureInfo), ApiAccess.Neutral, t => t.Setter(nameof(CultureInfo.CurrentCulture), ApiAccess.Allowed)));

            builder.RegisterInstance(testApiPolicy)
            .AsSelf()
            .SingleInstance();
        }
Beispiel #5
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterInstance(ApiPolicySetup.CreatePolicy())
            .AsSelf()
            .SingleInstance();

            builder.Register(_ => {
                var dataTarget = DataTarget.AttachToProcess(Current.ProcessId, uint.MaxValue, AttachFlag.Passive);
                return(dataTarget.ClrVersions.Single(c => c.Flavor == ClrFlavor.Core).CreateRuntime());
            }).SingleInstance();

            builder.RegisterType <Pool <ClrRuntime> >()
            .AsSelf()
            .SingleInstance();

            builder.RegisterType <ExecutionResultSerializer>()
            .AsSelf()
            .SingleInstance();

            builder.RegisterType <FlowReportingRewriter>()
            .As <IAssemblyRewriter>()
            .SingleInstance();

            builder.RegisterType <MemoryGraphArgumentNamesRewriter>()
            .As <IAssemblyRewriter>()
            .SingleInstance();

            builder.RegisterType <FSharpEntryPointRewriter>()
            .As <IAssemblyRewriter>()
            .SingleInstance();

            builder.RegisterType <Executor>()
            .As <IExecutor>()
            .SingleInstance();

            RegisterRuntime(builder);
        }