protected override IComponent[] CreateComponentsCore(IDesignerHost host) { const string prefix = VSNETConst.shortTitle; // "Ingres" IContainer designerHostContainer = host.Container; ArrayList newComponents = new ArrayList(); ArrayList newCommandComponents = new ArrayList(); string name; IngresConnection connection; IngresCommand providerCommand; if (designerHostContainer == null) // safety check return null; IngresDataAdapter dataAdapter = new IngresDataAdapter(); // Once a reference to an assembly has been added to this service, // this service can load types from names that // do not specify an assembly. ITypeResolutionService resService = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); System.Reflection.Assembly assembly = dataAdapter.GetType().Module.Assembly; if (resService != null) { resService.ReferenceAssembly(assembly.GetName()); // set the assembly name to load types from } name = DesignerNameManager.CreateUniqueName( designerHostContainer, prefix, "DataAdapter"); try { designerHostContainer.Add(dataAdapter, name); newComponents.Add(dataAdapter); } catch (ArgumentException ex) { string exMsg = ex.ToString() + "\nRemove IngresDataAdapter component '" + name + "'" + " that is defined outside of the designer. "; MessageBox.Show(exMsg, "Add " + name + " failed"); return null; } string [] commandName = new String [] { "SelectCommand", "InsertCommand", "UpdateCommand", "DeleteCommand", }; providerCommand = new IngresCommand(); // SELECT newCommandComponents.Add(providerCommand); providerCommand.DesignTimeVisible = false; dataAdapter.SelectCommand = providerCommand; providerCommand = new IngresCommand(); // INSERT newCommandComponents.Add(providerCommand); providerCommand.DesignTimeVisible = false; dataAdapter.InsertCommand = providerCommand; providerCommand = new IngresCommand(); // UPDATE newCommandComponents.Add(providerCommand); providerCommand.DesignTimeVisible = false; dataAdapter.UpdateCommand = providerCommand; providerCommand = new IngresCommand(); // DELETE newCommandComponents.Add(providerCommand); providerCommand.DesignTimeVisible = false; dataAdapter.DeleteCommand = providerCommand; // invoke the wizard to create the connection and query // pass VS.NET IDesignerHost host so we can add Connection DataAdapterWizard wizard = new DataAdapterWizard(dataAdapter, host); // The DataAdapterWizard called the ConnectionEditor and // gave the Wizard and Editor a chance to create the Connection // object and SELECT statement, or to cancel out. // If not cancelled, add the Connection object to // the VS.NET component tray if not already done. if (dataAdapter.SelectCommand != null && dataAdapter.SelectCommand.Connection != null) { connection = dataAdapter.SelectCommand.Connection; name = DesignerNameManager.CreateUniqueName( designerHostContainer, prefix, "Connection"); //add the connection to the VS.NET component tray designerHostContainer.Add(connection, name); } // add the four Command objects (each with a unique name) // to the designer's components tray for (int i=0; i<4; i++) { name = DesignerNameManager.CreateUniqueName( designerHostContainer, prefix, commandName[i]); designerHostContainer.Add( (IComponent) newCommandComponents[i], name); } // end for loop thru command components string s = "Creating component list for "+ this.GetType() +"?\n"; return (IComponent[])(newComponents.ToArray(typeof(IComponent))); //return base.CreateComponentsCore(host); }
CreateComponentsCore(IDesignerHost host) { const string prefix = VSNETConst.shortTitle; // "Ingres" IContainer designerHostContainer = host.Container; ArrayList newComponents = new ArrayList(); ArrayList newCommandComponents = new ArrayList(); string name; IngresConnection connection; IngresCommand providerCommand; if (designerHostContainer == null) // safety check { return(null); } IngresDataAdapter dataAdapter = new IngresDataAdapter(); // Once a reference to an assembly has been added to this service, // this service can load types from names that // do not specify an assembly. ITypeResolutionService resService = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); System.Reflection.Assembly assembly = dataAdapter.GetType().Module.Assembly; if (resService != null) { resService.ReferenceAssembly(assembly.GetName()); // set the assembly name to load types from } name = DesignerNameManager.CreateUniqueName( designerHostContainer, prefix, "DataAdapter"); try { designerHostContainer.Add(dataAdapter, name); newComponents.Add(dataAdapter); } catch (ArgumentException ex) { string exMsg = ex.ToString() + "\nRemove IngresDataAdapter component '" + name + "'" + " that is defined outside of the designer. "; MessageBox.Show(exMsg, "Add " + name + " failed"); return(null); } string [] commandName = new String [] { "SelectCommand", "InsertCommand", "UpdateCommand", "DeleteCommand", }; providerCommand = new IngresCommand(); // SELECT newCommandComponents.Add(providerCommand); providerCommand.DesignTimeVisible = false; dataAdapter.SelectCommand = providerCommand; providerCommand = new IngresCommand(); // INSERT newCommandComponents.Add(providerCommand); providerCommand.DesignTimeVisible = false; dataAdapter.InsertCommand = providerCommand; providerCommand = new IngresCommand(); // UPDATE newCommandComponents.Add(providerCommand); providerCommand.DesignTimeVisible = false; dataAdapter.UpdateCommand = providerCommand; providerCommand = new IngresCommand(); // DELETE newCommandComponents.Add(providerCommand); providerCommand.DesignTimeVisible = false; dataAdapter.DeleteCommand = providerCommand; // invoke the wizard to create the connection and query // pass VS.NET IDesignerHost host so we can add Connection DataAdapterWizard wizard = new DataAdapterWizard(dataAdapter, host); // The DataAdapterWizard called the ConnectionEditor and // gave the Wizard and Editor a chance to create the Connection // object and SELECT statement, or to cancel out. // If not cancelled, add the Connection object to // the VS.NET component tray if not already done. if (dataAdapter.SelectCommand != null && dataAdapter.SelectCommand.Connection != null) { connection = dataAdapter.SelectCommand.Connection; name = DesignerNameManager.CreateUniqueName( designerHostContainer, prefix, "Connection"); //add the connection to the VS.NET component tray designerHostContainer.Add(connection, name); } // add the four Command objects (each with a unique name) // to the designer's components tray for (int i = 0; i < 4; i++) { name = DesignerNameManager.CreateUniqueName( designerHostContainer, prefix, commandName[i]); designerHostContainer.Add( (IComponent)newCommandComponents[i], name); } // end for loop thru command components string s = "Creating component list for " + this.GetType() + "?\n"; return((IComponent[])(newComponents.ToArray(typeof(IComponent)))); //return base.CreateComponentsCore(host); } // CreateComponentsCore