コード例 #1
0
ファイル: QueryProvider.cs プロジェクト: sincoda/Kros.Libs
        private TableSchema LoadTableSchema(string tableName)
        {
            IDatabaseSchemaLoader schemaLoader = GetSchemaLoader();
            TableSchema           tableSchema  = schemaLoader.LoadTableSchema(Connection, tableName);

            return(tableSchema
                   ?? throw new InvalidOperationException($"Could not get schema for table [{tableName}]. Table does not exists."));
        }
コード例 #2
0
        private TableSchema LoadTableSchema(string tableName)
        {
            IDatabaseSchemaLoader schemaLoader = GetSchemaLoader();
            TableSchema           tableSchema  = schemaLoader.LoadTableSchema(Connection, tableName);

            return(tableSchema
                   ?? throw new InvalidOperationException(string.Format(Resources.QueryProviderCouldNotGetTableSchema, tableName)));
        }
コード例 #3
0
        /// <inheritdoc cref="IDatabaseSchemaLoader{T}.LoadTableSchema(T, string)"/>
        /// <exception cref="ArgumentNullException">Value of any parameter is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentException">
        /// <list type="bullet">
        /// <item>Loader for connection type specified by <paramref name="connection"/> does not exist.</item>
        /// <item>Value of <paramref name="tableName"/> is empty string, or string containing only whitespace characters.</item>
        /// </list>
        /// </exception>
        public TableSchema LoadTableSchema(object connection, string tableName)
        {
            Check.NotNullOrWhiteSpace(tableName, nameof(tableName));

            IDatabaseSchemaLoader loader = CheckConnectionAndGetLoader(connection);

            return(loader.LoadTableSchema(connection, tableName));
        }
コード例 #4
0
        private IDatabaseSchemaLoader CheckConnectionAndGetLoader(object connection)
        {
            Check.NotNull(connection, nameof(connection));

            IDatabaseSchemaLoader loader = GetLoader(connection);

            if (loader == null)
            {
                throw new ArgumentException(Resources.DatabaseSchemaLoader_UnsupportedConnectionType, nameof(connection));
            }

            return(loader);
        }
コード例 #5
0
        private IDatabaseSchemaLoader CheckConnectionAndGetLoader(object connection)
        {
            Check.NotNull(connection, nameof(connection));

            IDatabaseSchemaLoader loader = GetLoader(connection);

            if (loader == null)
            {
                throw new ArgumentException(
                          string.Format(Resources.UnsupportedConnectionType, connection.GetType().FullName), nameof(connection));
            }

            return(loader);
        }
コード例 #6
0
 /// <summary>
 /// Removes <paramref name="loader"/> from the list of loaders.
 /// </summary>
 /// <param name="loader">Specific database schema loader to be removed from the list.</param>
 public void RemoveSchemaLoader(IDatabaseSchemaLoader loader)
 {
     _loaders.Remove(loader);
 }
コード例 #7
0
 /// <summary>
 /// Adds <paramref name="loader"/> to the list of loaders.
 /// </summary>
 /// <param name="loader">Specific database schema loader.</param>
 /// <exception cref="ArgumentNullException">Value of <paramref name="loader"/> is <see langword="null"/>.</exception>
 public void AddSchemaLoader(IDatabaseSchemaLoader loader)
 {
     Check.NotNull(loader, nameof(loader));
     _loaders.Add(loader);
 }
コード例 #8
0
        /// <inheritdoc cref="IDatabaseSchemaLoader{T}.LoadSchema(T)"/>
        /// <exception cref="ArgumentNullException">Value of <paramref name="connection"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentException">
        /// Loader for connection type specified by <paramref name="connection"/> does not exist.
        /// </exception>
        public DatabaseSchema LoadSchema(object connection)
        {
            IDatabaseSchemaLoader loader = CheckConnectionAndGetLoader(connection);

            return(loader.LoadSchema(connection));
        }
コード例 #9
0
 public LoaderInfo(IDatabaseSchemaLoader loader, ISchemaCacheKeyGenerator keyGenerator)
 {
     Loader       = loader;
     KeyGenerator = keyGenerator;
 }
コード例 #10
0
 /// <summary>
 /// Vymaže zadaný <paramref name="loader"/> databázovej schémy.
 /// </summary>
 /// <param name="loader">Loader databázovej schémy, ktorý sa má vymazať.</param>
 public void RemoveSchemaLoader(IDatabaseSchemaLoader loader)
 {
     _loaders.Remove(_loaders.FirstOrDefault((linfo) => linfo.Loader == loader));
 }
コード例 #11
0
 /// <summary>
 /// Pridá do keše <paramref name="loader"/> na načítavanie schémy databázy, spolu s generátorom kľúčov pre načítanú
 /// shému <paramref name="keyGenerator"/>.
 /// </summary>
 /// <param name="loader">Loader pre načítavanie schémy databázy.</param>
 /// <param name="keyGenerator">Generátor kľúča pre schému databázy. Databáza sa interne drží v keši pod vygenerovaným
 /// kľúčom.</param>
 /// <exception cref="ArgumentNullException">Hodnota <paramref name="loader"/> alebo <paramref name="keyGenerator"/>
 /// je <c>null</c>.</exception>
 public void AddSchemaLoader(IDatabaseSchemaLoader loader, ISchemaCacheKeyGenerator keyGenerator)
 {
     Check.NotNull(loader, nameof(loader));
     Check.NotNull(keyGenerator, nameof(keyGenerator));
     _loaders.Add(new LoaderInfo(loader, keyGenerator));
 }