Exemple #1
0
        // Helpe method to retrieve localized string based on attribute name
        protected string GetExplicitResourceString(string attributeName, string defaultValue, bool throwIfNotFound)
        {
            if (attributeName == null)
            {
                throw new ArgumentNullException("attributeName");
            }

            string text = null;

            if (_resourceKeys != null)
            {
                string[] keys = _resourceKeys.GetValues(attributeName);
                if (keys != null && keys.Length > 1)
                {
                    try {
                        text = ResourceExpressionBuilder.GetGlobalResourceObject(keys[0], keys[1]) as string;
                    }
                    catch (MissingManifestResourceException) {
                        if (defaultValue != null)
                        {
                            return(defaultValue);
                        }
                    }

                    if (text == null && throwIfNotFound)
                    {
                        // throw if default value is not specified.
                        throw new InvalidOperationException(
                                  SR.GetString(SR.Res_not_found_with_class_and_key, keys[0], keys[1]));;
                    }
                }
            }

            return(text);
        }
        protected string GetExplicitResourceString(string attributeName, string defaultValue, bool throwIfNotFound)
        {
            if (attributeName == null)
            {
                throw new ArgumentNullException("attributeName");
            }
            string globalResourceObject = null;

            if (this._resourceKeys != null)
            {
                string[] values = this._resourceKeys.GetValues(attributeName);
                if ((values == null) || (values.Length <= 1))
                {
                    return(globalResourceObject);
                }
                try
                {
                    globalResourceObject = ResourceExpressionBuilder.GetGlobalResourceObject(values[0], values[1]) as string;
                }
                catch (MissingManifestResourceException)
                {
                    if (defaultValue != null)
                    {
                        return(defaultValue);
                    }
                }
                if ((globalResourceObject == null) && throwIfNotFound)
                {
                    throw new InvalidOperationException(System.Web.SR.GetString("Res_not_found_with_class_and_key", new object[] { values[0], values[1] }));
                }
            }
            return(globalResourceObject);
        }
Exemple #3
0
        // Helper method to retrieve localized string based on attribute name
        protected string GetImplicitResourceString(string attributeName)
        {
            if (attributeName == null)
            {
                throw new ArgumentNullException("attributeName");
            }

            string text = null;

            if (!String.IsNullOrEmpty(_resourceKey))
            {
                try {
                    text = ResourceExpressionBuilder.GetGlobalResourceObject(Provider.ResourceKey, ResourceKey + "." + attributeName) as String;
                }
                catch { }
            }

            return(text);
        }
Exemple #4
0
 protected object GetGlobalResourceObject(string className, string resourceKey, Type objType, string propName)
 {
     return(ResourceExpressionBuilder.GetGlobalResourceObject(className, resourceKey, objType, propName, null));
 }
Exemple #5
0
 protected object GetGlobalResourceObject(string className, string resourceKey)
 {
     return(ResourceExpressionBuilder.GetGlobalResourceObject(className, resourceKey, null, null, null));
 }