コード例 #1
0
        /// <summary>
        /// Returns the value of a "proxied" cell (identified by <paramref name="qualifiedProperty"/>)
        /// in a <paramref name="row"/>.
        /// </summary>
        /// <param name="row">The row holding the value.</param>
        /// <param name="qualifiedProperty">The qualified property which identifies the cell within the row.</param>
        /// <returns></returns>
        public static object GetValue(FlexRow row, string qualifiedProperty)
        {
            var    propertyList   = qualifiedProperty.Split('.').ToList();
            object currentElement = row;

            // if the class name (= first element) matches the current element,
            // skip this
            if (currentElement.GetType().Name == propertyList[0])
            {
                propertyList.RemoveAt(0);
            }

            // now scan all property names of the qualified property
            foreach (var propertyName in propertyList)
            {
                try
                {
                    var propInfo = currentElement.GetType().GetProperties().First(pi => pi.Name == propertyName);
                    currentElement = propInfo.GetValue(currentElement, null);
                }
                catch
                {
                    currentElement = "#error: unknown virtual field name#";
                }
            }

            return(currentElement == row ? null : currentElement);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProxyProperty"/> class.
 /// </summary>
 /// <param name="row">The row.</param>
 /// <param name="qualifiedProperty">The qualified property.</param>
 /// <param name="displayName">The display name.</param>
 public ProxyProperty(FlexRow row, string qualifiedProperty, string displayName)
 {
     this.row = row;
     this.qualifiedProperty = qualifiedProperty;
     this.displayName       = displayName;
 }