/// <summary>Builds the display name.</summary>
            /// <returns>Display name.</returns>
            protected virtual string BuildName()
            {
                var name = property.DisplayName;

                foreach (Attribute attribute in property.Attributes)
                {
                    // If we find a SRName attribute, we don't want to continue searching.
                    // We also override an existing Name attribute.
                    if (attribute is SRNameAttribute)
                    {
                        string resName = ((SRNameAttribute)attribute).ResourceName;
                        var    result  = ResourceLocator.GetString(resName, ownerObjectAssembly);
                        if (!string.IsNullOrEmpty(result))
                        {
                            name = result;
                            break;
                        }
                    }

                    if (attribute is NameAttribute)
                    {
                        name = ((NameAttribute)attribute).Name;
                    }
                }

                return(name);
            }
コード例 #2
0
        private string GetHeaderTextFromPropertyInfo(object o, PropertyInfo property)
        {
            var name = property.Name;

            foreach (Attribute attribute in property.GetCustomAttributes(true))
            {
                // If we find a SRName attribute, we don't want to continue searching.
                // We also override an existing Name attribute.
                if (attribute is SRNameAttribute)
                {
                    string resName = ((SRNameAttribute)attribute).ResourceName;
                    string result  = string.Empty;
                    try { result = ResourceLocator.GetString(resName, o.GetType().Assembly); }
                    catch (Exception ex)
                    {
                        var debugEx = ex;
                    }
                    if (!string.IsNullOrEmpty(result))
                    {
                        name = result;
                        break;
                    }
                }

                if (attribute is NameAttribute)
                {
                    name = ((NameAttribute)attribute).Name;
                }
            }

            return(name);
        }
            /// <summary>Builds the category.</summary>
            /// <returns>Category.</returns>
            protected virtual string BuildCategory()
            {
                var category = property.Category;

                foreach (Attribute attribute in property.Attributes)
                {
                    // If we find a SRName attribute, we override an existing Category attribute.
                    if (attribute is SRCategoryAttribute)
                    {
                        string resName = ((SRCategoryAttribute)attribute).ResourceName;
                        category = ResourceLocator.GetString(resName, ownerObjectAssembly);
                        if (!string.IsNullOrEmpty(category))
                        {
                            break;
                        }
                    }
                }

                return(category);
            }
            /// <summary>Builds the description.</summary>
            /// <returns>Description.</returns>
            protected virtual string BuildDescription()
            {
                var description = property.Description;

                foreach (Attribute attribute in property.Attributes)
                {
                    // If we find a SRName attribute, we override an existing Description attribute.
                    if (attribute is SRDescriptionAttribute)
                    {
                        string resName = ((SRDescriptionAttribute)attribute).ResourceName;
                        description = ResourceLocator.GetString(resName, ownerObjectAssembly);
                        if (!string.IsNullOrEmpty(description))
                        {
                            break;
                        }
                    }
                }

                return(description);
            }