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);
        }