コード例 #1
0
        /// <summary>
        /// Enumerates the properties of an object (of a type it supports).
        /// </summary>
        /// <param name="Object">Object</param>
        /// <returns>Property enumeration as a script element.</returns>
        public IElement EnumerateProperties(object Object)
        {
            List <IElement> Elements = new List <IElement>();
            Type            T        = Object.GetType();

            foreach (PropertyInfo PI in T.GetRuntimeProperties())
            {
                if (PI.GetIndexParameters().Length > 0)
                {
                    continue;
                }

                Elements.Add(new StringValue(PI.Name));
                Elements.Add(Expression.Encapsulate(PI.GetValue(Object)));
            }

            ObjectMatrix M = new ObjectMatrix(Elements.Count / 2, 2, Elements)
            {
                ColumnNames = new string[] { "Name", "Value" }
            };

            return(M);
        }