Exemple #1
0
        private void AddAopHandlerByUsageAttribute(MethodBase methodBase, IList methodHandlers)
        {
            CachingData data;

            if (cachedStaticHandlers == null)
            {
                cachedStaticHandlers = new Dictionary <MethodBase, CachingData>();
            }

            if (!cachedStaticHandlers.TryGetValue(methodBase, out data))
            {
                var cachingAttr = methodBase.GetCustomAttribute <CachingCallAttribute>(true);

                if (cachingAttr != null)
                {
                    int    maxCachingResult   = cachingAttr.MaxCaching;
                    Type   lifetimeType       = null;
                    string lifetimeMethod     = null;
                    var    resultLifetimeAttr = methodBase.GetCustomAttribute <CachingLifetimeAttribute>(false);

                    if (resultLifetimeAttr != null)
                    {
                        lifetimeType   = resultLifetimeAttr.LifetimeType;
                        lifetimeMethod = resultLifetimeAttr.Method;
                    }

                    data = new CachingData(maxCachingResult, lifetimeType, lifetimeMethod);

                    cachedStaticHandlers[methodBase] = data;
                }
            }

            if (data != null)
            {
                methodHandlers.Add(new CachingCallHandler(data));
            }
        }
Exemple #2
0
 public CachingCallHandler(CachingData data)
 {
     this.cachingData = data;
 }