Пример #1
0
 /// <summary>
 ///     <para>Returns a human-readable string that represents the current business object.
 /// </para>
 /// </summary>
 /// <returns>A string representing the current business object.
 /// </returns>
 public override string ToString()
 {
     if (!BaseObject.IsXpoProfiling)
     {
         if (!this.isDefaultPropertyAttributeInit)
         {
             string text = string.Empty;
             XafDefaultPropertyAttribute xafDefaultPropertyAttribute = XafTypesInfo.Instance.FindTypeInfo(base.GetType()).FindAttribute <XafDefaultPropertyAttribute>();
             if (xafDefaultPropertyAttribute != null)
             {
                 text = xafDefaultPropertyAttribute.Name;
             }
             else
             {
                 DefaultPropertyAttribute defaultPropertyAttribute = XafTypesInfo.Instance.FindTypeInfo(base.GetType()).FindAttribute <DefaultPropertyAttribute>();
                 if (defaultPropertyAttribute != null)
                 {
                     text = defaultPropertyAttribute.Name;
                 }
             }
             if (!string.IsNullOrEmpty(text))
             {
                 this.defaultPropertyMemberInfo = base.ClassInfo.FindMember(text);
             }
             this.isDefaultPropertyAttributeInit = true;
         }
         if (this.defaultPropertyMemberInfo != null)
         {
             object value = this.defaultPropertyMemberInfo.GetValue(this);
             if (value != null)
             {
                 return(value.ToString());
             }
         }
     }
     return(base.ToString());
 }
Пример #2
0
        public override string ToString()
        {
            if (!_isDefaultPropertyAttributeInit)
            {
                string defaultPropertyName = string.Empty;
                XafDefaultPropertyAttribute xafDefaultPropertyAttribute = XafTypesInfo.Instance.FindTypeInfo(GetType()).FindAttribute <XafDefaultPropertyAttribute>();
                if (xafDefaultPropertyAttribute != null)
                {
                    defaultPropertyName = xafDefaultPropertyAttribute.Name;
                }
                else
                {
                    DefaultPropertyAttribute defaultPropertyAttribute = XafTypesInfo.Instance.FindTypeInfo(GetType()).FindAttribute <DefaultPropertyAttribute>();
                    if (defaultPropertyAttribute != null)
                    {
                        defaultPropertyName = defaultPropertyAttribute.Name;
                    }
                }
                if (!string.IsNullOrEmpty(defaultPropertyName))
                {
                    _defaultPropertyMemberInfo = GetType().ToTypeInfo().FindMember(defaultPropertyName);
                }
                _isDefaultPropertyAttributeInit = true;
            }
            if (_defaultPropertyMemberInfo != null)
            {
                try {
                    return(_defaultPropertyMemberInfo.GetValue(this)?.ToString());
                }
                catch {
                    // ignored
                }
            }

            return(base.ToString());
        }