コード例 #1
0
        /// <summary>Returns the group name(s) for the given item. </summary>
        /// <param name="item">The item to return group names for.</param>
        /// <param name="level">The level of grouping.</param>
        /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to supply to the converter.</param>
        /// <returns>The group name(s) for the given item.</returns>
        // Token: 0x06001C95 RID: 7317 RVA: 0x0008632C File Offset: 0x0008452C
        public override object GroupNameFromItem(object item, int level, CultureInfo culture)
        {
            object obj;
            object obj2;

            if (string.IsNullOrEmpty(this.PropertyName))
            {
                obj = item;
            }
            else if (SystemXmlHelper.TryGetValueFromXmlNode(item, this.PropertyName, out obj2))
            {
                obj = obj2;
            }
            else
            {
                if (item != null)
                {
                    using (this._propertyPath.SetContext(item))
                    {
                        obj = this._propertyPath.GetValue();
                        goto IL_4F;
                    }
                }
                obj = null;
            }
IL_4F:
            if (this.Converter != null)
            {
                obj = this.Converter.Convert(obj, typeof(object), level, culture);
            }
            return(obj);
        }
コード例 #2
0
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        /// <summary>
        /// Return the group name(s) for the given item
        /// </summary>
        public override object GroupNameFromItem(object item, int level, CultureInfo culture)
        {
            object value;
            object xmlValue;

            // get the property value
            if (String.IsNullOrEmpty(PropertyName))
            {
                value = item;
            }
            else if (SystemXmlHelper.TryGetValueFromXmlNode(item, PropertyName, out xmlValue))
            {
                value = xmlValue;
            }
            else if (item != null)
            {
                using (_propertyPath.SetContext(item))
                {
                    value = _propertyPath.GetValue();
                }
            }
            else
            {
                value = null;
            }

            // apply the converter to the value
            if (Converter != null)
            {
                value = Converter.Convert(value, typeof(object), level, culture);
            }

            return(value);
        }