Пример #1
0
        protected internal virtual void Discover(Type type, String propertyName)
        {
            // this is gross and linear, but it keeps it straightforward.
            try
            {
                propertyUsed = propertyName;
                property     = introspector.GetProperty(type, propertyUsed);
                if (property != null)
                {
                    return;
                }

                // now the convenience, flip the 1st character
                propertyUsed = propertyName.Substring(0, 1).ToUpper() + propertyName.Substring(1);
                property     = introspector.GetProperty(type, propertyUsed);
                if (property != null)
                {
                    return;
                }

                propertyUsed = propertyName.Substring(0, 1).ToLower() + propertyName.Substring(1);
                property     = introspector.GetProperty(type, propertyUsed);
                if (property != null)
                {
                    return;
                }

                // check for a method that takes no arguments
                propertyUsed = propertyName;
                method       = introspector.GetMethod(type, propertyUsed, new Object[0]);
                if (method != null)
                {
                    return;
                }

                // check for a method that takes no arguments, flipping 1st character
                propertyUsed = propertyName.Substring(0, 1).ToUpper() + propertyName.Substring(1);
                method       = introspector.GetMethod(type, propertyUsed, new Object[0]);
                if (method != null)
                {
                    return;
                }

                propertyUsed = propertyName.Substring(0, 1).ToLower() + propertyName.Substring(1);
                method       = introspector.GetMethod(type, propertyUsed, new Object[0]);
                if (method != null)
                {
                    return;
                }
            }
            catch (System.Exception e)
            {
                runtimeLogger.Error(string.Format("PROGRAMMER ERROR : PropertyExector() : {0}", e));
            }
        }
Пример #2
0
        /// <param name="clazz">
        /// </param>
        /// <param name="property">
        /// </param>
        protected internal virtual void Discover(System.Type clazz, string property)
        {
            /*
             *  this is gross and linear, but it keeps it straightforward.
             */

            try
            {
                Property = introspector.GetProperty(clazz, property);
            }

            /**
             * pass through application level runtime exceptions
             */
            catch (System.SystemException e)
            {
                throw e;
            }
            catch (System.Exception e)
            {
                string msg = "Exception while looking for property getter for '" + property;
                log.Error(msg, e);
                throw new VelocityException(msg, e);
            }
        }
Пример #3
0
        protected internal override void Discover(System.Type clazz, string property)
        {
            try
            {
                Property = Introspector.GetProperty(clazz, property);

                if (Property != null && Property.Property.PropertyType.Equals(typeof(Boolean)))
                {
                    return;
                }

                Property = null;
            }

            /**
             * pass through application level runtime exceptions
             */
            catch (System.SystemException e)
            {
                throw e;
            }
            catch (System.Exception e)
            {
                string msg = "Exception while looking for boolean property getter for '" + property;
                log.Error(msg, e);
                throw new VelocityException(msg, e);
            }
        }