text:
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Xml;

namespace ZyGames.Framework.Data.Sql
{
    /// <summary>
    /// MSSQL数据库查询、删除、更新操作辅助类
    /// </summary>
    internal sealed class SqlHelper
    {
        private enum SqlConnectionOwnership
        {
            Internal,
            External
        }
        /// <summary>
        ///
        /// </summary>
        public static string defaultConnectionString = SqlHelper.GetConnectionString();
        private SqlHelper()
        {
        }
        private static SqlDataReader ExecuteReader(SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter[] commandParameters, SqlHelper.SqlConnectionOwnership connectionOwnership)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            bool flag = false;
            SqlCommand sqlCommand = new SqlCommand();
            SqlDataReader result;
            try
            {
                SqlHelper.PrepareCommand(sqlCommand, connection, transaction, commandType, commandText, commandParameters, out flag);
                SqlDataReader sqlDataReader;
                if (connectionOwnership == SqlHelper.SqlConnectionOwnership.External)
                {
                    sqlDataReader = sqlCommand.ExecuteReader();
                }
                else
                {
                    sqlDataReader = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
                }
                bool flag2 = true;
                foreach (SqlParameter sqlParameter in sqlCommand.Parameters)
                {
                    if (sqlParameter.Direction != ParameterDirection.Input)
                    {
                        flag2 = false;
                    }
                }
                if (flag2)
                {
                    sqlCommand.Parameters.Clear();
                }
                SqlHelper.OperatingLog(commandText);
                result = sqlDataReader;
            }
            catch
            {
                if (flag)
                {
                    connection.Close();
                }
                throw;
            }
            return result;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static SqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText)
        {
            SqlDataReader result = SqlHelper.ExecuteReader(connectionString, commandType, commandText, null);
            SqlHelper.OperatingLog(commandText);
            return result;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="commandParameters"></param>
        /// <returns></returns>
        public static SqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException("connectionString");
            }
            SqlConnection sqlConnection = null;
            SqlDataReader result;
            try
            {
                sqlConnection = new SqlConnection(connectionString);
                sqlConnection.Open();
                SqlDataReader sqlDataReader = SqlHelper.ExecuteReader(sqlConnection, null, commandType, commandText,
                    commandParameters, SqlHelper.SqlConnectionOwnership.Internal);
                result = sqlDataReader;
            }
            catch
            {
                if (sqlConnection != null)
                {
                    sqlConnection.Close();
                }
                throw;
            }
            return result;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="spName"></param>
        /// <param name="parameterValues"></param>
        /// <returns></returns>
        public static SqlDataReader ExecuteReader(string connectionString, string spName, params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                SqlDataReader result = SqlHelper.ExecuteReader(connectionString, CommandType.StoredProcedure, spName, spParameterSet);
                SqlHelper.OperatingLog(spName);
                return result;
            }
            SqlDataReader result2 = SqlHelper.ExecuteReader(connectionString, CommandType.StoredProcedure, spName);
            SqlHelper.OperatingLog(spName);
            return result2;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteReader(connection, commandType, commandText, null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="commandParameters"></param>
        /// <returns></returns>
        public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            SqlDataReader result = SqlHelper.ExecuteReader(connection, null, commandType, commandText, commandParameters, SqlHelper.SqlConnectionOwnership.External);
            SqlHelper.OperatingLog(commandText);
            return result;
        }
        public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType commandType, string commandText, bool externalConn, params SqlParameter[] commandParameters)
        {
            SqlDataReader result = SqlHelper.ExecuteReader(connection, null, commandType, commandText, commandParameters,
                externalConn ? SqlConnectionOwnership.External : SqlConnectionOwnership.Internal);
            SqlHelper.OperatingLog(commandText);
            return result;
        }

        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="spName"></param>
        /// <param name="parameterValues"></param>
        /// <returns></returns>
        public static SqlDataReader ExecuteReader(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                return SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, spName);
        }
        private static SqlDataReader ExecuteReader(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteReader(transaction, commandType, commandText, null);
        }
        private static SqlDataReader ExecuteReader(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            return SqlHelper.ExecuteReader(transaction.Connection, transaction, commandType, commandText, commandParameters, SqlHelper.SqlConnectionOwnership.External);
        }
        private static SqlDataReader ExecuteReader(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                return SqlHelper.ExecuteReader(transaction, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteReader(transaction, CommandType.StoredProcedure, spName);
        }
        private static string GetConnectionString()
        {
            if (ConfigurationManager.ConnectionStrings["LocalSqlServer"] != null)
            {
                return ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
            }
            return null;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static object ExecuteScalar(string commandText)
        {
            return SqlHelper.ExecuteScalar(SqlHelper.defaultConnectionString, CommandType.Text, commandText);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static SqlDataReader ExecuteReader(string commandText)
        {
            return SqlHelper.ExecuteReader(SqlHelper.defaultConnectionString, CommandType.Text, commandText);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static int ExecuteNonQuery(string commandText)
        {
            return SqlHelper.ExecuteNonQuery(SqlHelper.defaultConnectionString, CommandType.Text, commandText);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static DataSet ExecuteDataset(string commandText)
        {
            return SqlHelper.ExecuteDataset(SqlHelper.defaultConnectionString, CommandType.Text, commandText);
        }
        private static void AttachParameters(SqlCommand command, SqlParameter[] commandParameters)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }
            if (commandParameters != null)
            {
                for (int i = 0; i < commandParameters.Length; i++)
                {
                    SqlParameter sqlParameter = commandParameters[i];
                    if (sqlParameter != null)
                    {
                        if ((sqlParameter.Direction == ParameterDirection.InputOutput || sqlParameter.Direction == ParameterDirection.Input) && sqlParameter.Value == null)
                        {
                            sqlParameter.Value = DBNull.Value;
                        }
                        command.Parameters.Add(sqlParameter);
                    }
                }
            }
        }
        private static void AssignParameterValues(SqlParameter[] commandParameters, DataRow dataRow)
        {
            if (commandParameters == null || dataRow == null)
            {
                return;
            }
            int num = 0;
            for (int i = 0; i < commandParameters.Length; i++)
            {
                SqlParameter sqlParameter = commandParameters[i];
                if (sqlParameter.ParameterName == null || sqlParameter.ParameterName.Length <= 1)
                {
                    throw new Exception(string.Format("请在 #{0} 处提供一个有效的参数名, 参数名属性现有值如下: '{1}'.", num, sqlParameter.ParameterName));
                }
                if (dataRow.Table.Columns.IndexOf(sqlParameter.ParameterName.Substring(1)) != -1)
                {
                    sqlParameter.Value = dataRow[sqlParameter.ParameterName.Substring(1)];
                }
                num++;
            }
        }
        private static void AssignParameterValues(SqlParameter[] commandParameters, object[] parameterValues)
        {
            if (commandParameters == null || parameterValues == null)
            {
                return;
            }
            if (commandParameters.Length != parameterValues.Length)
            {
                throw new ArgumentException("参数数量与参数值数量不匹配.");
            }
            int i = 0;
            int num = commandParameters.Length;
            while (i < num)
            {
                if (parameterValues[i] is IDbDataParameter)
                {
                    IDbDataParameter dbDataParameter = parameterValues[i] as IDbDataParameter;
                    if (dbDataParameter.Value == null)
                    {
                        commandParameters[i].Value = DBNull.Value;
                    }
                    else
                    {
                        commandParameters[i].Value = dbDataParameter.Value;
                    }
                }
                else
                {
                    if (parameterValues[i] == null)
                    {
                        commandParameters[i].Value = DBNull.Value;
                    }
                    else
                    {
                        commandParameters[i].Value = parameterValues[i];
                    }
                }
                i++;
            }
        }
        private static void PrepareCommand(SqlCommand command, SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter[] commandParameters, out bool mustCloseConnection)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }
            if (commandText == null || commandText.Length == 0)
            {
                throw new ArgumentNullException("commandText");
            }
            if (connection.State != ConnectionState.Open)
            {
                mustCloseConnection = true;
                connection.Open();
            }
            else
            {
                mustCloseConnection = false;
            }
            command.Connection = connection;
            command.CommandText = commandText;
            if (transaction != null)
            {
                if (transaction.Connection == null)
                {
                    throw new ArgumentException("打开状态的事务允许数据操作回滚或者提交。", "事务");
                }
                command.Transaction = transaction;
            }
            command.CommandType = commandType;
            if (commandParameters != null)
            {
                SqlHelper.AttachParameters(command, commandParameters);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteNonQuery(connectionString, commandType, commandText, null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="commandParameters"></param>
        /// <returns></returns>
        public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            int result;
            using (SqlConnection sqlConnection = new SqlConnection(connectionString))
            {
                sqlConnection.Open();
                int num = SqlHelper.ExecuteNonQuery(sqlConnection, commandType, commandText, commandParameters);
                result = num;
            }
            return result;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="spName"></param>
        /// <param name="parameterValues"></param>
        /// <returns></returns>
        public static int ExecuteNonQuery(string connectionString, string spName, params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                return SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteNonQuery(connection, commandType, commandText, null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="commandParameters"></param>
        /// <returns></returns>
        public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            SqlCommand sqlCommand = new SqlCommand();
            bool flag = false;
            SqlHelper.PrepareCommand(sqlCommand, connection, null, commandType, commandText, commandParameters, out flag);
            int result = sqlCommand.ExecuteNonQuery();
            sqlCommand.Parameters.Clear();
            if (flag)
            {
                connection.Close();
            }
            SqlHelper.OperatingLog(commandText);
            return result;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="spName"></param>
        /// <param name="parameterValues"></param>
        /// <returns></returns>
        public static int ExecuteNonQuery(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            int result;
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                result = SqlHelper.ExecuteNonQuery(connection, CommandType.StoredProcedure, spName, spParameterSet);
            }
            else
            {
                result = SqlHelper.ExecuteNonQuery(connection, CommandType.StoredProcedure, spName);
            }
            return result;
        }
        private static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteNonQuery(transaction, commandType, commandText, null);
        }
        private static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            }
            SqlCommand sqlCommand = new SqlCommand();
            bool flag = false;
            SqlHelper.PrepareCommand(sqlCommand, transaction.Connection, transaction, commandType, commandText, commandParameters, out flag);
            SqlHelper.OperatingLog(commandText);
            int result = sqlCommand.ExecuteNonQuery();
            sqlCommand.Parameters.Clear();
            return result;
        }
        private static int ExecuteNonQuery(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            int result;
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                result = SqlHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName, spParameterSet);
            }
            else
            {
                result = SqlHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName);
            }
            return result;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteDataset(connectionString, commandType, commandText, null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="commandParameters"></param>
        /// <returns></returns>
        public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            DataSet result;
            using (SqlConnection sqlConnection = new SqlConnection(connectionString))
            {
                sqlConnection.Open();
                DataSet dataSet = SqlHelper.ExecuteDataset(sqlConnection, commandType, commandText, commandParameters);
                result = dataSet;
            }
            return result;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="spName"></param>
        /// <param name="parameterValues"></param>
        /// <returns></returns>
        public static DataSet ExecuteDataset(string connectionString, string spName, params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                return SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, spName);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteDataset(connection, commandType, commandText, null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="commandParameters"></param>
        /// <returns></returns>
        public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            SqlCommand sqlCommand = new SqlCommand();
            bool flag = false;
            SqlHelper.PrepareCommand(sqlCommand, connection, null, commandType, commandText, commandParameters, out flag);
            DataSet result;
            using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand))
            {
                DataSet dataSet = new DataSet();
                sqlDataAdapter.Fill(dataSet);
                sqlCommand.Parameters.Clear();
                if (flag)
                {
                    connection.Close();
                }
                SqlHelper.OperatingLog(commandText);
                result = dataSet;
            }
            return result;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="spName"></param>
        /// <param name="parameterValues"></param>
        /// <returns></returns>
        public static DataSet ExecuteDataset(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                return SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, spName);
        }
        private static DataSet ExecuteDataset(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteDataset(transaction, commandType, commandText, null);
        }
        private static DataSet ExecuteDataset(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            SqlCommand sqlCommand = new SqlCommand();
            bool flag = false;
            SqlHelper.PrepareCommand(sqlCommand, transaction.Connection, transaction, commandType, commandText, commandParameters, out flag);
            SqlHelper.OperatingLog(commandText);
            DataSet result;
            using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand))
            {
                DataSet dataSet = new DataSet();
                sqlDataAdapter.Fill(dataSet);
                sqlCommand.Parameters.Clear();
                result = dataSet;
            }
            return result;
        }
        private static DataSet ExecuteDataset(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                return SqlHelper.ExecuteDataset(transaction, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteDataset(transaction, CommandType.StoredProcedure, spName);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteScalar(connectionString, commandType, commandText, null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="commandParameters"></param>
        /// <returns></returns>
        public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            object result;
            using (SqlConnection sqlConnection = new SqlConnection(connectionString))
            {
                sqlConnection.Open();
                object obj = SqlHelper.ExecuteScalar(sqlConnection, commandType, commandText, commandParameters);
                result = obj;
            }
            return result;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="spName"></param>
        /// <param name="parameterValues"></param>
        /// <returns></returns>
        public static object ExecuteScalar(string connectionString, string spName, params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                return SqlHelper.ExecuteScalar(connectionString, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteScalar(connectionString, CommandType.StoredProcedure, spName);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static object ExecuteScalar(SqlConnection connection, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteScalar(connection, commandType, commandText, null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="commandParameters"></param>
        /// <returns></returns>
        public static object ExecuteScalar(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            SqlCommand sqlCommand = new SqlCommand();
            bool flag = false;
            SqlHelper.PrepareCommand(sqlCommand, connection, null, commandType, commandText, commandParameters, out flag);
            object result = sqlCommand.ExecuteScalar();
            sqlCommand.Parameters.Clear();
            if (flag)
            {
                connection.Close();
            }
            SqlHelper.OperatingLog(commandText);
            return result;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="spName"></param>
        /// <param name="parameterValues"></param>
        /// <returns></returns>
        public static object ExecuteScalar(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                object result = SqlHelper.ExecuteScalar(connection, CommandType.StoredProcedure, spName, spParameterSet);
                SqlHelper.OperatingLog(spName);
                return result;
            }
            object result2 = SqlHelper.ExecuteScalar(connection, CommandType.StoredProcedure, spName);
            SqlHelper.OperatingLog(spName);
            return result2;
        }
        private static object ExecuteScalar(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteScalar(transaction, commandType, commandText, null);
        }
        private static object ExecuteScalar(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            SqlCommand sqlCommand = new SqlCommand();
            bool flag = false;
            SqlHelper.PrepareCommand(sqlCommand, transaction.Connection, transaction, commandType, commandText, commandParameters, out flag);
            object result = sqlCommand.ExecuteScalar();
            sqlCommand.Parameters.Clear();
            SqlHelper.OperatingLog(commandText);
            return result;
        }
        private static object ExecuteScalar(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                return SqlHelper.ExecuteScalar(transaction, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteScalar(transaction, CommandType.StoredProcedure, spName);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static XmlReader ExecuteXmlReader(SqlConnection connection, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteXmlReader(connection, commandType, commandText, null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="commandParameters"></param>
        /// <returns></returns>
        public static XmlReader ExecuteXmlReader(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            bool flag = false;
            SqlCommand sqlCommand = new SqlCommand();
            XmlReader result;
            try
            {
                SqlHelper.PrepareCommand(sqlCommand, connection, null, commandType, commandText, commandParameters, out flag);
                XmlReader xmlReader = sqlCommand.ExecuteXmlReader();
                sqlCommand.Parameters.Clear();
                SqlHelper.OperatingLog(commandText);
                result = xmlReader;
            }
            catch
            {
                if (flag)
                {
                    connection.Close();
                }
                throw;
            }
            return result;
        }
        ///<summary>
        ///</summary>
        ///<param name="connection"></param>
        ///<param name="spName"></param>
        ///<param name="parameterValues"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static XmlReader ExecuteXmlReader(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                return SqlHelper.ExecuteXmlReader(connection, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteXmlReader(connection, CommandType.StoredProcedure, spName);
        }
        private static XmlReader ExecuteXmlReader(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            return SqlHelper.ExecuteXmlReader(transaction, commandType, commandText, null);
        }
        private static XmlReader ExecuteXmlReader(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            SqlCommand sqlCommand = new SqlCommand();
            bool flag = false;
            SqlHelper.PrepareCommand(sqlCommand, transaction.Connection, transaction, commandType, commandText, commandParameters, out flag);
            SqlHelper.OperatingLog(commandText);
            XmlReader result = sqlCommand.ExecuteXmlReader();
            sqlCommand.Parameters.Clear();
            return result;
        }
        private static XmlReader ExecuteXmlReader(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                return SqlHelper.ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="dataSet"></param>
        /// <param name="tableNames"></param>
        public static void FillDataset(string connectionString, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }
            using (SqlConnection sqlConnection = new SqlConnection(connectionString))
            {
                sqlConnection.Open();
                SqlHelper.FillDataset(sqlConnection, commandType, commandText, dataSet, tableNames);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="dataSet"></param>
        /// <param name="tableNames"></param>
        /// <param name="commandParameters"></param>
        public static void FillDataset(string connectionString, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }
            using (SqlConnection sqlConnection = new SqlConnection(connectionString))
            {
                sqlConnection.Open();
                SqlHelper.FillDataset(sqlConnection, commandType, commandText, dataSet, tableNames, commandParameters);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="spName"></param>
        /// <param name="dataSet"></param>
        /// <param name="tableNames"></param>
        /// <param name="parameterValues"></param>
        public static void FillDataset(string connectionString, string spName, DataSet dataSet, string[] tableNames, params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }
            using (SqlConnection sqlConnection = new SqlConnection(connectionString))
            {
                sqlConnection.Open();
                SqlHelper.FillDataset(sqlConnection, spName, dataSet, tableNames, parameterValues);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="commandType"></param>
        /// <param name="commandText"></param>
        /// <param name="dataSet"></param>
        /// <param name="tableNames"></param>
        public static void FillDataset(SqlConnection connection, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames)
        {
            SqlHelper.FillDataset(connection, commandType, commandText, dataSet, tableNames, null);
        }
        ///<summary>
        ///</summary>
        ///<param name="connection"></param>
        ///<param name="commandType"></param>
        ///<param name="commandText"></param>
        ///<param name="dataSet"></param>
        ///<param name="tableNames"></param>
        ///<param name="commandParameters"></param>
        public static void FillDataset(SqlConnection connection, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames, params SqlParameter[] commandParameters)
        {
            SqlHelper.FillDataset(connection, null, commandType, commandText, dataSet, tableNames, commandParameters);
        }
        ///<summary>
        ///</summary>
        ///<param name="connection"></param>
        ///<param name="spName"></param>
        ///<param name="dataSet"></param>
        ///<param name="tableNames"></param>
        ///<param name="parameterValues"></param>
        ///<exception cref="ArgumentNullException"></exception>
        public static void FillDataset(SqlConnection connection, string spName, DataSet dataSet, string[] tableNames, params object[] parameterValues)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                SqlHelper.FillDataset(connection, CommandType.StoredProcedure, spName, dataSet, tableNames, spParameterSet);
                return;
            }
            SqlHelper.FillDataset(connection, CommandType.StoredProcedure, spName, dataSet, tableNames);
        }
        ///<summary>
        ///</summary>
        ///<param name="transaction"></param>
        ///<param name="commandType"></param>
        ///<param name="commandText"></param>
        ///<param name="dataSet"></param>
        ///<param name="tableNames"></param>
        public static void FillDataset(SqlTransaction transaction, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames)
        {
            SqlHelper.FillDataset(transaction, commandType, commandText, dataSet, tableNames, null);
        }
        ///<summary>
        ///</summary>
        ///<param name="transaction"></param>
        ///<param name="commandType"></param>
        ///<param name="commandText"></param>
        ///<param name="dataSet"></param>
        ///<param name="tableNames"></param>
        ///<param name="commandParameters"></param>
        public static void FillDataset(SqlTransaction transaction, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames, params SqlParameter[] commandParameters)
        {
            SqlHelper.FillDataset(transaction.Connection, transaction, commandType, commandText, dataSet, tableNames, commandParameters);
        }
        ///<summary>
        ///</summary>
        ///<param name="transaction"></param>
        ///<param name="spName"></param>
        ///<param name="dataSet"></param>
        ///<param name="tableNames"></param>
        ///<param name="parameterValues"></param>
        ///<exception cref="ArgumentNullException"></exception>
        ///<exception cref="ArgumentException"></exception>
        public static void FillDataset(SqlTransaction transaction, string spName, DataSet dataSet, string[] tableNames, params object[] parameterValues)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (parameterValues != null && parameterValues.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, parameterValues);
                SqlHelper.FillDataset(transaction, CommandType.StoredProcedure, spName, dataSet, tableNames, spParameterSet);
                return;
            }
            SqlHelper.FillDataset(transaction, CommandType.StoredProcedure, spName, dataSet, tableNames);
        }
        private static void FillDataset(SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames, params SqlParameter[] commandParameters)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }
            SqlCommand sqlCommand = new SqlCommand();
            bool flag = false;
            SqlHelper.PrepareCommand(sqlCommand, connection, transaction, commandType, commandText, commandParameters, out flag);
            using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand))
            {
                if (tableNames != null && tableNames.Length > 0)
                {
                    string text = "Table";
                    for (int i = 0; i < tableNames.Length; i++)
                    {
                        if (tableNames[i] == null || tableNames[i].Length == 0)
                        {
                            throw new ArgumentException("输入表名必须为数组列表, 无时可为null 或空字符串.", "表名");
                        }
                        sqlDataAdapter.TableMappings.Add(text, tableNames[i]);
                        text += (i + 1).ToString();
                    }
                }
                sqlDataAdapter.Fill(dataSet);
                sqlCommand.Parameters.Clear();
                SqlHelper.OperatingLog(commandText);
            }
            if (flag)
            {
                connection.Close();
            }
        }
        ///<summary>
        ///</summary>
        ///<param name="insertCommand"></param>
        ///<param name="deleteCommand"></param>
        ///<param name="updateCommand"></param>
        ///<param name="dataSet"></param>
        ///<param name="tableName"></param>
        ///<exception cref="ArgumentNullException"></exception>
        public static void UpdateDataset(SqlCommand insertCommand, SqlCommand deleteCommand, SqlCommand updateCommand, DataSet dataSet, string tableName)
        {
            if (insertCommand == null)
            {
                throw new ArgumentNullException("insertCommand");
            }
            if (deleteCommand == null)
            {
                throw new ArgumentNullException("deleteCommand");
            }
            if (updateCommand == null)
            {
                throw new ArgumentNullException("updateCommand");
            }
            if (tableName == null || tableName.Length == 0)
            {
                throw new ArgumentNullException("tableName");
            }
            using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
            {
                sqlDataAdapter.UpdateCommand = updateCommand;
                sqlDataAdapter.InsertCommand = insertCommand;
                sqlDataAdapter.DeleteCommand = deleteCommand;
                sqlDataAdapter.Update(dataSet, tableName);
                dataSet.AcceptChanges();
            }
        }
        ///<summary>
        ///</summary>
        ///<param name="connection"></param>
        ///<param name="spName"></param>
        ///<param name="sourceColumns"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static SqlCommand CreateCommand(SqlConnection connection, string spName, params string[] sourceColumns)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            SqlCommand sqlCommand = new SqlCommand(spName, connection);
            sqlCommand.CommandType = CommandType.StoredProcedure;
            if (sourceColumns != null && sourceColumns.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                for (int i = 0; i < sourceColumns.Length; i++)
                {
                    spParameterSet[i].SourceColumn = sourceColumns[i];
                }
                SqlHelper.AttachParameters(sqlCommand, spParameterSet);
            }
            SqlHelper.OperatingLog(spName);
            return sqlCommand;
        }
        ///<summary>
        ///</summary>
        ///<param name="connectionString"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static int ExecuteNonQueryTypedParams(string connectionString, string spName, DataRow dataRow)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="connection"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static int ExecuteNonQueryTypedParams(SqlConnection connection, string spName, DataRow dataRow)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteNonQuery(connection, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteNonQuery(connection, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="transaction"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        ///<exception cref="ArgumentException"></exception>
        public static int ExecuteNonQueryTypedParams(SqlTransaction transaction, string spName, DataRow dataRow)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="connectionString"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static DataSet ExecuteDatasetTypedParams(string connectionString, string spName, DataRow dataRow)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="connection"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static DataSet ExecuteDatasetTypedParams(SqlConnection connection, string spName, DataRow dataRow)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="transaction"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        ///<exception cref="ArgumentException"></exception>
        public static DataSet ExecuteDatasetTypedParams(SqlTransaction transaction, string spName, DataRow dataRow)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteDataset(transaction, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteDataset(transaction, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="connectionString"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static SqlDataReader ExecuteReaderTypedParams(string connectionString, string spName, DataRow dataRow)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteReader(connectionString, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteReader(connectionString, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="connection"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static SqlDataReader ExecuteReaderTypedParams(SqlConnection connection, string spName, DataRow dataRow)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="transaction"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        ///<exception cref="ArgumentException"></exception>
        public static SqlDataReader ExecuteReaderTypedParams(SqlTransaction transaction, string spName, DataRow dataRow)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteReader(transaction, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteReader(transaction, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="connectionString"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static object ExecuteScalarTypedParams(string connectionString, string spName, DataRow dataRow)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteScalar(connectionString, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteScalar(connectionString, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="connection"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static object ExecuteScalarTypedParams(SqlConnection connection, string spName, DataRow dataRow)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteScalar(connection, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteScalar(connection, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="transaction"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        ///<exception cref="ArgumentException"></exception>
        public static object ExecuteScalarTypedParams(SqlTransaction transaction, string spName, DataRow dataRow)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteScalar(transaction, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteScalar(transaction, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="connection"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static XmlReader ExecuteXmlReaderTypedParams(SqlConnection connection, string spName, DataRow dataRow)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteXmlReader(connection, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteXmlReader(connection, CommandType.StoredProcedure, spName);
        }
        ///<summary>
        ///</summary>
        ///<param name="transaction"></param>
        ///<param name="spName"></param>
        ///<param name="dataRow"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        ///<exception cref="ArgumentException"></exception>
        public static XmlReader ExecuteXmlReaderTypedParams(SqlTransaction transaction, string spName, DataRow dataRow)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }
            if (transaction != null && transaction.Connection == null)
            {
                throw new ArgumentException("该事务已经被回滚或提交, 请提供一个正打开的事务.", "事务");
            }
            if (spName == null || spName.Length == 0)
            {
                throw new ArgumentNullException("spName");
            }
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                SqlParameter[] spParameterSet = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
                SqlHelper.AssignParameterValues(spParameterSet, dataRow);
                return SqlHelper.ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName, spParameterSet);
            }
            return SqlHelper.ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName);
        }
        private static void OperatingLog(string OperatingSql)
        {
            return;
        }
        private static void ExecuteNonQueryaasd(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0)
            {
                throw new ArgumentNullException("connectionString");
            }
            using (SqlConnection sqlConnection = new SqlConnection(connectionString))
            {
                sqlConnection.Open();
                SqlHelper.ExecuteNonQueryaasd(sqlConnection, commandType, commandText, commandParameters);
            }
        }
        ///<summary>
        ///</summary>
        ///<param name="connection"></param>
        ///<param name="commandType"></param>
        ///<param name="commandText"></param>
        ///<param name="commandParameters"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static int ExecuteNonQueryaasd(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            SqlCommand sqlCommand = new SqlCommand();
            bool flag = false;
            SqlHelper.PrepareCommand(sqlCommand, connection, null, commandType, commandText, commandParameters, out flag);
            int result = sqlCommand.ExecuteNonQuery();
            sqlCommand.Parameters.Clear();
            if (flag)
            {
                connection.Close();
            }
            return result;
        }
        //private static int LoadCookie()
        //{
        //    if (HttpContext.Current.Request.Cookies["userid"] != null)
        //    {
        //        int result = 0;
        //        string value = HttpContext.Current.Request.Cookies["userid"].Value;
        //        if (int.TryParse(value, out result))
        //        {
        //            return result;
        //        }
        //    }
        //    return 0;
        //}
    }
}


text:
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>
        <!-- Admin Forms  -->
        <service id="app.form.admin.incident" class="AppBundle\Form\Type\Admin\IncidentType">
            <tag name="form.type" alias="admin_incident" />
        </service>
        <service id="app.form.admin.service" class="AppBundle\Form\Type\Admin\ServiceType">
            <tag name="form.type" alias="admin_service" />
        </service>

        <!-- Api Forms  -->
        <service id="app.form.api.service_selector" class="AppBundle\Form\Type\Api\ServiceSelectorType">
            <argument type="service" id="app.transformer.service" />
            <tag name="form.type" alias="service_selector" />
        </service>

        <service id="app.form.api.user_selector" class="AppBundle\Form\Type\Api\UserSelectorType">
            <argument type="service" id="app.transformer.user" />
            <tag name="form.type" alias="user_selector" />
        </service>

        <service id="app.form.api.metric_selector" class="AppBundle\Form\Type\Api\MetricSelectorType">
            <argument type="service" id="app.data_transformer.metric" />
            <tag name="form.type" alias="metric_selector" />
        </service>

        <service id="app.form.api.metric_point" class="AppBundle\Form\Type\Api\MetricPointType">
            <tag name="form.type" alias="api_metric_point" />
        </service>

        <service id="app.form.api.metric" class="AppBundle\Form\Type\Api\MetricType">
            <tag name="form.type" alias="api_metric" />
        </service>

        <service id="app.form.api.incident" class="AppBundle\Form\Type\Api\IncidentType">
            <tag name="form.type" alias="api_incident" />
        </service>

        <service id="app.form.api.service" class="AppBundle\Form\Type\Api\ServiceType">
            <tag name="form.type" alias="api_service" />
        </service>

        <service id="app.form.entity_handler" class="AppBundle\Form\Handler\EntityFormHandler">
            <argument type="service" id="doctrine" />
        </service>

        <service id="app.form_factory" class="AppBundle\Form\Factory\RestFormFactory">
            <argument type="service" id="form.factory" />
        </service>

        <service id="app.form.registration" class="AppBundle\Form\Type\Admin\RegistrationFormType">
            <tag name="form.type" alias="app_user_registration" />
        </service>

        <service id="app.form.invitation" class="AppBundle\Form\Type\Admin\InvitationFormType">
            <argument type="service" id="app.form.data_transformer.invitation"/>
            <tag name="form.type" alias="app_invitation_type" />
        </service>

        <service id="app.form.data_transformer.invitation"
            class="AppBundle\Form\DataTransformer\InvitationToCodeTransformer"
            public="false">
            <argument type="service" id="doctrine.orm.entity_manager"/>
        </service>

        <!-- Data Transfomer -->
        <service id="app.transformer.service" class="AppBundle\Form\DataTransformer\ServiceTransformer">
            <argument type="service" id="doctrine.orm.entity_manager" />
        </service>

        <service id="app.transformer.user" class="AppBundle\Form\DataTransformer\UserTransformer">
            <argument type="service" id="doctrine.orm.entity_manager" />
        </service>

        <service id="app.data_transformer.metric" class="AppBundle\Form\DataTransformer\MetricTransformer">
            <argument type="service" id="doctrine.orm.entity_manager" />
        </service>
    </services>
</container>

redpajama_set_name: RedPajamaGithub


text:
/**
 * @file woff转换ttf
 * @author mengke01(kekee000@gmail.com)
 */

define(
    function (require) {

        var Reader = require('./reader');
        var Writer = require('./writer');
        var error = require('./error');

        /**
         * woff格式转换成ttf字体格式
         *
         * @param {ArrayBuffer} woffBuffer woff缓冲数组
         * @param {Object} options 选项
         * @param {Object} options.inflate 解压相关函数
         *
         * @return {ArrayBuffer} ttf格式byte流
         */
        function woff2ttf(woffBuffer, options) {
            options = options || {};

            var reader = new Reader(woffBuffer);
            var signature = reader.readUint32(0);
            var flavor = reader.readUint32(4);

            if (signature !== 0x774F4646 || flavor !== 0x10000) {
                reader.dispose();
                error.raise(10102);
            }

            var numTables = reader.readUint16(12);
            var ttfSize =  reader.readUint32(16);
            var tableEntries = [];
            var tableEntry;
            var i;
            var l;

            // 读取woff表索引信息
            for (i = 0; i < numTables; ++i) {
                reader.seek(44 + i * 20);
                tableEntry = {
                    tag: reader.readString(reader.offset, 4),
                    offset: reader.readUint32(),
                    compLength: reader.readUint32(),
                    length: reader.readUint32(),
                    checkSum: reader.readUint32()
                };

                // ttf 表数据
                var deflateData = reader.readBytes(tableEntry.offset, tableEntry.compLength);
                // 需要解压
                if (deflateData.length < tableEntry.length) {

                    if (!options.inflate) {
                        reader.dispose();
                        error.raise(10105);
                    }

                    tableEntry.data = options.inflate(deflateData);
                }
                else {
                    tableEntry.data = deflateData;
                }

                tableEntry.length = tableEntry.data.length;
                tableEntries.push(tableEntry);
            }

            var writer = new Writer(new ArrayBuffer(ttfSize));
            // 写头部
            var entrySelector = Math.floor(Math.log(numTables) / Math.LN2);
            var searchRange = Math.pow(2, entrySelector) * 16;
            var rangeShift = numTables * 16 - searchRange;

            writer.writeFixed(1);
            writer.writeUint16(numTables);
            writer.writeUint16(searchRange);
            writer.writeUint16(entrySelector);
            writer.writeUint16(rangeShift);

            // 写ttf表索引
            var tblOffset = 12 + 16 * tableEntries.length;
            for (i = 0, l = tableEntries.length; i < l; ++i) {
                tableEntry = tableEntries[i];
                writer.writeString(tableEntry.tag);
                writer.writeUint32(tableEntry.checkSum);
                writer.writeUint32(tblOffset);
                writer.writeUint32(tableEntry.length);
                tblOffset += tableEntry.length
                    + (tableEntry.length % 4 ? 4 - tableEntry.length % 4 : 0);
            }

            // 写ttf表数据
            for (i = 0, l = tableEntries.length; i < l; ++i) {
                tableEntry = tableEntries[i];
                writer.writeBytes(tableEntry.data);
                if (tableEntry.length % 4) {
                    writer.writeEmpty(4 - tableEntry.length % 4);
                }
            }

            return writer.getBuffer();
        }

        return woff2ttf;
    }
);


text:
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated by the Codegen C++ plugin.
// If you make any local changes, they will be lost.
// source: google/cloud/networkconnectivity/v1/hub.proto

#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_NETWORKCONNECTIVITY_HUB_CONNECTION_H
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_NETWORKCONNECTIVITY_HUB_CONNECTION_H

#include "google/cloud/networkconnectivity/hub_connection_idempotency_policy.h"
#include "google/cloud/networkconnectivity/internal/hub_retry_traits.h"
#include "google/cloud/networkconnectivity/internal/hub_stub.h"
#include "google/cloud/backoff_policy.h"
#include "google/cloud/future.h"
#include "google/cloud/options.h"
#include "google/cloud/polling_policy.h"
#include "google/cloud/status_or.h"
#include "google/cloud/stream_range.h"
#include "google/cloud/version.h"
#include <google/longrunning/operations.grpc.pb.h>
#include <memory>

namespace google {
namespace cloud {
namespace networkconnectivity {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

using HubServiceRetryPolicy = ::google::cloud::internal::TraitBasedRetryPolicy<
    networkconnectivity_internal::HubServiceRetryTraits>;

using HubServiceLimitedTimeRetryPolicy =
    ::google::cloud::internal::LimitedTimeRetryPolicy<
        networkconnectivity_internal::HubServiceRetryTraits>;

using HubServiceLimitedErrorCountRetryPolicy =
    ::google::cloud::internal::LimitedErrorCountRetryPolicy<
        networkconnectivity_internal::HubServiceRetryTraits>;

/**
 * The `HubServiceConnection` object for `HubServiceClient`.
 *
 * This interface defines virtual methods for each of the user-facing overload
 * sets in `HubServiceClient`. This allows users to inject custom behavior
 * (e.g., with a Google Mock object) when writing tests that use objects of type
 * `HubServiceClient`.
 *
 * To create a concrete instance, see `MakeHubServiceConnection()`.
 *
 * For mocking, see `networkconnectivity_mocks::MockHubServiceConnection`.
 */
class HubServiceConnection {
 public:
  virtual ~HubServiceConnection() = 0;

  virtual Options options() { return Options{}; }

  virtual StreamRange<google::cloud::networkconnectivity::v1::Hub> ListHubs(
      google::cloud::networkconnectivity::v1::ListHubsRequest request);

  virtual StatusOr<google::cloud::networkconnectivity::v1::Hub> GetHub(
      google::cloud::networkconnectivity::v1::GetHubRequest const& request);

  virtual future<StatusOr<google::cloud::networkconnectivity::v1::Hub>>
  CreateHub(
      google::cloud::networkconnectivity::v1::CreateHubRequest const& request);

  virtual future<StatusOr<google::cloud::networkconnectivity::v1::Hub>>
  UpdateHub(
      google::cloud::networkconnectivity::v1::UpdateHubRequest const& request);

  virtual future<
      StatusOr<google::cloud::networkconnectivity::v1::OperationMetadata>>
  DeleteHub(
      google::cloud::networkconnectivity::v1::DeleteHubRequest const& request);

  virtual StreamRange<google::cloud::networkconnectivity::v1::Spoke> ListSpokes(
      google::cloud::networkconnectivity::v1::ListSpokesRequest request);

  virtual StatusOr<google::cloud::networkconnectivity::v1::Spoke> GetSpoke(
      google::cloud::networkconnectivity::v1::GetSpokeRequest const& request);

  virtual future<StatusOr<google::cloud::networkconnectivity::v1::Spoke>>
  CreateSpoke(google::cloud::networkconnectivity::v1::CreateSpokeRequest const&
                  request);

  virtual future<StatusOr<google::cloud::networkconnectivity::v1::Spoke>>
  UpdateSpoke(google::cloud::networkconnectivity::v1::UpdateSpokeRequest const&
                  request);

  virtual future<
      StatusOr<google::cloud::networkconnectivity::v1::OperationMetadata>>
  DeleteSpoke(google::cloud::networkconnectivity::v1::DeleteSpokeRequest const&
                  request);
};

/**
 * A factory function to construct an object of type `HubServiceConnection`.
 *
 * The returned connection object should not be used directly; instead it
 * should be passed as an argument to the constructor of HubServiceClient.
 *
 * The optional @p options argument may be used to configure aspects of the
 * returned `HubServiceConnection`. Expected options are any of the types in
 * the following option lists:
 *
 * - `google::cloud::CommonOptionList`
 * - `google::cloud::GrpcOptionList`
 * - `google::cloud::UnifiedCredentialsOptionList`
 * - `google::cloud::networkconnectivity::HubServicePolicyOptionList`
 *
 * @note Unexpected options will be ignored. To log unexpected options instead,
 *     set `GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes` in the environment.
 *
 * @param options (optional) Configure the `HubServiceConnection` created by
 * this function.
 */
std::shared_ptr<HubServiceConnection> MakeHubServiceConnection(
    Options options = {});

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
}  // namespace networkconnectivity
}  // namespace cloud
}  // namespace google

#endif  // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_NETWORKCONNECTIVITY_HUB_CONNECTION_H