Esempio n. 1
0
        private IEnumerable <Aspect> Find(
            string name,
            Type returnType,
            MemberTypes kind,
            int argCount,
            IEnumerable <string> argumentNames,
            Aspect.InterceptMode mode)
        {
            if (!_mappings.ContainsKey(name))
            {
                return(null);
            }

            var lt = _mappings[name];
            var mp = lt.Keys
                     .FirstOrDefault(
                p => p.ReturnType == returnType &&
                p.MemberType == kind &&
                p.ArgumentCount == argCount &&
                p.GetArgumentNamesHashCode() == MemberProjection.HashArgumentNames(argumentNames));

            if (mp == null)
            {
                return(Enumerable.Empty <Aspect>());
            }

            var aspects = (from a in lt[mp].SelectMany(ap => ap.ProvideAspects(mode))
                           orderby _aspectCategoryOrdering[a.Category.EnumName()]
                           select a).Distinct();

            return(aspects);
        }
Esempio n. 2
0
 private IEnumerable <Aspect> Find(InvokeMemberBinder binder, Aspect.InterceptMode mode)
 {
     return(Find(
                binder.Name,
                binder.ReturnType,
                MemberTypes.Method,
                binder.CallInfo.ArgumentCount,
                binder.CallInfo.ArgumentNames,
                mode));
 }
Esempio n. 3
0
        public override IEnumerable <Aspect> ProvideAspects(Aspect.InterceptMode mode)
        {
            IEnumerable <Aspect> retval = Enumerable.Empty <Aspect>();

            if (mode.HasFlag(Aspect.InterceptMode.Before))
            {
                retval = retval.Concat(_beforeCache);
            }

            if (mode.HasFlag(Aspect.InterceptMode.Instead))
            {
                retval = retval.Concat(_insteadOfCache);
            }

            if (mode.HasFlag(Aspect.InterceptMode.After))
            {
                retval = retval.Concat(_afterCache);
            }

            return(retval);
        }
Esempio n. 4
0
 private IEnumerable <Aspect> Find(SetMemberBinder binder, Aspect.InterceptMode mode)
 {
     return(Find(binder.Name, binder.ReturnType, MemberTypes.Property, mode));
 }
Esempio n. 5
0
 public abstract IEnumerable <Aspect> ProvideAspects(Aspect.InterceptMode mode);