public override void BeforeDefine(ProxyScope proxyScope) { if (ViewModelSupport.IsViewModel(proxyScope.TypeDefinition.Type)) { notifyPropertyChangedFeature.ImplementFeature(proxyScope); var commands = ViewModelSupport.GetCommandInfos(proxyScope.TypeDefinition.Type); delegateCommandBuilder.CreateCommands(proxyScope, commands); } }
public override MethodBuilder CreateMethod(ProxyScope proxyScope, MethodDefinition methodDefinition, MemberInfo member, FieldBuilder memberField, FieldBuilder callerMethodField) { // create clean properties (invocation and callback method not added) if (ViewModelSupport.IsViewModel(proxyScope.TypeDefinition.Type)) { if (methodDefinition.MethodDefinitionType == MethodDefinitionType.Getter) { MethodBuilder methodBuilder = DefineMethodAndParameters(proxyScope, methodDefinition); var il = methodBuilder.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Call, methodDefinition.Method); il.Emit(OpCodes.Ret); return(methodBuilder); } if (methodDefinition.MethodDefinitionType == MethodDefinitionType.Setter) { // Setter raise OnPropertyChanged MethodBuilder methodBuilder = DefineMethodAndParameters(proxyScope, methodDefinition); var il = methodBuilder.GetILGenerator(); notifyPropertyChangedFeature.CheckEquals(proxyScope, il, methodDefinition.Method); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Call, methodDefinition.Method); notifyPropertyChangedFeature.InvokeOnPropertyChanged(proxyScope, il, methodDefinition.Method); string propertyName = (methodDefinition as SetMethodDefinition).PropertyDefinition.Name; delegateCommandBuilder.RaiseCanExecuteChangedFor(proxyScope, il, propertyName); il.Emit(OpCodes.Ret); return(methodBuilder); } } return(base.CreateMethod(proxyScope, methodDefinition, member, memberField, callerMethodField)); }
public override void AfterInvoke(ProxyScope proxyScope, ILGenerator il, CallbackMethodDefinition callbackMethodDefinition) { // never called with clean get and set method builder if (callbackMethodDefinition.MethodDefinition.MethodDefinitionType == MethodDefinitionType.Setter && ViewModelSupport.IsViewModel(proxyScope.TypeDefinition.Type)) { notifyPropertyChangedFeature.InvokeOnPropertyChanged(proxyScope, il, callbackMethodDefinition.Method); string propertyName = (callbackMethodDefinition.MethodDefinition as SetMethodDefinition).PropertyDefinition.Name; delegateCommandBuilder.RaiseCanExecuteChangedFor(proxyScope, il, propertyName); } }
public override void BeforeInvoke(ProxyScope proxyScope, ILGenerator il, CallbackMethodDefinition callbackMethodDefinition) { // never called with clean get and set method builder if (callbackMethodDefinition.MethodDefinition.MethodDefinitionType == MethodDefinitionType.Setter && ViewModelSupport.IsViewModel(proxyScope.TypeDefinition.Type)) { notifyPropertyChangedFeature.CheckEquals(proxyScope, il, callbackMethodDefinition.Method); } }