Esempio n. 1
0
        private static bool TryAddMethodAttributeContext
            (Type serviceType, Type attributeType, ServiceTypeContext result, bool isContext)
        {
            foreach (var method in serviceType.GetMethods())
            {
                foreach (var attribute in method.GetCustomAttributes())
                {
                    if (attribute.GetType() == attributeType)
                    {
                        isContext = true;
                    }
                    result.AddContext(new MethodAttributeContext(method, attribute));
                }
            }

            return(isContext);
        }
Esempio n. 2
0
        private static ServiceTypeContext ServiceTypeContextFifter(Type serviceType, Type implementationType, Type attributeType)
        {
            ServiceTypeContext result    = ServiceTypeContextListCache.FirstOrDefault(i => i.Type == serviceType);
            Boolean            isContext = true;

            if (result == null)
            {
                isContext = false;
                result    = new ServiceTypeContext(serviceType);
                isContext = TryAddMethodAttributeContext(serviceType, attributeType, result, isContext);
                if (implementationType != null)
                {
                    isContext = TryAddMethodAttributeContext
                                    (implementationType, attributeType, result, isContext);
                }
                if (isContext)
                {
                    ServiceTypeContextListCache.Add(result);
                }
            }
            return(result);
        }