private object HandleGetProperty(MethodInvocation call)
        {
            IProxy proxy        = (IProxy)call.Target;
            string propertyName = call.Method.Name.Substring(4);
            //object value = call.Proceed();

            object value  = null;
            bool   cancel = false;

            Puzzle.NPersist.Framework.Interfaces.IInterceptor interceptor = proxy.GetInterceptor();
            if (interceptor != null)
            {
                interceptor.NotifyPropertyGet(call.Target, propertyName, ref value, ref cancel);
            }
            if (cancel)
            {
                return(value);
            }
            //if (cancel) {return GetDefaultValue(call.ReturnType);}

            value = call.Proceed();

            if (interceptor != null)
            {
                interceptor.NotifyReadProperty(proxy, propertyName, ref value);
            }
            return(value);
        }
        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);
        }
        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);
        }