Пример #1
0
 public BeanProperties(Type baseClass)
 {
     PropertyDescriptor[] descriptors;
     try
     {
         descriptors = Introspector.getBeanInfo(baseClass).PropertyDescriptors;
     }
     catch (IntrospectionException e)
     {
         throw new ELException(e);
     }
     foreach (PropertyDescriptor descriptor in descriptors)
     {
         map[descriptor.Name] = new BeanProperty(descriptor);
     }
 }
Пример #2
0
        /// <summary> init is responsible for checking the class to make sure
        /// it implements addPropertyChangeListener(java.beans.PropertyChangeListener)
        /// and removePropertyChangeListener(java.beans.PropertyChangeListener).
        /// We don't require the classes extend PropertyChangeSupport.
        /// </summary>
        public void init()
        {
            try
            {
                INFO = Introspector.getBeanInfo(OBJECT_CLASS);
                // we have to filter out the class PropertyDescriptor
                PropertyInfo[] pd   = INFO.getPropertyDescriptors();
                List <Object>  list = new List <Object>();
                for (int idx = 0; idx < pd.Length; idx++)
                {
                    if (pd[idx].Name.Equals("class"))
                    {
                        // don't Add
                    }
                    else
                    {
                        // we map the methods using the PropertyDescriptor.getName for
                        // the key and the PropertyDescriptor as the value
                        methods.Put(pd[idx].Name, pd[idx]);
                        list.Add(pd[idx]);
                    }
                }
                PropertyInfo[] newpd = new PropertyInfo[list.Count];

                list.CopyTo(newpd, 0);
                PROPS = (PropertyInfo[])newpd;
                // logic for filtering the PropertyDescriptors
                if (ObjectFilter.lookupFilter(OBJECT_CLASS) != null)
                {
                    // Remove the props that should be invisible
                    BeanFilter bf = ObjectFilter.lookupFilter(OBJECT_CLASS);
                    PROPS = bf.filter(PROPS);
                }
                if (checkBean())
                {
                    ISBEAN = true;
                }
                // we clean up the array and List<Object>
                list.Clear();
                pd = null;
            }
            catch (System.Exception e)
            {
                // we should log this and throw an exception
            }
        }
Пример #3
0
        /// <summary>
        /// If the base object is not null, returns an Iterator containing the set of JavaBeans
        /// properties available on the given object. Otherwise, returns null. The Iterator returned must
        /// contain zero or more instances of java.beans.FeatureDescriptor. Each info object contains
        /// information about a property in the bean, as obtained by calling the
        /// BeanInfo.getPropertyDescriptors method. The FeatureDescriptor is initialized using the same
        /// fields as are present in the PropertyDescriptor, with the additional required named
        /// attributes "type" and "resolvableAtDesignTime" set as follows:
        /// <ul>
        /// <li><seealso cref="ELResolver.TYPE"/> - The runtime type of the property, from
        /// PropertyDescriptor.getPropertyType().</li>
        /// <li><seealso cref="ELResolver.RESOLVABLE_AT_DESIGN_TIME"/> - true.</li>
        /// </ul>
        /// </summary>
        /// <param name="context">
        ///            The context of this evaluation. </param>
        /// <param name="base">
        ///            The bean to analyze. </param>
        /// <returns> An Iterator containing zero or more FeatureDescriptor objects, each representing a
        ///         property on this bean, or null if the base object is null. </returns>
        public override IEnumerator <FeatureDescriptor> getFeatureDescriptors(ELContext context, object @base)
        {
            if (isResolvable(@base))
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.beans.PropertyDescriptor[] properties;
                PropertyDescriptor[] properties;
                try
                {
                    properties = Introspector.getBeanInfo(@base.GetType()).PropertyDescriptors;
                }
                catch (IntrospectionException)
                {
                    return(System.Linq.Enumerable.Empty <FeatureDescriptor> ().GetEnumerator());
                }
                return(new IteratorAnonymousInnerClass(this, properties));
            }
            return(null);
        }