public override void PreDefine(ITypeDesigner t) { if (_fnGet != null) { var mtGet = _info.GetGetMethod(); if (mtGet == null) { throw new Exception("Can't override non-existent get method on property " + _info.Name); } t.OverrideMethod(mtGet).Emit(_fnGet); } if (_fnSet != null) { var mtSet = _info.GetSetMethod(); if (mtSet == null) { throw new Exception("Can't override non-existent set method on property " + _info.Name); } t.OverrideMethod(mtSet).Emit(_fnSet); } }
public static void ObjectChanged(ITypeDesigner typeDesigner) { if (_init) return; foreach (IEDMDesignerChangeWatcherObserver observer in _observers) { if (observer.ObjectChanged(typeDesigner)) break; } }
public override void PreDefine(ITypeDesigner t) { if (_backingField != null) { _fnGet = (il) => { il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldfld, _backingField); il.Emit(OpCodes.Ret); }; _fnSet = (il) => { if (_fnOnChanged != null) { var lbSkipOnChanged = il.DefineLabel(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldfld, _backingField); if (_type.IsValueType) { il.Emit(OpCodes.Box, _type); } il.Emit(OpCodes.Ldarg_1); if (_type.IsValueType) { il.Emit(OpCodes.Box, _type); } il.Emit(OpCodes.Call, typeof(object).GetMethod("Equals", BindingFlags.Public | BindingFlags.Static)); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Stfld, _backingField); il.Emit(OpCodes.Brtrue, lbSkipOnChanged); _fnOnChanged(il); il.MarkLabel(lbSkipOnChanged); il.Emit(OpCodes.Ret); } else { il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Stfld, _backingField); il.Emit(OpCodes.Ret); } }; } }
public static void ObjectChanged(ITypeDesigner typeDesigner) { if (_init) { return; } foreach (IEDMDesignerChangeWatcherObserver observer in _observers) { if (observer.ObjectChanged(typeDesigner)) { break; } } }
public override void PreDefine(ITypeDesigner t) { if (_handlerType == null) { _handlerType = _eventArgsType == typeof(EventArgs) ? typeof(EventHandler) : typeof(EventHandler <>).MakeGenericType(_eventArgsType); } if (_bPrivateField) { _field = t.Field("_" + _name, _handlerType); _fnAdd = (il) => { il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldfld, _field); il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Call, typeof(Delegate).GetMethod("Combine", new[] { typeof(Delegate), typeof(Delegate) }, null)); il.Emit(OpCodes.Castclass, _handlerType); il.Emit(OpCodes.Stfld, _field); il.Emit(OpCodes.Ret); }; _fnRemove = (il) => { il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldfld, _field); il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Call, typeof(Delegate).GetMethod("Remove", new[] { typeof(Delegate), typeof(Delegate) }, null)); il.Emit(OpCodes.Castclass, _handlerType); il.Emit(OpCodes.Stfld, _field); il.Emit(OpCodes.Ret); }; } }
public override void PreDefine(ITypeDesigner t) { //... }
public abstract void PreDefine(ITypeDesigner t);