Esempio n. 1
0
        internal static DynamicPropertyDescriptorByMethod GetPopulateCache(
            CopyOnWriteList <DynamicPropertyDescriptorByMethod> cache,
            DynamicPropertyGetterByMethodOrPropertyBase dynamicPropertyGetterBase,
            object obj,
            EventBeanTypedEventFactory eventBeanTypedEventFactory)
        {
            var desc = DynamicPropertyCacheCheck(cache, obj);

            if (desc != null)
            {
                return(desc);
            }

            // need to add it
            lock (dynamicPropertyGetterBase) {
                desc = DynamicPropertyCacheCheck(cache, obj);
                if (desc != null)
                {
                    return(desc);
                }

                // Lookup method to use
                var method = dynamicPropertyGetterBase.DetermineMethod(obj.GetType());

                // Cache descriptor and create fast method
                desc = DynamicPropertyCacheAdd(obj.GetType(), method, cache);
                return(desc);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="cache">cache</param>
        /// <param name="getter">getter</param>
        /// <param name="object">object</param>
        /// <param name="eventBeanTypedEventFactory">event server</param>
        /// <returns>exists-flag</returns>
        public static bool CacheAndExists(
            CopyOnWriteList <DynamicPropertyDescriptorByMethod> cache,
            DynamicPropertyGetterByMethodOrPropertyBase getter,
            object @object,
            EventBeanTypedEventFactory eventBeanTypedEventFactory)
        {
            var desc = GetPopulateCache(cache, getter, @object, eventBeanTypedEventFactory);

            if (desc.Method == null)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="cache">cache</param>
        /// <param name="getter">getter</param>
        /// <param name="object">object</param>
        /// <param name="eventBeanTypedEventFactory">event server</param>
        /// <param name="beanEventTypeFactory">bean factory</param>
        /// <returns>property</returns>
        public static object CacheAndCall(
            CopyOnWriteList <DynamicPropertyDescriptorByMethod> cache,
            DynamicPropertyGetterByMethodOrPropertyBase getter,
            object @object,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var desc = GetPopulateCache(cache, getter, @object, eventBeanTypedEventFactory);

            if (desc.Method == null)
            {
                return(null);
            }

            return(getter.Call(desc, @object));
        }