Hi there, 
        
The issue IOC-ISSUE-144 was just created by Jo?o Bragan?a (captainramen).
        
        Key: IOC-ISSUE-144
        Summary: Cannot Register Abstract Components With Interceptor as of 
r5530
        Type: Bug
        Importance: Low
        
        Description:
        I think DefaultComponentActivator should make an exception for abstract 
components that have interceptors set on them. Example:
public abstract class Scale
{
        public virtual bool IsOn { get; set; }
        public virtual double Weight { get; set; }
}
public class DataBindingInterceptor
        : IInterceptor
{
        protected PropertyChangedEventHandler propertyChanged = delegate { };
        #region IInterceptor Members
        public void Intercept(IInvocation invocation)
        {
                if (invocation.Method.DeclaringType ==
                    typeof(INotifyPropertyChanged))
                {
                        var handler = 
(PropertyChangedEventHandler)invocation.Arguments[0];
                        if (invocation.Method.Name.StartsWith("add_"))
                        {
                                propertyChanged += handler;
                        }
                        else
                        {
                                propertyChanged -= handler;
                        }
                        invocation.ReturnValue = null;
                        return;
                }
                Invoke(invocation);
                RaiseIfRequired(invocation, invocation.Proxy);
        }
        #endregion
        private void RaiseIfRequired(IInvocation invocation, object target)
        {
                if (invocation.Method.Name.StartsWith("set_"))
                {
                        propertyChanged(target, new 
PropertyChangedEventArgs(invocation.Method.Name.Substring(4)));
                }
        }
        protected virtual void Invoke(IInvocation invocation)
        {
                invocation.Proceed();
        }
}
static void Main()
{
        
Kernel.Register(Component.For<DataBindingInterceptor>().Named("dataBindingInterceptor").LifeStyle.Transient);
        Kernel.Register(Component.For<Scale>()
                                .Interceptors(new 
InterceptorReference("dataBindingInterceptor")).Anywhere
                                .Proxy.AdditionalInterfaces(typeof 
(INotifyPropertyChanged)));
        
}
        
For more, see 
http://support.castleproject.org/projects/IOC/issues/view/IOC-ISSUE-144
 
        
--
donjon
by Castle Stronghold
http://www.castle-donjon.com



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to