I think this is an ok idea; but not a good idea. I've had problems in the past with trying to use a modified version of class alongside unmodified versions:
http://forum.castleproject.org/posts/list/39.page You probably won't experience those errors since you're wrapping the class. If I were maintaining a project that required me to use a wrapped SqlCommand object, I would expect all related objects for accessing the datastore to be wrapped. Have you thought about putting your modified SqlCommand along with other thin wrapper classes into their own assembly? By doing that, you could create your own provider node. I think that's more in-line with the spirit/design of IBatisNet. I think its confusing specifing an assemblyName in a provider node but then allow special cases. If you want to specify a fully qualified type for one thing, I think you should have to use a fully qualified type for everything (i.e. remove the assemblyName attribute entirely). That's the approach log4net has taken for its config file. I'm curious to know what your SqlCommand wrapper class is doing. --- Ramon Casha <[EMAIL PROTECTED]> wrote: > I altered my copy of iBATIS.NET so as to allow a provider to mix > classes from different assemblies. In my case I needed it because I > created a "wrapper class" around SqlCommand but wanted to retain all > the other classes as they were. The way it works now is that if a > classname contains a comma, it is loaded via > "IBatisNet.Common.Utilities.Resources.TypeForName(className)" which > can load from different assemblies, while if it has no comma it is > loaded as before. > > If you think this is a good idea, here's a patch for Provider.cs: > > START PATCH > vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv > Index: Provider.cs > =================================================================== > --- Provider.cs (revision 2) > +++ Provider.cs (working copy) > @@ -462,6 +462,15 @@ > #endregion > > #region Methods > + > + private Type GetType(Assembly assembly, string className) { > + if(className.IndexOf(',') >= 0) { > + return > IBatisNet.Common.Utilities.Resources.TypeForName(className); > + } else { > + return assembly.GetType(className, true); > + } > + } > + > /// <summary> > /// Init the provider. > /// </summary> > @@ -476,25 +485,25 @@ > assembly = Assembly.Load(_assemblyName); > > // Build the Command template > - type = assembly.GetType(_commandClass, true); > + type = GetType(assembly,_commandClass); > _templateCommand = > (IDbCommand)type.GetConstructor(Type.EmptyTypes).Invoke(null); > // Build the DataAdapter template > - type = assembly.GetType(_dataAdapterClass, > true); > + type = GetType(assembly,_dataAdapterClass); > _templateDataAdapter = > (IDbDataAdapter)type.GetConstructor(Type.EmptyTypes).Invoke(null); > // Build the connection template > - type = assembly.GetType(_connectionClass, true); > + type = GetType(assembly,_connectionClass); > _templateConnection = > (IDbConnection)type.GetConstructor(Type.EmptyTypes).Invoke(null); > // Get the IDataParameter type > - _dataParameterType = > assembly.GetType(_dataParameter, true); > + _dataParameterType = > GetType(assembly,_dataParameter); > // Get the CommandBuilder Type > - _commandBuilderType = > assembly.GetType(_commandBuilderClass, > true); > + _commandBuilderType = > GetType(assembly,_commandBuilderClass); > if (_parameterDbTypeClass.IndexOf(',')>0) > { > _parameterDbType = > cachedTypeResolver.Resolve(_parameterDbTypeClass); > } > else > { > - _parameterDbType = > assembly.GetType(_parameterDbTypeClass, > true); > + _parameterDbType = > GetType(assembly,_parameterDbTypeClass); > } > > _templateConnectionIsICloneable = > _templateConnection is > ICloneable; > END PATCH > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > ________________________________ > > Ramon Casha > Megabyte Ltd (www.megabyte.net <http://www.megabyte.net/> ) > F4, The Technopark, Mosta MST02 Malta > tel: (+356) 2142 1600 > fax: (+356) 2142 1590 Megabyte Ltd > <file:///C:/Documents%20and%20Settings/rac.MEGABYTE.000/My%20Documents/My%20Pictures/mb-email-signature.gif> > > > DISCLAIMER > The information contained in this electronic mail may be confidential > or legally privileged. It is for the intended recipient(s) only. > Should you receive this message in error, please notify the sender by > replying to this mail. Unauthorised use of the contents is strictly > prohibited. Whilst all care has been taken, the Megabyte Group is not > responsible for the integrity of the contents of this electronic mail > and any attachments included within. > > >
