The first resource file is used by the entire application (e.g. Project.Core) and does include all sorts of widely used common strings. I actually don't make any difference between errors/exceptions and logging:
CommonResources.resx Access modifier: Public
Error_Context e.g. Error_ArgumentCannotBeNull
Warn_Context e.g. Warn_ApplicationSettingNotFoundUseDefault
Info_Context e.g. Info_UpdateAvailable
Validation_Context e.g. Validation_EmailNotValid
The second resource file is used by the presentation layer and contains all sorts of UI strings. The naming can vary from project to project but generally it looks like the following schema:
Section/Controller_Window/View_Context e.g. Help_FAQ_HeadlineHowToUseResources or Help_FAQ_TextHowToUseResources
Finally every project/assembly does also have an internal resource file for Error/Warn/Info/Validation resources that are too specific to go in the CommonResources.resx file. I have to admit, that I mostly name this resource file InternalResources.cs ;)
InternalResources.resx Access modifier: Internal
Classname_Error_Context e.g. BCrypt_Error_InvalidSaltRevision
发布评论
评论(1)
我通常这样构造我的资源:
第一个资源文件由整个应用程序使用(例如
Project.Core
),并且包含各种广泛使用的常见字符串。实际上,我对错误/异常和日志记录没有任何区别:CommonResources.resx
访问修饰符:公共
Error_Context
例如
Error_ArgumentCannotBeNull
Warn_Context
例如
Warn_ApplicationSettingNotFoundUseDefault
Info_Context
例如
Info_UpdateAvailable
Validation_Context
例如
Validation_EmailNotValid
第二个资源文件由表示层使用,包含各种 UI 字符串。命名可能因项目而异,但通常类似于以下架构:
PresentationResources.resx
访问修饰符:内部
Common_Context
例如
Common_Yes
Section/Controller_Window/View_Context
例如
Help_FAQ_HeadlineHowToUseResources
或Help_FAQ_TextHowToUseResources
最后,每个项目/程序集还有一个用于错误/警告/信息/验证资源的内部资源文件,这些资源太具体而无法放入
CommonResources.resx
文件。我必须承认,我主要将此资源文件命名为InternalResources.cs
;)InternalResources.resx
访问修饰符:内部
Classname_Error_Context
例如
BCrypt_Error_InvalidSaltRevision
Classname_Warn_Context
Classname_Info_Context
Classname_Validation_Context
I generally structure my resources like this:
The first resource file is used by the entire application (e.g.
Project.Core
) and does include all sorts of widely used common strings. I actually don't make any difference between errors/exceptions and logging:CommonResources.resx
Access modifier: Public
Error_Context
e.g.
Error_ArgumentCannotBeNull
Warn_Context
e.g.
Warn_ApplicationSettingNotFoundUseDefault
Info_Context
e.g.
Info_UpdateAvailable
Validation_Context
e.g.
Validation_EmailNotValid
The second resource file is used by the presentation layer and contains all sorts of UI strings. The naming can vary from project to project but generally it looks like the following schema:
PresentationResources.resx
Access modifier: Internal
Common_Context
e.g.
Common_Yes
Section/Controller_Window/View_Context
e.g.
Help_FAQ_HeadlineHowToUseResources
orHelp_FAQ_TextHowToUseResources
Finally every project/assembly does also have an internal resource file for Error/Warn/Info/Validation resources that are too specific to go in the
CommonResources.resx
file. I have to admit, that I mostly name this resource fileInternalResources.cs
;)InternalResources.resx
Access modifier: Internal
Classname_Error_Context
e.g.
BCrypt_Error_InvalidSaltRevision
Classname_Warn_Context
Classname_Info_Context
Classname_Validation_Context