예제 #1
0
        public BridgeMethod <T> Bridge <TResult>(Expression <Func <T, TResult> > propertyAccessor)
        {
            var bridgeMethod = BridgeMethod <T> .Create(propertyAccessor);

            this.Methods.Add(bridgeMethod);

            return(bridgeMethod);
        }
        public static BridgeMethod <T> Create <TResult>(Expression <Func <T, TResult> > propertyAccessor)
        {
            MemberExpression memberExpression = ExpressionPropertyAnalyzer.UnwrapLambda(propertyAccessor);

            if (!(memberExpression.Expression is ParameterExpression))
            {
                throw new InvalidOperationException("Extended Properties are not allowed.");
            }

            var name = ExpressionPropertyAnalyzer.ExtractPropertyName(propertyAccessor);

            Action <T> changedCallback  = me => me.OnPropertyChanged(name);
            Action <T> changingCallback = me => me.OnPropertyChanging(name);

            var method = new BridgeMethod <T>(changingCallback, changedCallback);

            return(method);
        }