private object HandleSetProperty(MethodInvocation call)
        {
            IProxy proxy        = (IProxy)call.Target;
            bool   cancel       = false;
            object value        = ((InterceptedParameter)call.Parameters[0]).Value;
            string propertyName = call.Method.Name.Substring(4);
            object refValue     = value;

#if NET2
            IPropertyChangedHelper propertyChangedObj = (IPropertyChangedHelper)proxy;
            propertyChangedObj.OnPropertyChanging(propertyName);
#endif

            Puzzle.NPersist.Framework.Interfaces.IInterceptor interceptor = proxy.GetInterceptor();
            if (interceptor != null)
            {
                interceptor.NotifyPropertySet(call.Target, propertyName, ref refValue, ref cancel);
            }
            if (cancel)
            {
                return(null);
            }
            ((InterceptedParameter)call.Parameters[0]).Value = refValue;
            call.Proceed();
#if NET2
            propertyChangedObj.OnPropertyChanged(propertyName);
#endif
            return(null);
        }
Пример #2
0
        public object HandleCall(MethodInvocation call)
        {
            IProxy proxy        = (IProxy)call.Target;
            string propertyName = call.Method.Name.Substring(4);

            IPropertyChangedHelper propertyChangedObj = (IPropertyChangedHelper)proxy;

            propertyChangedObj.OnPropertyChanging(propertyName);

            object res = call.Proceed();

            propertyChangedObj.OnPropertyChanged(propertyName);
            return(res);
        }
        private object HandleSetProperty(MethodInvocation call)
        {
            IProxy proxy        = (IProxy)call.Target;
            bool   cancel       = false;
            object value        = ((InterceptedParameter)call.Parameters[0]).Value;
            string propertyName = call.Method.Name.Substring(4);
            object refValue     = value;

#if NET2
            IPropertyChangedHelper propertyChangedObj = (IPropertyChangedHelper)proxy;
            propertyChangedObj.OnPropertyChanging(propertyName);
#endif

            Puzzle.NPersist.Framework.Interfaces.IInterceptor interceptor = proxy.GetInterceptor();
            if (interceptor != null)
            {
                interceptor.NotifyPropertySet(call.Target, propertyName, ref refValue, ref cancel);
            }
            if (cancel)
            {
                return(null);
            }

            IContext context = null;
            if (interceptor != null)
            {
                context = interceptor.Context;
            }
            object oldValue = null;
            if (context != null)
            {
                oldValue = context.ObjectManager.GetPropertyValue(call.ExecutionTarget, propertyName);
            }
            else
            {
                oldValue = call.ExecutionTarget.GetType().GetProperty(propertyName).GetValue(call.ExecutionTarget, null);
            }
            ((InterceptedParameter)call.Parameters[0]).Value = refValue;
            call.Proceed();

#if NET2
            propertyChangedObj.OnPropertyChanged(propertyName);
#endif
            if (interceptor != null)
            {
                interceptor.NotifyWroteProperty(call.Target, propertyName, refValue, oldValue);
            }
            return(null);
        }