avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject svn commit: rev 37257 - in avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel: . Handler
Date Tue, 31 Aug 2004 18:44:52 GMT
Author: hammett
Date: Tue Aug 31 11:44:51 2004
New Revision: 37257

Modified:
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/BaseKernel.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/AbstractHandler.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernelEvents.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernel.sln
Log:
Event infraestructure.

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/BaseKernel.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/BaseKernel.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/BaseKernel.cs	Tue Aug 31
11:44:51 2004
@@ -27,6 +27,7 @@
 	public class BaseKernel : IKernel, IDisposable
 	{
         private static readonly object ComponentRegisteredEvent = new object();
+        private static readonly object ComponentInterceptionEvent = new object();
         private static readonly object ComponentCreatedEvent = new object();
         private static readonly object ComponentDestroyedEvent = new object();
 
@@ -97,10 +98,44 @@
             OnNewHandler( model, key, service, implementation, handler);
         }
 
+        /// <summary>
+        /// Pending
+        /// </summary>
+        /// <value></value>
         public event ComponentDataDelegate ComponentRegistered
         {
             add { m_events.AddHandler(ComponentRegisteredEvent, value); }
             remove { m_events.RemoveHandler(ComponentRegisteredEvent, value); }
+        }
+
+        /// <summary>
+        /// Pending
+        /// </summary>
+        /// <value></value>
+        public event InterceptionDelegate ComponentInterception
+        {
+            add { m_events.AddHandler(ComponentInterceptionEvent, value); }
+            remove { m_events.RemoveHandler(ComponentInterceptionEvent, value); }
+        }
+
+        /// <summary>
+        /// Pending
+        /// </summary>
+        /// <value></value>
+        public event ComponentInstanceDelegate ComponentCreated
+        {
+            add { m_events.AddHandler(ComponentCreatedEvent, value); }
+            remove { m_events.RemoveHandler(ComponentCreatedEvent, value); }
+        }
+
+        /// <summary>
+        /// Pending
+        /// </summary>
+        /// <value></value>
+        public event ComponentInstanceDelegate ComponentDestroyed
+        {
+            add { m_events.AddHandler(ComponentDestroyedEvent, value); }
+            remove { m_events.RemoveHandler(ComponentDestroyedEvent, value); }
         }
 
         /// <summary>

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/AbstractHandler.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/AbstractHandler.cs
(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/AbstractHandler.cs
Tue Aug 31 11:44:51 2004
@@ -67,7 +67,10 @@
 			{
 				object instance = m_lifestyleManager.Resolve();
 
-				RegisterInstance( ref instance );
+                // TODO: Proxy
+                // instance = RaiseInterceptorEvent( instance );
+
+                RegisterInstance( instance );
 
 				return instance;
 			}
@@ -104,9 +107,9 @@
 
 		#endregion
 
-		protected virtual void RegisterInstance( ref object instance )
+		protected virtual void RegisterInstance( object instance )
 		{
-			// RaiseComponentCreatedEvent( ref instance );
+			RaiseComponentCreatedEvent( instance );
 
 			if (!HasInstance( instance, false ))
 			{
@@ -117,10 +120,10 @@
 		}
 
 		protected virtual void UnregisterInstance( object instance )
-		{
-			// RaiseComponentCreatedEvent( instance );
-
-			if (m_instances.Count == 0)
+		{
+            RaiseComponentDestroyedEvent( instance );
+
+            if (m_instances.Count == 0)
 			{
 				return;
 			}
@@ -152,34 +155,28 @@
 			return false;
 		}
 
-        /*
-		protected virtual void RaiseComponentCreatedEvent( ref object instance )
-		{
-			IEventManager eventManager = (IEventManager) m_kernel.GetSubsystem( KernelConstants.EVENTS
);
-			
-			if (eventManager != null)
-			{
-				// We're passing the instance and allowing the listeners to
-				// replace/wrap the instance as they wish.
-				EventManagerData data = new EventManagerData( m_componentModel, instance );
-				
-				eventManager.OnComponentCreated( data );
-
-				/// 90% of cases we're setting the same instance back
-				instance = data.Instance;
-			}
-		}
-
 		protected virtual void RaiseComponentCreatedEvent( object instance )
-		{
-			IEventManager eventManager = (IEventManager) m_kernel.GetSubsystem( KernelConstants.EVENTS
);
-			
-			if (eventManager != null)
-			{
-				EventManagerData data = new EventManagerData( m_componentModel, instance );
-				eventManager.OnComponentDestroyed( data );
-			}
-		}
-        */
-	}
+		{
+            ComponentInstanceDelegate createdEvent = m_kernel.ComponentCreated;
+            
+            if (createdEvent == null)
+            {
+                return;
+            }
+
+            createdEvent( m_componentModel, this, instance );
+        }
+
+        protected virtual void RaiseComponentDestroyedEvent(object instance)
+        {
+            ComponentInstanceDelegate destroyedEvent = m_kernel.ComponentDestroyed;
+
+            if (destroyedEvent == null)
+            {
+                return;
+            }
+
+            destroyedEvent(m_componentModel, this, instance);
+        }
+    }
 }

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernelEvents.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernelEvents.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernelEvents.cs	Tue Aug
31 11:44:51 2004
@@ -21,9 +21,9 @@
 
     public delegate void ComponentDataDelegate( IComponentModel model, String key, IHandler
handler );
 
-	public delegate void InterceptionDelegate( IComponentModel model, String key, IHandler handler,
IInterceptedComponent interceptedComponent );
+	public delegate void InterceptionDelegate( IComponentModel model, IHandler handler, IInterceptedComponent
interceptedComponent );
 
-	public delegate void ComponentInstanceDelegate( IComponentModel model, String key, IHandler
handler, object instance );
+	public delegate void ComponentInstanceDelegate( IComponentModel model, IHandler handler,
object instance );
 
     /// <summary>
     /// 
@@ -34,15 +34,20 @@
         /// 
         /// </summary>
         event ComponentDataDelegate ComponentRegistered;
-	
-		/// <summary>
+
+        /// <summary>
+        /// 
+        /// </summary>
+        event InterceptionDelegate ComponentInterception;
+
+        /// <summary>
 		/// 
 		/// </summary>
-		// event InterceptionDelegate ComponentCreated;
+        event ComponentInstanceDelegate ComponentCreated;
 
-		/// <summary>
+        /// <summary>
 		/// 
 		/// </summary>
-		// event ComponentInstanceDelegate ComponentDestroyed;
+		event ComponentInstanceDelegate ComponentDestroyed;
 	}
 }

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernel.sln
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernel.sln	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernel.sln	Tue Aug
31 11:44:51 2004
@@ -1,29 +1,25 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual C# Express 2005
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.Castle.MicroKernel", "Apache.Avalon.Castle.MicroKernel.csproj",
"{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}"
-	ProjectSection(ProjectDependencies) = postProject
-	EndProjectSection
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.Castle.MicroKernel.Test",
"MicroKernelTest\Apache.Avalon.Castle.MicroKernel.Test.csproj", "{50442F0D-987F-4A8D-B38C-DFA855B9249E}"
-	ProjectSection(ProjectDependencies) = postProject
-	EndProjectSection
 EndProject
 Global
-	GlobalSection(SolutionConfiguration) = preSolution
-		Debug = Debug
-		Release = Release
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
 	EndGlobalSection
-	GlobalSection(ProjectConfiguration) = postSolution
-		{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Debug.ActiveCfg = Debug|.NET
-		{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Debug.Build.0 = Debug|.NET
-		{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Release.ActiveCfg = Release|.NET
-		{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Release.Build.0 = Release|.NET
-		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Debug.ActiveCfg = Debug|.NET
-		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Debug.Build.0 = Debug|.NET
-		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Release.ActiveCfg = Release|.NET
-		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Release.Build.0 = Release|.NET
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Release|Any CPU.Build.0 = Release|Any CPU
+		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
-	GlobalSection(ExtensibilityGlobals) = postSolution
-	EndGlobalSection
-	GlobalSection(ExtensibilityAddIns) = postSolution
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
 	EndGlobalSection
 EndGlobal

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message