Beispiel #1
0
            public override IClassVisitor Extend(IClassVisitor visitor, IBytecodeBehaviorState state, IList <IBytecodeBehavior> remainingPendingBehaviors,
                                                 IList <IBytecodeBehavior> cascadePendingBehaviors)
            {
                ListUtil.AddAll(cascadePendingBehaviors, 0, remainingPendingBehaviors);
                remainingPendingBehaviors.Clear();

                // Add this interface only for real entities, not for embedded types
                if (implementValueHolderContainerInterface)
                {
                    visitor = new InterfaceAdder(visitor, typeof(IValueHolderContainer));
                }
                visitor = new RelationsGetterVisitor(visitor, metaData, ValueHolderContainerHelper, PropertyInfoProvider);
                visitor = new SetCacheModificationMethodCreator(visitor);
                return(visitor);
            }
Beispiel #2
0
            public override IClassVisitor Extend(IClassVisitor visitor, IBytecodeBehaviorState state, IList <IBytecodeBehavior> remainingPendingBehaviors,
                                                 IList <IBytecodeBehavior> cascadePendingBehaviors)
            {
                visitor = new InterfaceAdder(visitor, typeof(IDataObject), typeof(INotifyCollectionChangedListener));
                visitor = new DataObjectVisitor(visitor, metaData, PropertyInfoProvider);
                visitor = new SetCacheModificationMethodCreator(visitor);

                // ToBeUpdated & ToBeDeleted have to fire PropertyChange-Events by themselves
                String[] properties = { DataObjectVisitor.template_p_toBeUpdated.Name, DataObjectVisitor.template_p_toBeDeleted.Name };

                CascadeBehavior2 cascadeBehavior2 = BeanContext.RegisterWithLifecycle(new CascadeBehavior2(metaData, properties)).Finish();

                cascadePendingBehaviors.Add(cascadeBehavior2);

                return(visitor);
            }
Beispiel #3
0
        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);
        }