Beispiel #1
0
        public SqlServerConfigurationSource Build()
        {
            var instance = new SqlServerConfigurationSource {
                ConnectionString = ConnectionString
            };

            if (Table != null)
            {
                instance.Table = Table;
            }

            if (KeyColumn != null)
            {
                instance.KeyColumn = KeyColumn;
            }

            if (ValueColumn != null)
            {
                instance.ValueColumn = ValueColumn;
            }

            if (Schema != null)
            {
                instance.Schema = Schema;
            }

            if (PeriodicalRefreshTimeSpan != null)
            {
                instance.SqlServerWatcher = new SqlServerPeriodicalWatcher(PeriodicalRefreshTimeSpan.Value);
            }

            return(instance);
        }
Beispiel #2
0
        public SqlServerConfigurationProvider(SqlServerConfigurationSource source)
        {
            _source = source;
            _query  = $"select {_source.KeyColumn}, {_source.ValueColumn} from {_source.Schema}.{_source.Table}";

            if (_source.SqlServerWatcher != null)
            {
                _changeTokenRegistration = ChangeToken.OnChange(
                    () => _source.SqlServerWatcher.Watch(),
                    Load
                    );
            }
        }