You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2008/06/10 20:27:21 UTC
svn commit: r666257 - in /ibatis/trunk/cs/V3/src:
Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/
Apache.Ibatis.DataMapper/ Apache.Ibatis.DataMapper/MappedStatements/
Apache.Ibatis.DataMapper/Model/Events/ Apache.Ibatis.DataMapper/Model/...
Author: gbayon
Date: Tue Jun 10 11:27:20 2008
New Revision: 666257
URL: http://svn.apache.org/viewvc?rev=666257&view=rev
Log:
IBATISNET-271 finish refactoring following Ron remarks
Added:
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostCreateEventArgs.cs
- copied, changed from r664536, ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostCreateEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostPropertyEventArgs.cs
- copied, changed from r664536, ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostPropertyEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreCreateEventArgs.cs
- copied, changed from r664536, ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreCreateEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PrePropertyEventArgs.cs
- copied, changed from r664536, ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PrePropertyEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMapEvents.cs (with props)
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultPropertySupportEvents.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMapEventSupport.cs (with props)
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultPropertyEventSupport.cs (with props)
Removed:
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/BaseResultMapEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/IResultMapEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/IResultPropertyEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/Listeners/
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostCreateEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostPropertyEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreCreateEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PrePropertyEvent.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/StatementEventType.cs
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/EventTest.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Apache.Ibatis.DataMapper.20005.csproj
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatementEvents.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatementEventSupport.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/BaseStatementEventArgs.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/Events.cd
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostInsertEventArgs.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostSelectEventArgs.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostUpdateOrDeleteEventArgs.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreInsertEventArgs.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreSelectEventArgs.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreUpdateOrDeleteEventArgs.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/AutoResultMap.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMap.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/NullResultMap.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMap.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultProperty.cs
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/EventTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/EventTest.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/EventTest.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/EventTest.cs Tue Jun 10 11:27:20 2008
@@ -4,7 +4,6 @@
using Apache.Ibatis.DataMapper.Configuration.Interpreters.Config.Xml;
using Apache.Ibatis.DataMapper.MappedStatements;
using Apache.Ibatis.DataMapper.Model.Events;
-using Apache.Ibatis.DataMapper.Model.Events.Listeners;
using Apache.Ibatis.DataMapper.Model.ResultMapping;
using Apache.Ibatis.DataMapper.Session;
using Apache.Ibatis.DataMapper.SqlClient.Test.Domain;
@@ -47,19 +46,6 @@
}
- private static void ReInitListeners(IResultMap resultMap)
- {
- resultMap.PreCreateEventListeners = new IResultMapEventListener<PreCreateEvent>[] { };
- resultMap.PostCreateEventListeners = new IResultMapEventListener<PostCreateEvent>[] { };
- }
-
- private static void ReInitListeners(ResultProperty resultProperty)
- {
- resultProperty.PrePropertyEventListeners = new IResultPropertyEventListener<PrePropertyEvent>[] { };
- resultProperty.PostPropertyEventListeners = new IResultPropertyEventListener<PostPropertyEvent>[] { };
- }
-
-
[Test]
public void PreSelectEvent_must_be_fired()
{
@@ -220,43 +206,58 @@
evnt.ResultObject = 999;
}
- /*
+
[Test]
public void PreCreateEventListener_must_be_fired()
{
IResultMap resultMap = ((IModelStoreAccessor)dataMapper).ModelStore.GetResultMap("Account.account-result-constructor");
- ReInitListeners(resultMap);
- resultMap.PreCreateEventListeners = new PreCreateEventListener[] { new MyPreCreateEventListener() };
+ resultMap.PreCreate += PreCreateEventHandler;
Account account = dataMapper.QueryForObject<Account>("SelectAccountViaConstructor", 1);
Assert.That(account.Id, Is.EqualTo(1));
Assert.That(account.LastName, Is.EqualTo("new lastName"));
+
+ resultMap.PreCreate -= PreCreateEventHandler;
+ }
+
+ private static void PreCreateEventHandler(object src, PreCreateEventArgs evnt)
+ {
+ Assert.That(((IResultMap)src).Id, Is.EqualTo("Account.account-result-constructor"));
+ evnt.Parameters[evnt.Parameters.Length - 1] = "new lastName";
}
[Test]
public void PostCreateEventListener_must_be_fired()
{
IResultMap resultMap = ((IModelStoreAccessor)dataMapper).ModelStore.GetResultMap("Account.account-result-constructor");
- ReInitListeners(resultMap);
- resultMap.PostCreateEventListeners = new PostCreateEventListener[] { new MyPostCreateEventListener() };
+ resultMap.PostCreate += PostCreateEventHandler;
Account account = dataMapper.QueryForObject<Account>("SelectAccountViaConstructor", 1);
Assert.That(account.Id, Is.EqualTo(1234));
Assert.That(account.LastName, Is.EqualTo("New LastName"));
Assert.That(account.FirstName, Is.EqualTo("New FirstName"));
+
+ resultMap.PostCreate -= PostCreateEventHandler;
}
+ private static void PostCreateEventHandler(object src, PostCreateEventArgs evnt)
+ {
+ Assert.That(((IResultMap)src).Id, Is.EqualTo("Account.account-result-constructor"));
+ Account account = (Account)evnt.Instance;
+ account.Id = 1234;
+ account.FirstName = "New FirstName";
+ account.LastName = "New LastName";
+ }
+
[Test]
public void PrePropertyEventListener_must_be_fired()
{
IResultMap resultMap = ((IModelStoreAccessor)dataMapper).ModelStore.GetResultMap("Account.account-result");
- ReInitListeners(resultMap);
ResultProperty resultProperty = resultMap.Properties.FindByPropertyName("FirstName");
- ReInitListeners(resultProperty);
- resultProperty.PrePropertyEventListeners = new PrePropertyEventListener[] { new MyPrePropertyEventListener() };
+ resultProperty.PreProperty += PreCreateEventHandler;
Account account = dataMapper.QueryForObject<Account>("SelectAccount", 1);
@@ -264,190 +265,41 @@
Assert.That(account.FirstName, Is.EqualTo("No Name"));
Assert.That(account.LastName, Is.EqualTo("Dalton"));
+ resultProperty.PreProperty -= PreCreateEventHandler;
}
+ private static void PreCreateEventHandler(object src, PrePropertyEventArgs evnt)
+ {
+ Assert.That(((ResultProperty)src).PropertyName, Is.EqualTo("FirstName"));
+ evnt.DataBaseValue = "No Name";
+ }
+
+
[Test]
public void PostPropertyEventListener_must_be_fired()
{
IResultMap resultMap = ((IModelStoreAccessor)dataMapper).ModelStore.GetResultMap("Account.account-result-with-document");
- ReInitListeners(resultMap);
ResultProperty resultProperty = resultMap.Properties.FindByPropertyName("Document");
- ReInitListeners(resultProperty);
- resultProperty.PostPropertyEventListeners = new PostPropertyEventListener[] { new MyPostPropertyEventListener() };
+ resultProperty.PostProperty += PostCreateEventHandler;
Account account = dataMapper.QueryForObject<Account>("SelectAccountWithDocument", 1);
Assert.That(account.Id, Is.EqualTo(1));
Assert.That(account.Document, Is.Not.Null);
Assert.That(account.Document.Id, Is.EqualTo(55));
- }
-
-
- private class MyPostSelectEventListener : PostSelectEventListener
- {
-
- /// <summary>
- /// Calls on the specified event.
- /// </summary>
- /// <param name="evnt">The event.</param>
- /// <returns>Returns is used as the result object</returns>
- public override object OnEvent(PostSelectEventArgs evnt)
- {
- Assert.That(evnt.MappedStatement.Id, Is.EqualTo("SelectAccount"));
- Account account = (Account)evnt.ResultObject;
- account.Id = 99;
-
- return account;
- }
- }
-
- private class MyPreInsertEventListener :PreInsertEventListener
- {
-
- /// <summary>
- /// Calls on the specified event.
- /// </summary>
- /// <param name="evnt">The event.</param>
- /// <returns>Returns is used as the parameter object</returns>
- public override object OnEvent(PreInsertEventArgs evnt)
- {
- Assert.That(evnt.MappedStatement.Id, Is.EqualTo("InsertAccount"));
- Account account = (Account)evnt.ParameterObject;
- account.EmailAddress = "pre.insert.email@noname.org";
-
- return account;
- }
- }
-
- private class MyPostInsertEventListener : PostInsertEventListener
- {
-
- /// <summary>
- /// Calls on the specified event.
- /// </summary>
- /// <param name="evnt">The event.</param>
- /// <returns>Returns is used as the result object</returns>
- public override object OnEvent(PostInsertEventArgs evnt)
- {
- Assert.That(evnt.MappedStatement.Id, Is.EqualTo("InsertAccount"));
- Account account = (Account)evnt.ParameterObject;
- account.Id = 99;
- return 999;
- }
- }
-
- private class MyPreUpdateOrDeleteEventListener : PreUpdateOrDeleteEventListener
- {
-
- /// <summary>
- /// Calls on the specified event.
- /// </summary>
- /// <param name="evnt">The event.</param>
- /// <returns>Returns is used as the parameter object</returns>
- public override object OnEvent(PreUpdateOrDeleteEventArgs evnt)
- {
- Assert.That(evnt.MappedStatement.Id, Is.EqualTo("UpdateAccount"));
- Account account = (Account)evnt.ParameterObject;
- account.EmailAddress = "Pre.Update.Or.Delete.Event@noname.org";
-
- return account;
- }
- }
-
- private class MyPostUpdateOrDeleteEventListener : PostUpdateOrDeleteEventListener
- {
-
- /// <summary>
- /// Calls on the specified event.
- /// </summary>
- /// <param name="evnt">The event.</param>
- /// <returns>Returns is used as the result object</returns>
- public override object OnEvent(PostUpdateOrDeleteEventArgs evnt)
- {
- Assert.That(evnt.MappedStatement.Id, Is.EqualTo("UpdateAccount"));
- Account account = (Account)evnt.ParameterObject;
- account.Id = 99;
- return 999;
- }
- }
- private class MyPreCreateEventListener : PreCreateEventListener
- {
- /// <summary>
- /// Calls before creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <param name="evnt">The event.</param>
- /// <returns>
- /// Returns is used as constructor arguments for the instance being created
- /// </returns>
- public override object OnEvent(PreCreateEvent evnt)
- {
- Assert.That(evnt.ResultMap.Id, Is.EqualTo("Account.account-result-constructor"));
- evnt.Parameters[evnt.Parameters.Length-1] = "new lastName";
-
- return evnt.Parameters;
- }
- }
-
- private class MyPostCreateEventListener : PostCreateEventListener
- {
-
- /// <summary>
- /// Calls after creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <param name="evnt">The event.</param>
- /// <returns>Returns is used as the instance object</returns>
- public override object OnEvent(PostCreateEvent evnt)
- {
- Assert.That(evnt.ResultMap.Id, Is.EqualTo("Account.account-result-constructor"));
- Account account = (Account)evnt.Instance;
- account.Id = 1234;
- account.FirstName = "New FirstName";
- account.LastName = "New LastName";
-
- return account;
- }
+ resultProperty.PostProperty -= PostCreateEventHandler;
}
- private class MyPrePropertyEventListener : PrePropertyEventListener
+ private static void PostCreateEventHandler(object src, PostPropertyEventArgs evnt)
{
+ Assert.That(((ResultProperty)src).PropertyName, Is.EqualTo("Document"));
+ Account account = (Account)evnt.Target;
- /// <summary>
- /// Calls before setting the property value in an instance of a <see cref="IResultMap"/> object.
- /// </summary>
- /// <param name="evnt">The event.</param>
- /// <returns>
- /// Returns is used as databse value, to be set on the property
- /// </returns>
- public override object OnEvent(PrePropertyEvent evnt)
- {
- Assert.That(evnt.ResultProperty.PropertyName, Is.EqualTo("FirstName"));
- return "No Name";
- }
- }
-
- private class MyPostPropertyEventListener : PostPropertyEventListener
- {
- /// <summary>
- /// Calls after creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <param name="evnt">The event.</param>
- /// <returns>Returns is not used</returns>
- public override object OnEvent(PostPropertyEvent evnt)
- {
- Assert.That(evnt.ResultProperty.PropertyName, Is.EqualTo("Document"));
-
- Account account = (Account) evnt.Target;
-
- Assert.That(account.Document, Is.Null);
-
- account.Document = new Document();
- account.Document.Id = 55;
-
- return null;
- }
+ Assert.That(account.Document, Is.Null);
+ account.Document = new Document();
+ account.Document.Id = 55;
}
- */
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Apache.Ibatis.DataMapper.20005.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Apache.Ibatis.DataMapper.20005.csproj?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Apache.Ibatis.DataMapper.20005.csproj (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Apache.Ibatis.DataMapper.20005.csproj Tue Jun 10 11:27:20 2008
@@ -178,25 +178,15 @@
<Compile Include="IModelStoreAccessor.cs" />
<Compile Include="MappedStatements\PropertStrategy\CircularStrategy.cs" />
<Compile Include="MappedStatements\ResultStrategy\CirularStrategy.cs" />
- <Compile Include="Model\Events\BaseResultMapEvent.cs" />
<Compile Include="MappedStatements\IMappedStatementEvents.cs" />
- <Compile Include="Model\Events\IResultMapEvent.cs" />
- <Compile Include="Model\Events\IResultPropertyEvent.cs" />
- <Compile Include="Model\Events\Listeners\IResultMapEventListener.cs" />
- <Compile Include="Model\Events\Listeners\IResultPropertyEventListener.cs" />
- <Compile Include="Model\Events\Listeners\PostCreateEventListener.cs" />
- <Compile Include="Model\Events\Listeners\PostPropertyEventListener.cs" />
- <Compile Include="Model\Events\Listeners\PreCreateEventListener.cs" />
- <Compile Include="Model\Events\Listeners\PrePropertyEventListener.cs" />
<Compile Include="MappedStatements\MappedStatementEventSupport.cs" />
- <Compile Include="Model\Events\PostCreateEvent.cs" />
- <Compile Include="Model\Events\PostPropertyEvent.cs" />
+ <Compile Include="Model\Events\PostCreateEventArgs.cs" />
+ <Compile Include="Model\Events\PostPropertyEventArgs.cs" />
<Compile Include="Model\Events\PostStatementEventArgs.cs" />
- <Compile Include="Model\Events\PreCreateEvent.cs" />
- <Compile Include="Model\Events\PrePropertyEvent.cs" />
+ <Compile Include="Model\Events\PreCreateEventArgs.cs" />
+ <Compile Include="Model\Events\PrePropertyEventArgs.cs" />
<Compile Include="Model\Events\PreStatementEventArgs.cs" />
<Compile Include="Model\Events\BaseStatementEventArgs.cs" />
- <Compile Include="Model\Events\StatementEventType.cs" />
<Compile Include="Model\Events\PostInsertEventArgs.cs" />
<Compile Include="Model\Events\PostSelectEventArgs.cs" />
<Compile Include="Model\Events\PostUpdateOrDeleteEventArgs.cs" />
@@ -205,6 +195,10 @@
<Compile Include="Model\Events\PreUpdateOrDeleteEventArgs.cs" />
<Compile Include="Model\ParameterMapping\InlineParemeterMapBuilder.cs" />
<Compile Include="Model\ResultMapping\ArgumentPropertyCollection.cs" />
+ <Compile Include="Model\ResultMapping\IResultMapEvents.cs" />
+ <Compile Include="Model\ResultMapping\IResultPropertySupportEvents.cs" />
+ <Compile Include="Model\ResultMapping\ResultMapEventSupport.cs" />
+ <Compile Include="Model\ResultMapping\ResultPropertyEventSupport.cs" />
<Compile Include="Model\Sql\External\ExternalSql.cs" />
<Compile Include="ISqlSource.cs" />
<Compile Include="Session\DataMapperSession.cs" />
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs Tue Jun 10 11:27:20 2008
@@ -33,7 +33,6 @@
using Apache.Ibatis.DataMapper.Model;
using Apache.Ibatis.DataMapper.Model.Cache;
using Apache.Ibatis.DataMapper.Model.Events;
-using Apache.Ibatis.DataMapper.Model.Events.Listeners;
using Apache.Ibatis.DataMapper.Model.Statements;
using Apache.Ibatis.DataMapper.Scope;
using Apache.Ibatis.DataMapper.Session;
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs Tue Jun 10 11:27:20 2008
@@ -29,8 +29,6 @@
using System.Collections.Generic;
using Apache.Ibatis.DataMapper.Data;
using Apache.Ibatis.DataMapper.Model;
-using Apache.Ibatis.DataMapper.Model.Events;
-using Apache.Ibatis.DataMapper.Model.Events.Listeners;
using Apache.Ibatis.DataMapper.Model.Statements;
using Apache.Ibatis.DataMapper.Session;
#endregion
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatementEvents.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatementEvents.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatementEvents.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatementEvents.cs Tue Jun 10 11:27:20 2008
@@ -24,7 +24,6 @@
#endregion
using System;
-using System.ComponentModel;
using Apache.Ibatis.DataMapper.Model.Events;
namespace Apache.Ibatis.DataMapper.MappedStatements
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs Tue Jun 10 11:27:20 2008
@@ -30,7 +30,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Data;
-using System.Text;
using Apache.Ibatis.Common.Utilities.Objects;
@@ -38,7 +37,6 @@
using Apache.Ibatis.DataMapper.Data;
using Apache.Ibatis.DataMapper.Model;
using Apache.Ibatis.DataMapper.Model.Events;
-using Apache.Ibatis.DataMapper.Model.Events.Listeners;
using Apache.Ibatis.DataMapper.Model.ParameterMapping;
using Apache.Ibatis.DataMapper.Model.Statements;
using Apache.Ibatis.DataMapper.MappedStatements.ResultStrategy;
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatementEventSupport.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatementEventSupport.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatementEventSupport.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatementEventSupport.cs Tue Jun 10 11:27:20 2008
@@ -109,21 +109,22 @@
/// <param name="key">The key.</param>
/// <param name="parameterObject">The parameter object.</param>
/// <returns>Returns is used as the parameter object</returns>
- protected virtual object RaisePreEvent<TEvent>(object key, object parameterObject)
+ protected object RaisePreEvent<TEvent>(object key, object parameterObject)
where TEvent : PreStatementEventArgs, new()
{
EventHandler<TEvent> handlers = (EventHandler<TEvent>)events[key];
- TEvent eventArgs = new TEvent();
- eventArgs.ParameterObject = parameterObject;
-
- // should process _all_ the listeners
if (handlers != null)
{
+ TEvent eventArgs = new TEvent();
+ eventArgs.ParameterObject = parameterObject;
handlers(this, eventArgs);
+ return eventArgs.ParameterObject;
+ }
+ else
+ {
+ return parameterObject;
}
-
- return eventArgs.ParameterObject;
}
/// <summary>
@@ -133,22 +134,23 @@
/// <param name="parameterObject">The parameter object.</param>
/// <param name="resultObject">The result object.</param>
/// <returns>Returns is used as the result object</returns>
- protected virtual TType RaisePostEvent<TType, TEvent>(object key, object parameterObject, TType resultObject)
+ protected TType RaisePostEvent<TType, TEvent>(object key, object parameterObject, TType resultObject)
where TEvent : PostStatementEventArgs, new()
{
EventHandler<TEvent> handlers = (EventHandler<TEvent>)events[key];
- TEvent eventArgs = new TEvent();
- eventArgs.ParameterObject = parameterObject;
- eventArgs.ResultObject = resultObject;
-
- // should process _all_ the listeners
if (handlers != null)
{
+ TEvent eventArgs = new TEvent();
+ eventArgs.ParameterObject = parameterObject;
+ eventArgs.ResultObject = resultObject;
handlers(this, eventArgs);
+ return (TType)eventArgs.ResultObject;
+ }
+ else
+ {
+ return resultObject;
}
-
- return (TType)eventArgs.ResultObject;
}
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/BaseStatementEventArgs.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/BaseStatementEventArgs.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/BaseStatementEventArgs.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/BaseStatementEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -24,7 +24,6 @@
#endregion
using System;
-using Apache.Ibatis.DataMapper.MappedStatements;
namespace Apache.Ibatis.DataMapper.Model.Events
{
@@ -47,13 +46,6 @@
set { parameterObject = value; }
}
- /// <summary>
- /// Gets the event type.
- /// </summary>
- /// <value>The type.</value>
- public abstract StatementEventType Type { get; }
-
-
#endregion
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/Events.cd
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/Events.cd?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/Events.cd (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/Events.cd Tue Jun 10 11:27:20 2008
@@ -5,7 +5,7 @@
<Position X="5.5" Y="0.75" Width="2.25" />
<TypeIdentifier>
<FileName>Model\Events\BaseStatementEventArgs.cs</FileName>
- <HashCode>AAABAAAAAAAAAAAAAAgAAAAAAAAAAAAAAQgAAAAAAQA=</HashCode>
+ <HashCode>AAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAQgAAAAAAAA=</HashCode>
</TypeIdentifier>
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
@@ -70,4 +70,24 @@
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
</TypeIdentifier>
</Class>
+ <Class Name="Apache.Ibatis.DataMapper.Model.Events.PreCreateEventArgs">
+ <Position X="0.75" Y="8" Width="2" />
+ <TypeIdentifier>
+ <FileName>Model\Events\PreCreateEventArgs.cs</FileName>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAA=</HashCode>
+ </TypeIdentifier>
+ <Compartments>
+ <Compartment Name="Fields" Collapsed="true" />
+ </Compartments>
+ </Class>
+ <Class Name="Apache.Ibatis.DataMapper.Model.Events.PostCreateEventArgs">
+ <Position X="3.25" Y="8" Width="2" />
+ <TypeIdentifier>
+ <FileName>Model\Events\PostCreateEventArgs.cs</FileName>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAA=</HashCode>
+ </TypeIdentifier>
+ <Compartments>
+ <Compartment Name="Fields" Collapsed="true" />
+ </Compartments>
+ </Class>
</ClassDiagram>
\ No newline at end of file
Copied: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostCreateEventArgs.cs (from r664536, ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostCreateEvent.cs)
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostCreateEventArgs.cs?p2=ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostCreateEventArgs.cs&p1=ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostCreateEvent.cs&r1=664536&r2=666257&rev=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostCreateEvent.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostCreateEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -24,14 +24,15 @@
********************************************************************************/
#endregion
+using System;
using Apache.Ibatis.DataMapper.Model.ResultMapping;
namespace Apache.Ibatis.DataMapper.Model.Events
{
/// <summary>
- /// Lauchs after creating an instance of the <see cref="IResultMap"/> object.
+ /// Event launchs after creating an instance of the <see cref="IResultMap"/> object.
/// </summary>
- public sealed class PostCreateEvent : BaseResultMapEvent
+ public sealed class PostCreateEventArgs : EventArgs
{
private object instance = null;
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostInsertEventArgs.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostInsertEventArgs.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostInsertEventArgs.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostInsertEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -30,13 +30,6 @@
/// </summary>
public sealed class PostInsertEventArgs : PostStatementEventArgs
{
- /// <summary>
- /// Gets the event type.
- /// </summary>
- /// <value>The type.</value>
- public override StatementEventType Type
- {
- get { return StatementEventType.PostInsert; }
- }
+
}
}
\ No newline at end of file
Copied: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostPropertyEventArgs.cs (from r664536, ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostPropertyEvent.cs)
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostPropertyEventArgs.cs?p2=ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostPropertyEventArgs.cs&p1=ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostPropertyEvent.cs&r1=664536&r2=666257&rev=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostPropertyEvent.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostPropertyEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -24,6 +24,7 @@
********************************************************************************/
#endregion
+using System;
using Apache.Ibatis.DataMapper.Model.ResultMapping;
namespace Apache.Ibatis.DataMapper.Model.Events
@@ -31,22 +32,11 @@
/// <summary>
/// Lauchs after setting the property value in an instance of a <see cref="IResultMap"/> object.
/// </summary>
- public sealed class PostPropertyEvent : IResultPropertyEvent
+ public sealed class PostPropertyEventArgs : EventArgs
{
- private ResultProperty property = null;
private object target = null;
/// <summary>
- /// Gets or sets the result property.
- /// </summary>
- /// <value>The result property.</value>
- public ResultProperty ResultProperty
- {
- get { return property; }
- set { property = value; }
- }
-
- /// <summary>
/// Gets or sets the target.
/// </summary>
/// <value>The target.</value>
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostSelectEventArgs.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostSelectEventArgs.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostSelectEventArgs.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostSelectEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -30,14 +30,6 @@
/// </summary>
public sealed class PostSelectEventArgs : PostStatementEventArgs
{
- /// <summary>
- /// Gets the event type.
- /// </summary>
- /// <value>The type.</value>
- public override StatementEventType Type
- {
- get { return StatementEventType.PostSelect; }
- }
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostUpdateOrDeleteEventArgs.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostUpdateOrDeleteEventArgs.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostUpdateOrDeleteEventArgs.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PostUpdateOrDeleteEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -30,14 +30,6 @@
/// </summary>
public sealed class PostUpdateOrDeleteEventArgs : PostStatementEventArgs
{
- /// <summary>
- /// Gets the event type.
- /// </summary>
- /// <value>The type.</value>
- public override StatementEventType Type
- {
- get { return StatementEventType.PostUpdateOrDelete; }
- }
}
}
Copied: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreCreateEventArgs.cs (from r664536, ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreCreateEvent.cs)
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreCreateEventArgs.cs?p2=ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreCreateEventArgs.cs&p1=ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreCreateEvent.cs&r1=664536&r2=666257&rev=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreCreateEvent.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreCreateEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -24,14 +24,15 @@
********************************************************************************/
#endregion
+using System;
using Apache.Ibatis.DataMapper.Model.ResultMapping;
namespace Apache.Ibatis.DataMapper.Model.Events
{
/// <summary>
- /// Lauchs before creating an instance of the <see cref="IResultMap"/> object.
+ /// Event lauchs before creating an instance of the <see cref="IResultMap"/> object.
/// </summary>
- public sealed class PreCreateEvent : BaseResultMapEvent
+ public sealed class PreCreateEventArgs : EventArgs
{
private object[] parameters = null;
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreInsertEventArgs.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreInsertEventArgs.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreInsertEventArgs.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreInsertEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -30,13 +30,6 @@
/// </summary>
public sealed class PreInsertEventArgs : PreStatementEventArgs
{
- /// <summary>
- /// Gets the event type.
- /// </summary>
- /// <value>The type.</value>
- public override StatementEventType Type
- {
- get { return StatementEventType.PreInsert; }
- }
+
}
}
Copied: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PrePropertyEventArgs.cs (from r664536, ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PrePropertyEvent.cs)
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PrePropertyEventArgs.cs?p2=ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PrePropertyEventArgs.cs&p1=ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PrePropertyEvent.cs&r1=664536&r2=666257&rev=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PrePropertyEvent.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PrePropertyEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -24,6 +24,7 @@
********************************************************************************/
#endregion
+using System;
using Apache.Ibatis.DataMapper.Model.ResultMapping;
namespace Apache.Ibatis.DataMapper.Model.Events
@@ -31,23 +32,12 @@
/// <summary>
/// Lauchs before setting the property value in an instance of a <see cref="IResultMap"/> object.
/// </summary>
- public sealed class PrePropertyEvent : IResultPropertyEvent
+ public sealed class PrePropertyEventArgs : EventArgs
{
- private ResultProperty property = null;
private object dataBaseValue = null;
private object target = null;
/// <summary>
- /// Gets or sets the result property.
- /// </summary>
- /// <value>The result property.</value>
- public ResultProperty ResultProperty
- {
- get { return property; }
- set { property = value; }
- }
-
- /// <summary>
/// Gets or sets the data base value.
/// </summary>
/// <value>The data base value.</value>
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreSelectEventArgs.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreSelectEventArgs.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreSelectEventArgs.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreSelectEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -30,14 +30,6 @@
/// </summary>
public sealed class PreSelectEventArgs : PreStatementEventArgs
{
- /// <summary>
- /// Gets the event type.
- /// </summary>
- /// <value>The type.</value>
- public override StatementEventType Type
- {
- get { return StatementEventType.PreSelect; }
- }
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreUpdateOrDeleteEventArgs.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreUpdateOrDeleteEventArgs.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreUpdateOrDeleteEventArgs.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Events/PreUpdateOrDeleteEventArgs.cs Tue Jun 10 11:27:20 2008
@@ -30,13 +30,5 @@
/// </summary>
public sealed class PreUpdateOrDeleteEventArgs : PreStatementEventArgs
{
- /// <summary>
- /// Gets the event type.
- /// </summary>
- /// <value>The type.</value>
- public override StatementEventType Type
- {
- get { return StatementEventType.PreUpdateOrDelete; }
- }
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/AutoResultMap.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/AutoResultMap.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/AutoResultMap.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/AutoResultMap.cs Tue Jun 10 11:27:20 2008
@@ -34,7 +34,6 @@
using Apache.Ibatis.Common.Utilities.Objects;
using Apache.Ibatis.DataMapper.DataExchange;
using Apache.Ibatis.DataMapper.Model.Events;
-using Apache.Ibatis.DataMapper.Model.Events.Listeners;
#endregion
@@ -77,7 +76,6 @@
this.resultClassFactory = resultClassFactory;
this.dataExchange = dataExchange;
this.isSimpleType = isSimpleType;
-
}
#region IResultMap Members
@@ -214,44 +212,27 @@
get { throw new NotImplementedException("The method or operation is not implemented."); }
}
- /// <summary>
- /// Handles event generated after creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <value>The post create events.</value>
- public IResultMapEventListener<PostCreateEvent>[] PostCreateEventListeners
- {
- get { throw new Exception("The method or operation is not implemented."); }
- set { throw new Exception("The method or operation is not implemented."); }
- }
+ #endregion
- /// <summary>
- /// Handles event generated before creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <value>The pre create events.</value>
- public IResultMapEventListener<PreCreateEvent>[] PreCreateEventListeners
- {
- get { throw new Exception("The method or operation is not implemented."); }
- set { throw new Exception("The method or operation is not implemented."); }
- }
+
+ #region IResultMapEvents Members
/// <summary>
- /// Handles event generated before setting the property value in an instance of a <see cref="IResultMap"/> object.
+ /// Handles event <see cref="PreCreateEventArgs"/> generated before creating an instance of the <see cref="IResultMap"/> object.
/// </summary>
- /// <value>The post create events.</value>
- public IResultMapEventListener<PrePropertyEvent>[] PrePropertyEventListeners
+ public event EventHandler<PreCreateEventArgs> PreCreate
{
- get { throw new Exception("The method or operation is not implemented."); }
- set { throw new Exception("The method or operation is not implemented."); }
+ add { throw new NotImplementedException("PreCreate EventHandler"); }
+ remove { throw new NotImplementedException("PreCreate EventHandler"); }
}
/// <summary>
- /// Handles event generated after setting the property value in an instance of a <see cref="IResultMap"/> object.
+ /// Handles event <see cref="PostCreateEventArgs"/> generated after creating an instance of the <see cref="IResultMap"/> object.
/// </summary>
- /// <value>The pre create events.</value>
- public IResultMapEventListener<PostPropertyEvent>[] PostPropertyEventListeners
+ public event EventHandler<PostCreateEventArgs> PostCreate
{
- get { throw new Exception("The method or operation is not implemented."); }
- set { throw new Exception("The method or operation is not implemented."); }
+ add { throw new NotImplementedException("PostCreate EventHandler"); }
+ remove { throw new NotImplementedException("PostCreate EventHandler"); }
}
#endregion
@@ -263,7 +244,5 @@
{
return new AutoResultMap(resultClass, resultClassFactory, dataExchange, isSimpleType);
}
-
-
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMap.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMap.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMap.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMap.cs Tue Jun 10 11:27:20 2008
@@ -29,8 +29,6 @@
using System.Collections.Generic;
using System.Data;
using Apache.Ibatis.DataMapper.DataExchange;
-using Apache.Ibatis.DataMapper.Model.Events;
-using Apache.Ibatis.DataMapper.Model.Events.Listeners;
#endregion
@@ -39,7 +37,7 @@
/// <summary>
/// This is a grouping of ResultMapping objects used to map results back to objects
/// </summary>
- public interface IResultMap
+ public interface IResultMap : IResultMapEvents
{
/// <summary>
/// The collection of constructor parameters.
@@ -121,16 +119,5 @@
/// <returns></returns>
IResultMap ResolveSubMap(IDataReader dataReader);
- /// <summary>
- /// Handles event generated before creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <value>The pre create events.</value>
- IResultMapEventListener<PreCreateEvent>[] PreCreateEventListeners { get; set;}
-
- /// <summary>
- /// Handles event generated after creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <value>The post create events.</value>
- IResultMapEventListener<PostCreateEvent>[] PostCreateEventListeners { get; set;}
}
}
\ No newline at end of file
Added: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMapEvents.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMapEvents.cs?rev=666257&view=auto
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMapEvents.cs (added)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMapEvents.cs Tue Jun 10 11:27:20 2008
@@ -0,0 +1,39 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 476843 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2008/2005 - The Apache Software Foundation
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+using System;
+using Apache.Ibatis.DataMapper.Model.Events;
+
+namespace Apache.Ibatis.DataMapper.Model.ResultMapping
+{
+ /// <summary>
+ /// Defines the contract for events generated during <see cref="IResultMap"/> analyse.
+ /// </summary>
+ public interface IResultMapEvents
+ {
+ event EventHandler<PreCreateEventArgs> PreCreate;
+ event EventHandler<PostCreateEventArgs> PostCreate;
+ }
+}
Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMapEvents.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultMapEvents.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultPropertySupportEvents.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultPropertySupportEvents.cs?rev=666257&view=auto
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultPropertySupportEvents.cs (added)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/IResultPropertySupportEvents.cs Tue Jun 10 11:27:20 2008
@@ -0,0 +1,40 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 476843 $
+ * $LastChangedDate: 2008-06-08 20:20:44 +0200 (dim., 08 juin 2008) $
+ * $LastChangedBy: gbayon $
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2008/2005 - The Apache Software Foundation
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+using System;
+using Apache.Ibatis.DataMapper.Model.Events;
+
+namespace Apache.Ibatis.DataMapper.Model.ResultMapping
+{
+ /// <summary>
+ /// Defines the contract for events generated during <see cref="ResultProperty"/> analyse.
+ /// </summary>
+ public interface IResultPropertySupportEvents
+ {
+ event EventHandler<PrePropertyEventArgs> PreProperty;
+ event EventHandler<PostPropertyEventArgs> PostProperty;
+
+ }
+}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/NullResultMap.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/NullResultMap.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/NullResultMap.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/NullResultMap.cs Tue Jun 10 11:27:20 2008
@@ -27,7 +27,6 @@
using Apache.Ibatis.DataMapper.DataExchange;
using System.Collections.Generic;
using Apache.Ibatis.DataMapper.Model.Events;
-using Apache.Ibatis.DataMapper.Model.Events.Listeners;
namespace Apache.Ibatis.DataMapper.Model.ResultMapping
{
@@ -194,44 +193,25 @@
get { return keysProperties; }
}
- /// <summary>
- /// Handles event generated after creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <value>The post create events.</value>
- public IResultMapEventListener<PostCreateEvent>[] PostCreateEventListeners
- {
- get { throw new Exception("The method or operation is not implemented."); }
- set { throw new Exception("The method or operation is not implemented."); }
- }
-
- /// <summary>
- /// Handles event generated before creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <value>The pre create events.</value>
- public IResultMapEventListener<PreCreateEvent>[] PreCreateEventListeners
- {
- get { throw new Exception("The method or operation is not implemented."); }
- set { throw new Exception("The method or operation is not implemented."); }
- }
+ #region IResultMapEvents Members
/// <summary>
- /// Handles event generated before setting the property value in an instance of a <see cref="IResultMap"/> object.
+ /// Handles event <see cref="PreCreateEventArgs"/> generated before creating an instance of the <see cref="IResultMap"/> object.
/// </summary>
- /// <value>The post create events.</value>
- public IResultMapEventListener<PrePropertyEvent>[] PrePropertyEventListeners
+ public event EventHandler<PreCreateEventArgs> PreCreate
{
- get { throw new Exception("The method or operation is not implemented."); }
- set { throw new Exception("The method or operation is not implemented."); }
+ add { throw new NotImplementedException("PreCreate EventHandler"); }
+ remove { throw new NotImplementedException("PreCreate EventHandler"); }
}
/// <summary>
- /// Handles event generated after setting the property value in an instance of a <see cref="IResultMap"/> object.
+ /// Handles event <see cref="PostCreateEventArgs"/> generated after creating an instance of the <see cref="IResultMap"/> object.
/// </summary>
- /// <value>The pre create events.</value>
- public IResultMapEventListener<PostPropertyEvent>[] PostPropertyEventListeners
+ public event EventHandler<PostCreateEventArgs> PostCreate
{
- get { throw new Exception("The method or operation is not implemented."); }
- set { throw new Exception("The method or operation is not implemented."); }
+ add { throw new NotImplementedException("PostCreate EventHandler"); }
+ remove { throw new NotImplementedException("PostCreate EventHandler"); }
}
+ #endregion
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMap.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMap.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMap.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMap.cs Tue Jun 10 11:27:20 2008
@@ -35,8 +35,6 @@
using Apache.Ibatis.Common.Utilities;
using Apache.Ibatis.Common.Utilities.Objects;
using Apache.Ibatis.DataMapper.DataExchange;
-using Apache.Ibatis.DataMapper.Model.Events;
-using Apache.Ibatis.DataMapper.Model.Events.Listeners;
using Apache.Ibatis.DataMapper.TypeHandlers;
#endregion
@@ -48,7 +46,7 @@
/// </summary>
[Serializable]
[DebuggerDisplay("ResultMap: {Id}-{ClassName}")]
- public sealed class ResultMap : IResultMap
+ public sealed class ResultMap : ResultMapEventSupport, IResultMap
{
private static IResultMap nullResultMap = null;
@@ -84,11 +82,6 @@
[NonSerialized]
private readonly ResultPropertyCollection keysProperties = new ResultPropertyCollection();
- [NonSerialized]
- private IResultMapEventListener<PostCreateEvent>[] postCreateEventListeners = new IResultMapEventListener<PostCreateEvent>[] { };
- [NonSerialized]
- private IResultMapEventListener<PreCreateEvent>[] preCreateEventListeners = new IResultMapEventListener<PreCreateEvent>[] { };
-
#endregion
#region Properties
@@ -275,31 +268,12 @@
{
if (!isSimpleType)
{
- if (preCreateEventListeners.Length > 0)
- {
- PreCreateEvent evnt = new PreCreateEvent();
- evnt.ResultMap = this;
- evnt.Parameters = parameters;
- foreach (IResultMapEventListener<PreCreateEvent> listener in preCreateEventListeners)
- {
- evnt.Parameters = (object[])listener.OnEvent(evnt);
- }
- parameters = evnt.Parameters;
- }
+ parameters = RaisePreCreateEvent(parameters);
object instance = objectFactory.CreateInstance(parameters);
- if (postCreateEventListeners.Length > 0)
- {
- PostCreateEvent evnt = new PostCreateEvent();
- evnt.ResultMap = this;
- evnt.Instance = instance;
- foreach (IResultMapEventListener<PostCreateEvent> listener in postCreateEventListeners)
- {
- evnt.Instance = listener.OnEvent(evnt);
- }
- instance = evnt.Instance;
- }
+ instance = RaisePostCreateEvent(instance);
+
return instance;
}
else
@@ -373,26 +347,6 @@
get { return keysProperties; }
}
- /// <summary>
- /// Handles event generated after creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <value>The post create events.</value>
- public IResultMapEventListener<PostCreateEvent>[] PostCreateEventListeners
- {
- get { return postCreateEventListeners; }
- set { postCreateEventListeners = value; }
- }
-
- /// <summary>
- /// Handles event generated before creating an instance of the <see cref="IResultMap"/> object.
- /// </summary>
- /// <value>The pre create events.</value>
- public IResultMapEventListener<PreCreateEvent>[] PreCreateEventListeners
- {
- get { return preCreateEventListeners; }
- set { preCreateEventListeners = value; }
- }
-
#endregion
Added: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMapEventSupport.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMapEventSupport.cs?rev=666257&view=auto
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMapEventSupport.cs (added)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMapEventSupport.cs Tue Jun 10 11:27:20 2008
@@ -0,0 +1,116 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 476843 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2008/2005 - The Apache Software Foundation
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+using System;
+using System.ComponentModel;
+using Apache.Ibatis.DataMapper.Model.Events;
+
+namespace Apache.Ibatis.DataMapper.Model.ResultMapping
+{
+ /// <summary>
+ /// Base implementation for <see cref="IResultMapEvents"/>
+ /// </summary>
+ [Serializable]
+ public abstract class ResultMapEventSupport : IResultMapEvents
+ {
+ protected static readonly object PreCreateEvent = new object();
+ protected static readonly object PostCreateEvent = new object();
+
+ private readonly EventHandlerList events = new EventHandlerList();
+
+ #region IResultMapEvents Members
+
+ /// <summary>
+ /// Handles event <see cref="PreCreateEventArgs"/> generated before creating an instance of the <see cref="IResultMap"/> object.
+ /// </summary>
+ public event EventHandler<PreCreateEventArgs> PreCreate
+ {
+ add { events.AddHandler(PreCreateEvent, value); }
+ remove { events.RemoveHandler(PreCreateEvent, value); }
+ }
+
+ /// <summary>
+ /// Handles event <see cref="PostCreateEventArgs"/> generated after creating an instance of the <see cref="IResultMap"/> object.
+ /// </summary>
+ public event EventHandler<PostCreateEventArgs> PostCreate
+ {
+ add { events.AddHandler(PostCreateEvent, value); }
+ remove { events.RemoveHandler(PostCreateEvent, value); }
+ }
+ #endregion
+
+ /// <summary>
+ /// Raises the <see cref="PreCreateEventArgs"/>.
+ /// </summary>
+ /// <param name="parameters">The parameters.</param>
+ /// <returns>
+ /// Returns is used as the parameters used to create the object
+ /// </returns>
+ protected object[] RaisePreCreateEvent(object[] parameters)
+ {
+ EventHandler<PreCreateEventArgs> handlers = (EventHandler<PreCreateEventArgs>)events[PreCreateEvent];
+
+ if (handlers != null)
+ {
+ PreCreateEventArgs eventArgs = new PreCreateEventArgs();
+ eventArgs.Parameters = parameters;
+
+ handlers(this, eventArgs);
+
+ return eventArgs.Parameters;
+ }
+ else
+ {
+ return parameters;
+ }
+ }
+
+ /// <summary>
+ /// Raises the <see cref="PostCreateEventArgs"/>.
+ /// </summary>
+ /// <param name="instance">The instance.</param>
+ /// <returns>
+ /// Returns is used as the parameters used to create the object
+ /// </returns>
+ protected object RaisePostCreateEvent(object instance)
+ {
+ EventHandler<PostCreateEventArgs> handlers = (EventHandler<PostCreateEventArgs>)events[PostCreateEvent];
+
+ if (handlers != null)
+ {
+ PostCreateEventArgs eventArgs = new PostCreateEventArgs();
+ eventArgs.Instance = instance;
+
+ handlers(this, eventArgs);
+
+ return eventArgs.Instance;
+ }
+ else
+ {
+ return instance;
+ }
+ }
+ }
+}
Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMapEventSupport.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultMapEventSupport.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultProperty.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultProperty.cs?rev=666257&r1=666256&r2=666257&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultProperty.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultProperty.cs Tue Jun 10 11:27:20 2008
@@ -42,8 +42,6 @@
using Apache.Ibatis.DataMapper.Exceptions;
using Apache.Ibatis.DataMapper.MappedStatements.ArgumentStrategy;
using Apache.Ibatis.DataMapper.MappedStatements.PropertyStrategy;
-using Apache.Ibatis.DataMapper.Model.Events;
-using Apache.Ibatis.DataMapper.Model.Events.Listeners;
using Apache.Ibatis.DataMapper.Proxy;
using Apache.Ibatis.DataMapper.Scope;
using Apache.Ibatis.DataMapper.TypeHandlers;
@@ -57,7 +55,7 @@
/// </summary>
[Serializable]
[DebuggerDisplay("ResultProperty: {propertyName}-{columnName}")]
- public class ResultProperty
+ public class ResultProperty : ResultPropertyEventSupport
{
/// <summary>
/// Unknow Column Index
@@ -106,36 +104,11 @@
[NonSerialized]
private static readonly IFactory arrayListFactory = new ArrayListFactory();
- [NonSerialized]
- private IResultPropertyEventListener<PrePropertyEvent>[] prePropertyEventListeners = new IResultPropertyEventListener<PrePropertyEvent>[] { };
- [NonSerialized]
- private IResultPropertyEventListener<PostPropertyEvent>[] postPropertyEventListeners = new IResultPropertyEventListener<PostPropertyEvent>[] { };
-
#endregion
#region Properties
/// <summary>
- /// Handles event generated before setting the property value of a <see cref="ResultProperty"/>.
- /// </summary>
- /// <value>The post create events.</value>
- public IResultPropertyEventListener<PrePropertyEvent>[] PrePropertyEventListeners
- {
- get { return prePropertyEventListeners; }
- set { prePropertyEventListeners = value; }
- }
-
- /// <summary>
- /// Handles event generated after setting the property value of a <see cref="ResultProperty"/>.
- /// </summary>
- /// <value>The pre create events.</value>
- public IResultPropertyEventListener<PostPropertyEvent>[] PostPropertyEventListeners
- {
- get { return postPropertyEventListeners; }
- set { postPropertyEventListeners = value; }
- }
-
- /// <summary>
/// Tell us if the member type implement generic Ilist interface.
/// </summary>
public bool IsGenericIList
@@ -545,33 +518,13 @@
/// <param name="target">Object to set the field/property on.</param>
/// <param name="value">Value.</param>
public void Set(object target, object value)
- {
- if (prePropertyEventListeners.Length > 0)
- {
- PrePropertyEvent evnt = new PrePropertyEvent();
- evnt.ResultProperty = this;
- evnt.DataBaseValue = value;
- evnt.Target = target;
- foreach (IResultPropertyEventListener<PrePropertyEvent> listener in prePropertyEventListeners)
- {
- evnt.DataBaseValue = listener.OnEvent(evnt);
- }
- value = evnt.DataBaseValue;
- }
-
- setAccessor.Set(target, value);
-
- if (postPropertyEventListeners.Length > 0)
- {
- PostPropertyEvent evnt = new PostPropertyEvent();
- evnt.ResultProperty = this;
- evnt.Target = target;
- foreach (IResultPropertyEventListener<PostPropertyEvent> listener in postPropertyEventListeners)
- {
- listener.OnEvent(evnt);
- }
- }
- }
+ {
+ value = RaisePrePropertyEvent(target, value);
+
+ setAccessor.Set(target, value);
+
+ RaisePostPropertyEvent(target);
+ }
/// <summary>
/// Gets a result argument value.
@@ -650,7 +603,6 @@
/// </summary>
private class ArrayListFactory : IFactory
{
-
#region IFactory Members
/// <summary>
Added: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultPropertyEventSupport.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultPropertyEventSupport.cs?rev=666257&view=auto
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultPropertyEventSupport.cs (added)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultPropertyEventSupport.cs Tue Jun 10 11:27:20 2008
@@ -0,0 +1,106 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 476843 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2008/2005 - The Apache Software Foundation
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+using System;
+using System.ComponentModel;
+using Apache.Ibatis.DataMapper.Model.Events;
+
+namespace Apache.Ibatis.DataMapper.Model.ResultMapping
+{
+ /// <summary>
+ /// Base implementation for <see cref="IResultPropertySupportEvents"/>
+ /// </summary>
+ [Serializable]
+ public abstract class ResultPropertyEventSupport : IResultPropertySupportEvents
+ {
+ protected static readonly object PrePropertyEvent = new object();
+ protected static readonly object PostPropertyEvent = new object();
+
+ private readonly EventHandlerList events = new EventHandlerList();
+
+ #region IResultPropertySupportEvents Members
+
+ /// <summary>
+ /// Handles event <see cref="PrePropertyEventArgs"/> generated before setting the property value in an instance of a <see cref="IResultMap"/> object.
+ /// </summary>
+ public event EventHandler<PrePropertyEventArgs> PreProperty
+ {
+ add { events.AddHandler(PrePropertyEvent, value); }
+ remove { events.RemoveHandler(PrePropertyEvent, value); }
+ }
+
+ /// <summary>
+ /// Handles event <see cref="PostCreateEventArgs"/> generated after setting the property value in an instance of a <see cref="IResultMap"/> object.
+ /// </summary>
+ public event EventHandler<PostPropertyEventArgs> PostProperty
+ {
+ add { events.AddHandler(PostPropertyEvent, value); }
+ remove { events.RemoveHandler(PostPropertyEvent, value); }
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Raises the <see cref="PreCreateEventArgs"/>.
+ /// </summary>
+ /// <param name="target">The target.</param>
+ /// <param name="value">The value.</param>
+ /// <returns>Returns is used as databse value, to be set on the property</returns>
+ protected object RaisePrePropertyEvent(object target, object value)
+ {
+ EventHandler<PrePropertyEventArgs> handlers = (EventHandler<PrePropertyEventArgs>)events[PrePropertyEvent];
+
+ if (handlers != null)
+ {
+ PrePropertyEventArgs evnt = new PrePropertyEventArgs();
+ evnt.DataBaseValue = value;
+ evnt.Target = target;
+ handlers(this, evnt);
+
+ return evnt.DataBaseValue;
+ }
+ else
+ {
+ return value;
+ }
+ }
+
+ /// <summary>
+ /// Raises the <see cref="PostPropertyEventArgs"/>.
+ /// </summary>
+ /// <param name="target">The target.</param>
+ protected void RaisePostPropertyEvent(object target)
+ {
+ EventHandler<PostPropertyEventArgs> handlers = (EventHandler<PostPropertyEventArgs>)events[PostPropertyEvent];
+
+ if (handlers != null)
+ {
+ PostPropertyEventArgs evnt = new PostPropertyEventArgs();
+ evnt.Target = target;
+ handlers(this, evnt);
+ }
+ }
+ }
+}
Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultPropertyEventSupport.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ResultMapping/ResultPropertyEventSupport.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy