Example #1
0
        public Func <IAspectDefinition, IAspectExpressionBuilder> Visit(GetPropertyInterceptionAspect aspect)
        {
            return(aspectDefinition => {
                Func <IAspectExpression, IAspectExpression> ctor = null;
                var propertyAspectDefinition = aspectDefinition as IPropertyAspectDefinition;

                if (lastAspect.Top)
                {
                    ctor = expression => {
                        return new TopGetPropertyInterceptionAspectExpression(expression, propertyAspectDefinition);
                    };

                    lastAspect = new Aspect();
                }
                else
                {
                    if (lastAspect.IsInBinding)
                    {
                        ctor = expression => {
                            return new BindingGetPropertyInterceptionAspectExpression(expression, propertyAspectDefinition);
                        };
                    }
                }

                lastAspect.IsInBinding = true;
                topAspectInScopeDefinition = aspectDefinition;

                return new AspectNodeExpressionBuilder(ctor);
            });
        }
        private void CollectPartialPropertyAspectDefinitionsByPropertyInterceptionAttribute(IEnumerable <IAspectPropertyMap> properties)
        {
            properties.ForEach(propertyMap => {
                MethodInfo method = null;
                var canWrite      = propertyMap.ContractMember.CanWrite;
                var propertyInterceptionAspects = new List <IAspectDefinition>();

                if (propertyMap.Target.IsNotNull())
                {
                    propertyMap.Members.ForEach(targetMember => {
                        IEnumerable <IAspectDefinition> aspectDefinitions = null;
                        var aspectsAttrs = targetMember.GetCustomAttributes <PropertyInterceptionAspectAttribute>().ToArray();

                        if (aspectsAttrs.IsNotNullOrEmpty())
                        {
                            if (canWrite)
                            {
                                method            = propertyMap.Target.GetSetMethod();
                                aspectDefinitions = aspectsAttrs.Select(aspectAttr => {
                                    var aspect = new SetPropertyInterceptionAspect {
                                        AspectType       = aspectAttr.AspectType,
                                        AspectPriority   = aspectAttr.AspectPriority,
                                        LifetimeStrategy = aspectAttr.LifetimeStrategy
                                    };

                                    return(new SetPropertyInterceptionAspectDefinition(aspect, propertyMap.ContractType, propertyMap.ContractMember, targetMember));
                                });
                            }
                            else
                            {
                                method            = propertyMap.Target.GetGetMethod();
                                aspectDefinitions = aspectsAttrs.Select(aspectAttr => {
                                    var aspect = new GetPropertyInterceptionAspect {
                                        AspectType       = aspectAttr.AspectType,
                                        AspectPriority   = aspectAttr.AspectPriority,
                                        LifetimeStrategy = aspectAttr.LifetimeStrategy
                                    };

                                    return(new GetPropertyInterceptionAspectDefinition(aspect, propertyMap.ContractType, propertyMap.ContractMember, targetMember));
                                });
                            }

                            propertyInterceptionAspects.AddRange(aspectDefinitions);
                        }
                    });

                    AddOrUpdate(propertyMap.Target, propertyMap.ContractMember, method, propertyInterceptionAspects);
                }
            });
        }
 public GetPropertyInterceptionAspectDefinition(GetPropertyInterceptionAspect aspect, Type aspectDeclaringType, PropertyInfo property, MemberInfo target)
     : base(aspect, aspectDeclaringType, property, target)
 {
     this.aspect = aspect;
 }
Example #4
0
        public Func<IAspectDefinition, IAspectExpressionBuilder> Visit(GetPropertyInterceptionAspect aspect)
        {
            return aspectDefinition => {
                Func<IAspectExpression, IAspectExpression> ctor = null;
                var propertyAspectDefinition = aspectDefinition as IPropertyAspectDefinition;

                if (lastAspect.Top) {
                    ctor = expression => {
                        return new TopGetPropertyInterceptionAspectExpression(expression, propertyAspectDefinition);
                    };

                    lastAspect = new Aspect();
                }
                else {
                    if (lastAspect.IsInBinding) {
                        ctor = expression => {
                            return new BindingGetPropertyInterceptionAspectExpression(expression, propertyAspectDefinition);
                        };
                    }
                }

                lastAspect.IsInBinding = true;
                topAspectInScopeDefinition = aspectDefinition;

                return new AspectNodeExpressionBuilder(ctor);
            };
        }
Example #5
0
 public GetPropertyInterceptionAspectDefinition(GetPropertyInterceptionAspect aspect, Type aspectDeclaringType, PropertyInfo property, MemberInfo target)
     : base(aspect, aspectDeclaringType, property, target)
 {
     this.aspect = aspect;
 }