0

組み込みのローカリゼーション機能を使用しないことにしたため、ローカライズされたモデル属性に問題があります。

 public class LocalizedRequiredAttribute : RequiredAttribute
{
    public LocalizedRequiredAttribute(string displayName)
    {
        DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LocalizedRequiredAttribute), typeof(RequiredAttributeAdapter));

        ErrorMessage = ResourceProvider.Get(string.Format("resValidation{0}Missing", displayName));
    }
}

問題は、ユーザーがグローバル カルチャを変更できることですが、ErrorMessage、DisplayName などはフレームワークによってキャッシュされます。これを修正し、実行時に属性をバインドする方法について何か提案はありますか?

4

1 に答える 1