C# Class Framework.Mvc.Helpers.ResourceHelper

Provides methods for resources retrieving.
显示文件 Open project: coreframework/Core-Framework

Public Properties

Property Type Description
Areas String
MainAreas String[]
ScopeSeparator String
SlashSeparator char
ViewScopeKey String

Public Methods

Method Description
Combine ( ) : String

Generates resource key from chains.

Combine ( IEnumerable chains ) : String

Generates resource key from chains.

GetCommonMessagesScope ( ) : String

Gets the common error messages localization scope.

GetControllerScope ( Controller controller ) : String

Builds controller localization scope by it's namespace and type ([AreaName.]Controllers.{ControllerName}).

GetControllerScope ( String areaName, String controllerName ) : String

Gets the controller scope.

GetModelScope ( Type modelType ) : String

Builds model localization scope by it's namespace and type ([AreaName.]Models.{Namespace}.{TypeName}).

GetModelSpecificMessagesScope ( Type modelType, String propertyName ) : String

Gets the model specific error messages localization scope.

GetPartialViewScope ( System.Web.Mvc.ViewContext viewContext, String partialViewName ) : String

Builds partial view localization scope by view path (removes leading Areas directory).

GetResourceString ( System.Web.HttpContextBase context, String key, String scope, CultureInfo culture, Func translationMissing ) : String

Gets resource String using specified scope, key and culture.

translationMissing handler will be called if resource can not be found.

GetViewScope ( String viewPath ) : String

Builds view localization scope by view path (removes leading Areas directory).

GetViewScope ( System.Web.Mvc.ViewContext viewContext ) : String

Builds view localization scope by view path (removes leading Areas directory).

TranslateErrorMessage ( System.Web.HttpContextBase context, Type modelType, String propertyName, String validatorKey ) : String

Translates validation error message.

TranslateErrorMessage ( System.Web.HttpContextBase context, Type modelType, String propertyName, String validatorKey, String validationParams ) : String

Translates the error message and replace params.

TranslatePropertyName ( System.Web.HttpContextBase context, Type modelType, String propertyName ) : String

Translates property name using model scope.

Private Methods

Method Description
GetPartialViewPath ( System.Web.Mvc.ViewContext viewContext, String partialViewName ) : String

Method Details

Combine() public static method

Generates resource key from chains.
public static Combine ( ) : String
return String

Combine() public static method

Generates resource key from chains.
public static Combine ( IEnumerable chains ) : String
chains IEnumerable The chains.
return String

GetCommonMessagesScope() public static method

Gets the common error messages localization scope.
public static GetCommonMessagesScope ( ) : String
return String

GetControllerScope() public static method

Builds controller localization scope by it's namespace and type ([AreaName.]Controllers.{ControllerName}).
public static GetControllerScope ( Controller controller ) : String
controller Controller The controller.
return String

GetControllerScope() public static method

Gets the controller scope.
public static GetControllerScope ( String areaName, String controllerName ) : String
areaName String Name of the area.
controllerName String Name of the controller.
return String

GetModelScope() public static method

Builds model localization scope by it's namespace and type ([AreaName.]Models.{Namespace}.{TypeName}).
public static GetModelScope ( Type modelType ) : String
modelType System.Type Type of the model.
return String

GetModelSpecificMessagesScope() public static method

Gets the model specific error messages localization scope.
public static GetModelSpecificMessagesScope ( Type modelType, String propertyName ) : String
modelType System.Type Type of the model.
propertyName String Name of the property.
return String

GetPartialViewScope() public static method

Builds partial view localization scope by view path (removes leading Areas directory).
public static GetPartialViewScope ( System.Web.Mvc.ViewContext viewContext, String partialViewName ) : String
viewContext System.Web.Mvc.ViewContext The view context.
partialViewName String Name of partial view.
return String

GetResourceString() public static method

Gets resource String using specified scope, key and culture.
translationMissing handler will be called if resource can not be found.
public static GetResourceString ( System.Web.HttpContextBase context, String key, String scope, CultureInfo culture, Func translationMissing ) : String
context System.Web.HttpContextBase The http context.
key String The resource key.
scope String The localization scope.
culture System.Globalization.CultureInfo The culture.
translationMissing Func Translation missing fallback.
return String

GetViewScope() public static method

Builds view localization scope by view path (removes leading Areas directory).
public static GetViewScope ( String viewPath ) : String
viewPath String The view path.
return String

GetViewScope() public static method

Builds view localization scope by view path (removes leading Areas directory).
public static GetViewScope ( System.Web.Mvc.ViewContext viewContext ) : String
viewContext System.Web.Mvc.ViewContext The view context.
return String

TranslateErrorMessage() public static method

Translates validation error message.
public static TranslateErrorMessage ( System.Web.HttpContextBase context, Type modelType, String propertyName, String validatorKey ) : String
context System.Web.HttpContextBase The http context.
modelType System.Type Type of the model.
propertyName String Name of the property.
validatorKey String The validator key.
return String

TranslateErrorMessage() public static method

Translates the error message and replace params.
public static TranslateErrorMessage ( System.Web.HttpContextBase context, Type modelType, String propertyName, String validatorKey, String validationParams ) : String
context System.Web.HttpContextBase The context.
modelType System.Type Type of the model.
propertyName String Name of the property.
validatorKey String The validator key.
validationParams String The validation params.
return String

TranslatePropertyName() public static method

Translates property name using model scope.
public static TranslatePropertyName ( System.Web.HttpContextBase context, Type modelType, String propertyName ) : String
context System.Web.HttpContextBase The http context.
modelType System.Type Type of the model.
propertyName String Name of the proprty.
return String

Property Details

Areas public_oe static_oe property

Areas constant.
public static String Areas
return String

MainAreas public_oe static_oe property

Areas built in framework.
public static String[] MainAreas
return String[]

ScopeSeparator public_oe static_oe property

Resources scope separator.
public static String ScopeSeparator
return String

SlashSeparator public_oe static_oe property

Slash separator.
public static char SlashSeparator
return char

ViewScopeKey public_oe static_oe property

View scope key.
public static String ViewScopeKey
return String