Ejemplo n.º 1
0
        public static void Configure(IConfiguration configuration)
        {
            //load settings
            HostSettings              = configuration.GetSection("DirectSpHost").Get <HostSettings>() ?? new HostSettings();
            KestrelSettings           = configuration.GetSection("Kestrel").Get <KestrelSettings>() ?? new KestrelSettings();
            AuthProviderSettingsArray = configuration.GetSection("AuthProviders").Get <AuthProviderItem[]>() ?? new AuthProviderItem[0];

            var directSpInvokerOptions = configuration.GetSection("DirectSpInvoker").Get <DirectSpInvokerOptions>();

            directSpInvokerOptions.WorkspaceFolderPath = Path.Combine(HostSettings.WorkspaceFolderPath, "DirectSp");
            Directory.CreateDirectory(HostSettings.WorkspaceFolderPath);

            // Create KeyValue instance base of AppSetting.json settings
            directSpInvokerOptions.KeyValueProvider = HostSettings.KeyValueProvider.Name switch
            {
                KeyValueProviderType.SqlKeyValue => new SqlKeyValueProvider(HostSettings.KeyValueProvider.ConnectionString),
                KeyValueProviderType.MemoryKeyValue => new MemoryKeyValueProvder(),
                _ => throw new NotImplementedException($"KeyValueProvider has not been implemented. Name: {HostSettings.KeyValueProvider.Name}"),
            };
            directSpInvokerOptions.CommandProvider = new SqlCommandProvider(HostSettings.ResourceDbConnectionString);
            DirectSpInvoker = new DirectSpInvoker(directSpInvokerOptions);

            // find Kestrel Ssl Certificate
            if (!string.IsNullOrEmpty(KestrelSettings.CertificateThumb))
            {
                KestrelCertificate = DirectSpInvoker.CertificateProvider.GetByThumb(KestrelSettings.CertificateThumb);
            }
        }
Ejemplo n.º 2
0
        public void Init()
        {
            // Resolve SpInvoker internal dependencies
            var invokerOptions = new DirectSpInvokerOptions
            {
                WorkspaceFolderPath = "Workspace/Directsp",
                CommandProvider     = new ObjectCommandProvider(new TestObject()),
                CertificateProvider = new MockCertificateProvider(),
                CaptchaProvider     = new MockCaptchaProvider(),
                Logger = Log.Current
            };

            _directSpInvoker = new DirectSpInvoker(invokerOptions);
        }