Exemplo n.º 1
0
        public object CreateCommandBuilder(IDbDataAdapter adapter)
        {
            if (adapter == null)
            {
                throw new System.ArgumentNullException("adapter");
            }

            object obj = (object)adapter;

            if (!DataAdapterType.ToString().Equals(obj.ToString()))
            {
                throw new System.ArgumentException("adapter not part of this provider.");
            }

            if (commandBuilderTypeName.Equals(String.Empty))
            {
                throw new Exception("Provider does not have CommandBuilder type defined.");
            }

            object[] parms             = new object [] { obj };
            object   commandBuilderObj = Activator.CreateInstance(CommandBuilderType, parms);

            if (commandBuilderObj == null)
            {
                throw new Exception(String.Format("Unable to create instance of command builder class: {0} from assembly: {1}",
                                                  commandBuilderTypeName, assemblyName));
            }

            return(commandBuilderObj);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Retrieve the apropriate data adapter based on the DataAdapter type passed in.
 /// </summary>
 /// <param name="dataAdapterType"></param>
 /// <returns>A data adapter implementing IEICData</returns>
 public static IEICData GetDataAdapter(DataAdapterType dataAdapterType)
 {
     // This will allow for easier switching between data adapters if the application is decided to change source types (Sql, Nosql, Text, etc)
     // The passed in data adapter only needs to implement the IEICData interface.
     switch (dataAdapterType)
     {
         case DataAdapterType.MySql: return new EICData.MySqlEICData("[SERVER]", "[DB]", "[USER]", "[PWD]");
         default: return null;
     }
 }