private void CollectPropertyInterceptionAspectDefinition(IAspectPropertyMap propertyMap, PropertyInfo target, Type aspectDeclaringType, PropertyInterceptionAspectAttribute aspectAttribute) { var contract = propertyMap.ContractMember; var propertyGetMethod = target.GetGetMethod(); var propertySetMethod = target.GetSetMethod(); var contractGetMethodHasCode = contract.GetGetMethod().GetHashCode(); var contractSetMethodHasCode = contract.GetSetMethod().GetHashCode(); var aspectDefinition = new PropertyInterceptionAspectsDefinition(aspectAttribute, aspectAttribute.AspectType, contract, target); var bindingTypeReflectorBuilder = new FullPropertyBindingTypeReflectorBuilder(aspectDefinition); var getPropertyAspect = new GetPropertyFragmentInterceptionAspect { AspectType = aspectAttribute.AspectType, AspectPriority = aspectAttribute.AspectPriority, LifetimeStrategy = aspectAttribute.LifetimeStrategy }; var setPropertyAspect = new SetPropertyFragmentInterceptionAspect { AspectType = aspectAttribute.AspectType, AspectPriority = aspectAttribute.AspectPriority, LifetimeStrategy = aspectAttribute.LifetimeStrategy }; AddOrUpdate(contractGetMethodHasCode, propertyMap.Target, contract, propertyGetMethod, new[] { new GetPropertyFragmentInterceptionAspectDefinition(bindingTypeReflectorBuilder, getPropertyAspect, aspectDeclaringType, contract, target) }); AddOrUpdate(contractSetMethodHasCode, propertyMap.Target, contract, propertySetMethod, new[] { new SetPropertyFragmentInterceptionAspectDefinition(bindingTypeReflectorBuilder, setPropertyAspect, aspectDeclaringType, contract, target) }); }
public Func <IAspectDefinition, IAspectExpressionBuilder> Visit(GetPropertyFragmentInterceptionAspect aspect) { return(aspectDefinition => { Func <IAspectExpression, IAspectExpression> ctor = null; var propertyAspectDefinition = (IFullPropertyAspectDefinition)aspectDefinition; if (lastAspect.Top) { ctor = expression => { var propertyBuilder = propertyAspectDefinition.PropertyBuilder; propertyBuilder.SetGetExpression(expression); return new TopGetPropertyFragmentInterceptionAspectExpression(expression, propertyAspectDefinition, propertyBuilder); }; lastAspect = new Aspect(); } else { if (lastAspect.IsInBinding) { ctor = expression => { var propertyBuilder = propertyAspectDefinition.PropertyBuilder; propertyBuilder.SetGetExpression(expression); return new BindingGetPropertyFragmentInterceptionAspectExpression(expression, propertyAspectDefinition, propertyBuilder); }; } } lastAspect.IsInBinding = true; topAspectInScopeDefinition = aspectDefinition; return new AspectNodeExpressionBuilder(ctor); }); }
public Func<IAspectDefinition, IAspectExpressionBuilder> Visit(GetPropertyFragmentInterceptionAspect aspect) { return aspectDefinition => { Func<IAspectExpression, IAspectExpression> ctor = null; var propertyAspectDefinition = (IFullPropertyAspectDefinition)aspectDefinition; if (lastAspect.Top) { ctor = expression => { var propertyBuilder = propertyAspectDefinition.PropertyBuilder; propertyBuilder.SetGetExpression(expression); return new TopGetPropertyFragmentInterceptionAspectExpression(expression, propertyAspectDefinition, propertyBuilder); }; lastAspect = new Aspect(); } else { if (lastAspect.IsInBinding) { ctor = expression => { var propertyBuilder = propertyAspectDefinition.PropertyBuilder; propertyBuilder.SetGetExpression(expression); return new BindingGetPropertyFragmentInterceptionAspectExpression(expression, propertyAspectDefinition, propertyBuilder); }; } } lastAspect.IsInBinding = true; topAspectInScopeDefinition = aspectDefinition; return new AspectNodeExpressionBuilder(ctor); }; }
internal GetPropertyFragmentInterceptionAspectDefinition(IPropertyExpressionBuilder propertyBuilder, GetPropertyFragmentInterceptionAspect aspect, Type aspectDeclaringType, PropertyInfo property, MemberInfo target) : base(propertyBuilder, aspect, aspectDeclaringType, property, target) { Aspect = this.aspect = aspect; }
internal GetPropertyFragmentInterceptionAspectDefinition(IPropertyExpressionBuilder propertyBuilder, GetPropertyFragmentInterceptionAspect aspect, Type aspectDeclaringType, PropertyInfo property, MemberInfo target) : base(propertyBuilder, aspect, aspectDeclaringType, property, target) { Aspect = this.aspect = aspect; }