StronglyTypedResourceBuilder::VerifyResourceName Method
Generates a valid resource string based on the specified input string and code provider.
Assembly: System.Design (in System.Design.dll)
Parameters
- key
- Type: System::String
The string to verify and, if necessary, convert to a valid resource name.
- provider
- Type: System.CodeDom.Compiler::CodeDomProvider
A CodeDomProvider object that specifies the target language to use.
Return Value
Type: System::StringA valid resource name derived from the key parameter. Any invalid tokens are replaced with the underscore (_) character, or nullptr if the derived string still contains invalid characters according to the language specified by the provider parameter.
| Exception | Condition |
|---|---|
| ArgumentNullException | key or provider is nullptr. |
If the key parameter is a valid string of characters, that string is returned. If the key parameter is an invalid string or a string that contains invalid characters, the VerifyResourceName method attempts to generate a valid string based on the key and provider parameters. If a valid string can be generated, that string is returned; otherwise, nullptr is returned.
If the key parameter is an empty string (""), a string that consists of a single underscore character (_) is returned. If the key parameter is not an empty string, the VerifyResourceName method compares each character in the string to a set of invalid tokens based on the language specified by the provider parameter. Any invalid character in the string is replaced with an underscore character. The characters that will be replaced with an underscore are as follows:
' ' (space), U+00A0 (non-breaking space), '.' (period), ',' (comma), ';' (semicolon), '|', '~', '@', '#', '%', '^', '&', '*', '+', '-', '/', '\', '<', '>', '?', '[', ']', '(', ')', '{', '}', '"' (quote), ''' (apostrophe), ':', and '!'.
Note |
|---|
Strongly-typed resources do not allow the use of language keywords (such as if, for, and so on) as resource key names. However, the System.CodeDom design pattern allows the use of language keywords by prefixing the keyword with the underscore character. The VerifyResourceName method calls the CreateValidIdentifier method to enforce this design. For example, if you use a resource name that is the same as a language keyword, such as for, the name appears as _for in the generated strongly-typed resource class. |
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note