public IPropertyInfo GetMethodHandle(INotifyPropertyChangedSource obj, String propertyName) { IPropertyInfo property = PropertyInfoProvider.GetProperty(obj, propertyName); if (property != null) { return(property); } throw new Exception("Property not found: " + obj.GetType().FullName + "." + propertyName); }
public override IClassVisitor Extend(IClassVisitor visitor, IBytecodeBehaviorState state, IList <IBytecodeBehavior> remainingPendingBehaviors, IList <IBytecodeBehavior> cascadePendingBehaviors) { Type entityType = EntityUtil.GetEntityType(state.Context); if (entityType == null) { return(visitor); } IEntityMetaData metaData = EntityMetaDataProvider.GetMetaData(entityType, true); if (metaData == null) { return(visitor); } visitor = new FlattenDebugHierarchyVisitor(visitor, metaData.RelationMembers.Length != 0); bool addValueHolderContainer; if (EmbeddedEnhancementHint.HasMemberPath(state.Context)) { foreach (RelationMember member in metaData.RelationMembers) { if (!(member is IEmbeddedMember)) { continue; } Member cMember = ((IEmbeddedMember)member).ChildMember; MethodPropertyInfo prop = (MethodPropertyInfo)PropertyInfoProvider.GetProperty(cMember.DeclaringType, cMember.Name); if ((prop.Getter != null && state.HasMethod(new MethodInstance(prop.Getter))) || (prop.Setter != null && state.HasMethod(new MethodInstance(prop.Setter)))) { // Handle this behavior in the next iteration cascadePendingBehaviors.Add(this); return(visitor); } } addValueHolderContainer = false; } else { foreach (RelationMember member in metaData.RelationMembers) { if (member is IEmbeddedMember) { continue; } MethodPropertyInfo prop = (MethodPropertyInfo)PropertyInfoProvider.GetProperty(member.DeclaringType, member.Name); if ((prop.Getter != null && state.HasMethod(new MethodInstance(prop.Getter))) || (prop.Setter != null && state.HasMethod(new MethodInstance(prop.Setter)))) { // Handle this behavior in the next iteration cascadePendingBehaviors.Add(this); return(visitor); } } // Add this interface only for real entities, not for embedded types addValueHolderContainer = true; visitor = new EntityMetaDataHolderVisitor(visitor, metaData); } visitor = new SetCacheModificationMethodCreator(visitor); cascadePendingBehaviors.Add(WaitForApplyBehavior.Create(BeanContext, delegate(IClassVisitor visitor2, IBytecodeBehaviorState state2, IList <IBytecodeBehavior> remainingPendingBehaviors2, IList <IBytecodeBehavior> cascadePendingBehaviors2) { if (addValueHolderContainer) { visitor2 = new InterfaceAdder(visitor2, typeof(IValueHolderContainer)); } visitor2 = new RelationsGetterVisitor(visitor2, metaData, ValueHolderContainerHelper, PropertyInfoProvider); return(visitor2); })); return(visitor); }