Exemplo n.º 1
0
		public override void Intercept(Castle.Core.Interceptor.IInvocation invocation)
		{
			if(invocation.Method.DeclaringType == typeof(INotifyPropertyChanged))
			{
				var propertyChangedEventHandler = (PropertyChangedEventHandler)invocation.GetArgumentValue(0);
				if(invocation.Method.Name.StartsWith("add_"))
				{
					subscribers += propertyChangedEventHandler;
				}
				else
				{
					subscribers -= propertyChangedEventHandler;
				}
				return;
			}
			base.Intercept(invocation);
			var result = invocation.ReturnValue;

			// 속성값이 변경되었을 때 PropertyChanged event를 실행시킨다.
			if(invocation.Method.Name.StartsWith("set_"))
			{
				if(IsDebugEnabled)
					log.Debug("Raise PropertyChanged event. PropertyName=" + invocation.Method.Name);

				subscribers(this, new PropertyChangedEventArgs(invocation.Method.Name.Substring(4)));
			}

			invocation.ReturnValue = result;
		}