コード例 #1
0
        private void ValidateSettings(SqlServerInstanceStoreSettings settings)
        {
            if (settings.GetDatabaseConnection == null)
            {
                throw new ArgumentException($"{nameof(settings.GetDatabaseConnection)} cannot be null.");
            }
            if (settings.HubName == null)
            {
                throw new ArgumentException($"{nameof(settings.HubName)} cannot be null.");
            }
            if (settings.SchemaName == null)
            {
                throw new ArgumentException($"{nameof(settings.SchemaName)} cannot be null.");
            }

            //Validate schema and hubnames are valid SQL Identifiers
            var sqlIdentifierRegex = new Regex(@"^[\p{L}_][\p{L}\p{N}@$#_]{0,127}$");

            if (sqlIdentifierRegex.IsMatch(settings.SchemaName) == false)
            {
                throw new ArgumentException($"{nameof(settings.SchemaName)} must be a valid SQL Identifier");
            }
            if (sqlIdentifierRegex.IsMatch(settings.HubName) == false)
            {
                throw new ArgumentException($"{nameof(settings.HubName)} must be a valid SQL Identifier");
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates a new SqlServerInstanceStore using the supplied settings
        /// </summary>
        /// <param name="settings">Configuration values for the Instnace Store</param>
        public SqlServerInstanceStore(SqlServerInstanceStoreSettings settings)
        {
            ValidateSettings(settings);

            this.settings = settings;
        }