public CastleCoreConsumerServiceSelector(IServiceProvider serviceProvider, CapOptions capOptions)
     : base(serviceProvider, capOptions)
 {
 }
        public static CapOptions UseCapOptions(this CapOptions @this, IConfiguration Configuration)
        {
            IConfigurationSection defaultStorage      = Configuration.GetSection("CAP:DefaultStorage");
            IConfigurationSection defaultMessageQueue = Configuration.GetSection("CAP:DefaultMessageQueue");

            if (Enum.TryParse(defaultStorage.Value, out CapStorageType capStorageType))
            {
                if (!Enum.IsDefined(typeof(CapStorageType), capStorageType))
                {
                    Log.Error($"CAP配置CAP:DefaultStorage:{defaultStorage.Value}无效");
                }

                switch (capStorageType)
                {
                case CapStorageType.InMemoryStorage:
                    @this.UseInMemoryStorage();
                    break;

                case CapStorageType.Mysql:
                    IConfigurationSection mySql = Configuration.GetSection($"ConnectionStrings:MySql");
                    @this.UseMySql(mySql.Value);
                    break;

                default:
                    break;
                }
            }
            else
            {
                Log.Error($"CAP配置CAP:DefaultStorage:{defaultStorage.Value}无效");
            }

            if (Enum.TryParse(defaultMessageQueue.Value, out CapMessageQueueType capMessageQueueType))
            {
                if (!Enum.IsDefined(typeof(CapMessageQueueType), capMessageQueueType))
                {
                    Log.Error($"CAP配置CAP:DefaultMessageQueue:{defaultMessageQueue.Value}无效");
                }
                IConfigurationSection configurationSection = Configuration.GetSection($"ConnectionStrings:{capMessageQueueType}");

                switch (capMessageQueueType)
                {
                case CapMessageQueueType.InMemoryQueue:
                    @this.UseInMemoryMessageQueue();
                    break;

                case CapMessageQueueType.RabbitMQ:
                    @this.UseRabbitMQ(options =>
                    {
                        options.HostName    = Configuration["CAP:RabbitMQ:HostName"];
                        options.UserName    = Configuration["CAP:RabbitMQ:UserName"];
                        options.Password    = Configuration["CAP:RabbitMQ:Password"];
                        options.VirtualHost = Configuration["CAP:RabbitMQ:VirtualHost"];
                    });
                    break;

                default:
                    break;
                }
            }
            else
            {
                Log.Error($"CAP配置CAP:DefaultMessageQueue:{defaultMessageQueue.Value}无效");
            }

            return(@this);
        }
예제 #3
0
 public static CapOptions UseEntityFramework <TContext>(this CapOptions options)
     where TContext : DbContext
 {
     return(options.UseEntityFramework <TContext>(opt => { opt.DbContextType = typeof(TContext); }));
 }
예제 #4
0
 /// <summary>
 /// Configuration to use kafka in CAP.
 /// </summary>
 /// <param name="options">CAP configuration options</param>
 /// <param name="bootstrapServers">Kafka bootstrap server urls.</param>
 public static CapOptions UseKafka(this CapOptions options, string bootstrapServers)
 {
     return(options.UseKafka(opt => { opt.Servers = bootstrapServers; }));
 }
예제 #5
0
 public SqlServerStorageConnection(SqlServerOptions options, CapOptions capOptions)
 {
     _capOptions = capOptions;
     Options     = options;
 }
 public MyConsumerServiceSelector(IServiceProvider serviceProvider)
     : base(serviceProvider)
 {
     _capOptions = serviceProvider.GetService <IOptions <CapOptions> >().Value;
 }
예제 #7
0
 public static CapOptions UseMongoDB(this CapOptions options)
 {
     return(options.UseMongoDB(x => { }));
 }
 public static CapOptions UseLiteDBStorage(this CapOptions options, string connectionString)
 {
     return(options.UseLiteDBStorage(opt => opt.ConnectionString = connectionString));
 }
 public static CapOptions UseLiteDBStorage(this CapOptions options, Action <LiteDBOptions> configure)
 {
     options.RegisterExtension(new LiteDBCapOptionsExtension(configure));
     return(options);
 }
예제 #10
0
 public static CapOptions UseAmazonSQS(this CapOptions options, RegionEndpoint region)
 {
     return(options.UseAmazonSQS(opt => { opt.Region = region; }));
 }
 public static CapOptions UseLiteDBStorage(this CapOptions options)
 {
     return(options.UseLiteDBStorage(opt => opt.ConnectionString = $"{System.Reflection.Assembly.GetEntryAssembly().GetName().Name}.db"));
 }
예제 #12
0
        public static AccelGUI Construct(
            RawAcceleration form,
            ManagedAccel activeAccel,
            Chart accelerationChart,
            Chart accelerationChartY,
            Chart velocityChart,
            Chart velocityChartY,
            Chart gainChart,
            Chart gainChartY,
            ComboBox accelTypeDropX,
            ComboBox accelTypeDropY,
            Button writeButton,
            ButtonBase toggleButton,
            ToolStripMenuItem showVelocityGainToolStripMenuItem,
            ToolStripMenuItem showLastMouseMoveMenuItem,
            ToolStripMenuItem wholeVectorToolStripMenuItem,
            ToolStripMenuItem byVectorComponentToolStripMenuItem,
            ToolStripMenuItem velocityGainCapToolStripMenuItem,
            ToolStripMenuItem legacyCapToolStripMenuItem,
            ToolStripMenuItem gainOffsetToolStripMenuItem,
            ToolStripMenuItem legacyOffsetToolStripMenuItem,
            ToolStripMenuItem scaleMenuItem,
            ToolStripTextBox dpiTextBox,
            ToolStripTextBox pollRateTextBox,
            TextBox sensitivityBoxX,
            TextBox sensitivityBoxY,
            TextBox rotationBox,
            TextBox weightBoxX,
            TextBox weightBoxY,
            TextBox capBoxX,
            TextBox capBoxY,
            TextBox offsetBoxX,
            TextBox offsetBoxY,
            TextBox accelerationBoxX,
            TextBox accelerationBoxY,
            TextBox scaleBoxX,
            TextBox scaleBoxY,
            TextBox limitBoxX,
            TextBox limitBoxY,
            TextBox expBoxX,
            TextBox expBoxY,
            TextBox midpointBoxX,
            TextBox midpointBoxY,
            CheckBox sensXYLock,
            CheckBox byComponentXYLock,
            Label lockXYLabel,
            Label sensitivityLabel,
            Label rotationLabel,
            Label weightLabelX,
            Label weightLabelY,
            Label capLabelX,
            Label capLabelY,
            Label offsetLabelX,
            Label offsetLabelY,
            Label constantOneLabelX,
            Label constantOneLabelY,
            Label scaleLabelX,
            Label scaleLabelY,
            Label limitLabelX,
            Label limitLabelY,
            Label expLabelX,
            Label expLabelY,
            Label constantThreeLabelX,
            Label constantThreeLabelY,
            Label activeValueTitleX,
            Label activeValueTitleY,
            Label sensitivityActiveXLabel,
            Label sensitivityActiveYLabel,
            Label rotationActiveLabel,
            Label weightActiveXLabel,
            Label weightActiveYLabel,
            Label capActiveXLabel,
            Label capActiveYLabel,
            Label offsetActiveLabelX,
            Label offsetActiveLabelY,
            Label accelerationActiveLabelX,
            Label accelerationActiveLabelY,
            Label scaleActiveLabelX,
            Label scaleActiveLabelY,
            Label limitActiveLabelX,
            Label limitActiveLabelY,
            Label expActiveLabelX,
            Label expActiveLabelY,
            Label midpointActiveLabelX,
            Label midpointActiveLabelY,
            Label accelTypeActiveLabelX,
            Label accelTypeActiveLabelY,
            Label optionSetXTitle,
            Label optionSetYTitle,
            Label mouseLabel)
        {
            var accelCalculator = new AccelCalculator(
                new Field(dpiTextBox.TextBox, form, Constants.DefaultDPI),
                new Field(pollRateTextBox.TextBox, form, Constants.DefaultPollRate));

            var accelCharts = new AccelCharts(
                form,
                new ChartXY(accelerationChart, accelerationChartY, Constants.SensitivityChartTitle),
                new ChartXY(velocityChart, velocityChartY, Constants.VelocityChartTitle),
                new ChartXY(gainChart, gainChartY, Constants.GainChartTitle),
                showVelocityGainToolStripMenuItem,
                showLastMouseMoveMenuItem,
                writeButton,
                accelCalculator);

            var sensitivity = new OptionXY(
                sensitivityBoxX,
                sensitivityBoxY,
                sensXYLock,
                form,
                1,
                sensitivityLabel,
                new ActiveValueLabelXY(
                    new ActiveValueLabel(sensitivityActiveXLabel, activeValueTitleX),
                    new ActiveValueLabel(sensitivityActiveYLabel, activeValueTitleX)),
                "Sens Multiplier");

            var rotation = new Option(
                rotationBox,
                form,
                0,
                rotationLabel,
                0,
                new ActiveValueLabel(rotationActiveLabel, activeValueTitleX),
                "Rotation");

            var optionSetYLeft = rotation.Left + rotation.Width;

            var weightX = new Option(
                weightBoxX,
                form,
                1,
                weightLabelX,
                0,
                new ActiveValueLabel(weightActiveXLabel, activeValueTitleX),
                "Weight");

            var weightY = new Option(
                weightBoxY,
                form,
                1,
                weightLabelY,
                optionSetYLeft,
                new ActiveValueLabel(weightActiveYLabel, activeValueTitleY),
                "Weight");

            var capX = new Option(
                capBoxX,
                form,
                0,
                capLabelX,
                0,
                new ActiveValueLabel(capActiveXLabel, activeValueTitleX),
                "Cap");

            var capY = new Option(
                capBoxY,
                form,
                0,
                capLabelY,
                optionSetYLeft,
                new ActiveValueLabel(capActiveYLabel, activeValueTitleY),
                "Cap");

            var offsetX = new Option(
                offsetBoxX,
                form,
                0,
                offsetLabelX,
                0,
                new ActiveValueLabel(offsetActiveLabelX, activeValueTitleX),
                "Offset");

            var offsetY = new Option(
                offsetBoxY,
                form,
                0,
                offsetLabelY,
                optionSetYLeft,
                new ActiveValueLabel(offsetActiveLabelY, activeValueTitleY),
                "Offset");

            var offsetOptionsX = new OffsetOptions(
                gainOffsetToolStripMenuItem,
                legacyOffsetToolStripMenuItem,
                offsetX);

            var offsetOptionsY = new OffsetOptions(
                gainOffsetToolStripMenuItem,
                legacyOffsetToolStripMenuItem,
                offsetY);

            var accelerationX = new Option(
                new Field(accelerationBoxX, form, 0),
                constantOneLabelX,
                new ActiveValueLabel(accelerationActiveLabelX, activeValueTitleX),
                0);

            var accelerationY = new Option(
                new Field(accelerationBoxY, form, 0),
                constantOneLabelY,
                new ActiveValueLabel(accelerationActiveLabelY, activeValueTitleY),
                optionSetYLeft);

            var scaleX = new Option(
                new Field(scaleBoxX, form, 0),
                scaleLabelX,
                new ActiveValueLabel(scaleActiveLabelX, activeValueTitleX),
                0);

            var scaleY = new Option(
                new Field(scaleBoxY, form, 0),
                scaleLabelY,
                new ActiveValueLabel(scaleActiveLabelY, activeValueTitleY),
                optionSetYLeft);

            var limitX = new Option(
                new Field(limitBoxX, form, 2),
                limitLabelX,
                new ActiveValueLabel(limitActiveLabelX, activeValueTitleX),
                0);

            var limitY = new Option(
                new Field(limitBoxY, form, 2),
                limitLabelY,
                new ActiveValueLabel(limitActiveLabelY, activeValueTitleY),
                optionSetYLeft);

            var exponentX = new Option(
                new Field(expBoxX, form, 2),
                expLabelX,
                new ActiveValueLabel(expActiveLabelX, activeValueTitleX),
                0);

            var exponentY = new Option(
                new Field(expBoxY, form, 2),
                expLabelY,
                new ActiveValueLabel(expActiveLabelY, activeValueTitleY),
                optionSetYLeft);

            var midpointX = new Option(
                new Field(midpointBoxX, form, 0),
                constantThreeLabelX,
                new ActiveValueLabel(midpointActiveLabelX, activeValueTitleX),
                0);

            var midpointY = new Option(
                new Field(midpointBoxY, form, 0),
                constantThreeLabelY,
                new ActiveValueLabel(midpointActiveLabelY, activeValueTitleY),
                optionSetYLeft);

            var capOptionsX = new CapOptions(
                velocityGainCapToolStripMenuItem,
                legacyCapToolStripMenuItem,
                capX);

            var capOptionsY = new CapOptions(
                velocityGainCapToolStripMenuItem,
                legacyCapToolStripMenuItem,
                capY);

            var accelerationOptionsX = new AccelTypeOptions(
                accelTypeDropX,
                accelerationX,
                scaleX,
                capOptionsX,
                weightX,
                offsetOptionsX,
                limitX,
                exponentX,
                midpointX,
                writeButton,
                new ActiveValueLabel(accelTypeActiveLabelX, activeValueTitleX));

            var accelerationOptionsY = new AccelTypeOptions(
                accelTypeDropY,
                accelerationY,
                scaleY,
                capOptionsY,
                weightY,
                offsetOptionsY,
                limitY,
                exponentY,
                midpointY,
                writeButton,
                new ActiveValueLabel(accelTypeActiveLabelY, activeValueTitleY));

            var optionsSetX = new AccelOptionSet(
                optionSetXTitle,
                activeValueTitleX,
                rotationBox.Top + rotationBox.Height + Constants.OptionVerticalSeperation,
                accelerationOptionsX);

            var optionsSetY = new AccelOptionSet(
                optionSetYTitle,
                activeValueTitleY,
                rotationBox.Top + rotationBox.Height + Constants.OptionVerticalSeperation,
                accelerationOptionsY);

            var applyOptions = new ApplyOptions(
                wholeVectorToolStripMenuItem,
                byVectorComponentToolStripMenuItem,
                byComponentXYLock,
                optionsSetX,
                optionsSetY,
                sensitivity,
                rotation,
                lockXYLabel,
                accelCharts);

            var settings = new SettingsManager(
                activeAccel,
                accelCalculator.DPI,
                accelCalculator.PollRate,
                showLastMouseMoveMenuItem,
                showVelocityGainToolStripMenuItem);

            var mouseWatcher = new MouseWatcher(form, mouseLabel, accelCharts, accelCalculator.PollRate);

            return(new AccelGUI(
                       form,
                       accelCalculator,
                       accelCharts,
                       settings,
                       applyOptions,
                       writeButton,
                       toggleButton,
                       mouseWatcher,
                       scaleMenuItem));
        }
예제 #13
0
 public static CapOptions UseRedis(this CapOptions options, string connection) =>
 options.UseRedis(opt => opt.Configuration = ConfigurationOptions.Parse(connection));
예제 #14
0
 public static CapOptions UseRedis(this CapOptions options) =>
 options.UseRedis(_ => { });
 public static CapOptions UseDashboard(this CapOptions capOptions)
 {
     return(capOptions.UseDashboard(opt => { }));
 }
예제 #16
0
        /// <summary>
        /// 根据配置文件配置Cap
        /// </summary>
        /// <param name="options"></param>
        /// <param name="Configuration"></param>
        /// <returns></returns>
        private static CapOptions UseCapOptions(this CapOptions options)
        {
            var defaultStorage      = Appsettings.CapDefaultStorage;
            var defaultMessageQueue = Appsettings.CapDefaultMessageQueue;

            //配置Cap默认存储类型
            if (Enum.TryParse(defaultStorage, out CapStorageTypeEnums capStorageType))
            {
                if (!Enum.IsDefined(typeof(CapStorageTypeEnums), capStorageType))//枚举中是否存在该类型定义
                {
                    Log.Error($"CAP配置:DefaultStorage:{defaultStorage}无效");
                }

                switch (capStorageType)
                {
                case CapStorageTypeEnums.InMemoryStorage:
                    options.UseInMemoryStorage();
                    break;

                case CapStorageTypeEnums.Mysql:
                    options.UseMySql(opt =>
                    {
                        opt.ConnectionString = Appsettings.MySqlCon;
                        opt.TableNamePrefix  = SystemConst.DbTablePrefix;
                    });
                    break;

                default:
                    break;
                }
            }
            else
            {
                Log.Error($"CAP配置:DefaultStorage:{capStorageType}配置无效,仅支持InMemoryStorage,Mysql!更多请增加引用,修改配置项代码");
            }
            //配置Cap默认消息队列
            if (Enum.TryParse(defaultMessageQueue, out CapMessageQueueTypeEnums capMessageQueueType))
            {
                if (!Enum.IsDefined(typeof(CapMessageQueueTypeEnums), capMessageQueueType))//枚举中是否存在该类型定义
                {
                    Log.Error($"CAP配置:DefaultMessageQueue:{defaultMessageQueue}无效");
                }
                //IConfigurationSection configurationSection = Configuration.GetSection($"ConnectionStrings:{capMessageQueueType}");

                switch (capMessageQueueType)
                {
                case CapMessageQueueTypeEnums.InMemoryQueue:
                    options.UseInMemoryMessageQueue();
                    break;

                case CapMessageQueueTypeEnums.RabbitMQ:
                    options.UseRabbitMQ(options =>
                    {
                        options.HostName    = Appsettings.CapRabbitMq.HostName;
                        options.UserName    = Appsettings.CapRabbitMq.UserName;
                        options.Password    = Appsettings.CapRabbitMq.Password;
                        options.VirtualHost = Appsettings.CapRabbitMq.VirtualHost;
                    });
                    break;

                default:
                    break;
                }
            }
            else
            {
                Log.Error($"CAP配置:DefaultMessageQueue:{defaultMessageQueue}无效");
            }

            return(options);
        }
예제 #17
0
 public static CapOptions UseInMemoryStorage(this CapOptions options)
 {
     options.RegisterExtension(new InMemoryCapOptionsExtension());
     return(options);
 }
예제 #18
0
 /// <summary>
 /// Configuration to use In-Memory message queue in CAP.
 /// </summary>
 /// <param name="options">CAP configuration options</param>
 public static CapOptions UseInMemoryMessageQueue(this CapOptions options)
 {
     options.RegisterExtension(new InMemoryMqOptionsExtension());
     return(options);
 }
예제 #19
0
 public PostgreSqlStorageConnection(PostgreSqlOptions options, CapOptions capOptions)
 {
     _capOptions = capOptions;
     Options     = options;
 }
예제 #20
0
 public MySqlStorageConnection(MySqlOptions options, CapOptions capOptions)
 {
     _capOptions = capOptions;
     Options     = options;
     _prefix     = Options.TableNamePrefix;
 }
예제 #21
0
 public static CapOptions UseMongoDB(this CapOptions options, string connectionString)
 {
     return(options.UseMongoDB(x => { x.DatabaseConnection = connectionString; }));
 }
예제 #22
0
 public TypedConsumerServiceSelector(IServiceProvider serviceProvider) : base(serviceProvider)
 {
     _capOptions = serviceProvider.GetRequiredService <IOptions <CapOptions> >().Value;
 }
 public static CapOptions UseDiscovery(this CapOptions capOptions)
 {
     return(capOptions.UseDiscovery(opt => { }));
 }
예제 #24
0
 /// <summary>
 /// Configuration to use pulsar in CAP.
 /// </summary>
 /// <param name="options">CAP configuration options</param>
 /// <param name="serverUrl">Pulsar bootstrap server urls.</param>
 public static CapOptions UsePulsar(this CapOptions options, string serverUrl)
 {
     return(options.UsePulsar(opt => { opt.ServiceUrl = serverUrl; }));
 }
예제 #25
0
 // ReSharper disable once InconsistentNaming
 // ReSharper disable once UnusedMember.Global
 public static CapOptions UseActiveMQ(this CapOptions options, string brokerUri)
 {
     return(options.UseActiveMQ(opt => { opt.BrokerUri = brokerUri; }));
 }
예제 #26
0
 public RabbitMQPublishMessageSender(ILogger <RabbitMQPublishMessageSender> logger, CapOptions options,
                                     IStorageConnection connection, IConnectionChannelPool connectionChannelPool, IStateChanger stateChanger)
     : base(logger, options, connection, stateChanger)
 {
     _logger = logger;
     _connectionChannelPool = connectionChannelPool;
     _exchange      = _connectionChannelPool.Exchange;
     ServersAddress = _connectionChannelPool.HostAddress;
 }
 public static CapOptions UseEntityFramework <TContext>(this CapOptions options)
     where TContext : DbContext
 {
     return(options.UseEntityFramework <TContext>(opt => { }));
 }
 public static CapOptions UseRabbitMQ(this CapOptions options, string hostName)
 {
     return(options.UseRabbitMQ(opt => { opt.HostName = hostName; }));
 }
예제 #29
0
 public static CapOptions UseSqlServer(this CapOptions options, string connectionString)
 {
     return(options.UseSqlServer(opt => { opt.ConnectionString = connectionString; }));
 }
 public MySqlStorageConnection(IOptions <MySqlOptions> options, IOptions <CapOptions> capOptions)
 {
     _options    = options;
     _capOptions = capOptions.Value;
     _prefix     = options.Value.TableNamePrefix;
 }