using System;
using System.Collections.Generic; 
using System.Data.OracleClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Oracle.ManagedDataAccess.Client;

namespace RDH.Data
{
    public class OracleDynamicParameters : IDynamicParameters
    {
        private readonly DynamicParameters dynamicParameters = new DynamicParameters();

        private readonly List<Oracle.ManagedDataAccess.Client.OracleParameter> oracleParameters = new List<OracleParameter>();

        public void Add(string name, object value = null, System.Data.DbType? dbType = null, System.Data.ParameterDirection? direction = null, int? size = null)
        {
            dynamicParameters.Add(name, value, dbType, direction, size);
        }

        public void Add(string name, OracleDbType oracleDbType, System.Data.ParameterDirection direction)
        {
            var oracleParameter = new OracleParameter(name, oracleDbType, direction);
            oracleParameters.Add(oracleParameter);
        }

        public void AddParameters(System.Data.IDbCommand command, Identity identity)
        {
            ((IDynamicParameters)dynamicParameters).AddParameters(command, identity);

            var oracleCommand = command as OracleCommand;

            if (oracleCommand != null)
            {
                oracleCommand.Parameters.AddRange(oracleParameters.ToArray());
            }
        }
    }
}
