protected override string GetLocalizedString(string value)
        {
            string category = this.category;

            if (!this.loaded)
            {
                try
                {
                    ResourceManager resourceManager = SharedUtil.GetResourceManager(this.type.Assembly);
                    string[]        resourceNames   = this.GetResourceNames();
                    for (int i = 0; i < resourceNames.Length; i++)
                    {
                        if (!SharedUtil.IsEmpty(category = SharedUtil.Trim(SharedUtil.GetString(resourceManager, resourceNames[i], new object[0]))))
                        {
                            break;
                        }
                    }
                    if ((SharedUtil.IsEmpty(category) && (this.type.BaseType != null)) && (this.type.BaseType != typeof(object)))
                    {
                        category = new LocalCategoryAttribute(this.type.BaseType, this.category).Category;
                    }
                }
                catch
                {
                }
                finally
                {
                    if (SharedUtil.IsEmpty(category))
                    {
                        category = this.category;
                    }
                    else
                    {
                        this.category = category;
                    }
                    this.loaded = true;
                }
            }
            return(category);
        }
Ejemplo n.º 2
0
        internal static string GetValue(PropertyDescriptor propertyDescriptor, string name, string defaultValue)
        {
            ResourceManager manager;
            string          str = defaultValue;

            if (propertyDescriptor.Attributes != null)
            {
                foreach (Attribute attribute in propertyDescriptor.Attributes)
                {
                    ParameterAttribute attribute2;
                    if (((attribute2 = attribute as ParameterAttribute) != null) && (attribute2.Name == name))
                    {
                        str = attribute2.Value;
                        break;
                    }
                }
            }
            if (((str != null) && str.StartsWith("res::")) && ((manager = SharedUtil.GetResourceManager(propertyDescriptor.ComponentType.Assembly)) != null))
            {
                str = manager.GetString(str.Substring("res::".Length));
            }
            return(str);
        }