开发者

WPF Validation Message in Xml

I have a WPF application which is displaying field validation messages by implementing the IDataErrorInfo开发者_运维知识库 interface. This is all working well.

What I want to do now is to break out the validation messages into an separate xml file so that validation message key value pairs can be stored outside of the code and can be easily maintained possibly by an end (super)user.

I was thinking of having a method something like:

    private void ValidateRequiredField<T>(ref T field, string fieldName)
    {
        string error = null;
        if (Equals(field, null)
            || (field is string
                && (string.IsNullOrEmpty(field.ToString())
                    || field.ToString().Replace(" ", string.Empty).Length == 0)
               )
            || (field is int
                && int.Parse(field.ToString()) == 0)
            )
        {
            error = GetValueFromConfig(fieldName);
        }
        SetFieldDataError(fieldName, error);
    }

Is the best way to store these key value pairs in an xml file? I seem to remember that there used to be a Microsoft Configuration Application Block but I can't see an equivalent in Enterprise Library 5.0. Is there a better way?


For anyone who may be pondering the same question...after much deliberating, I opted to use the Microsoft Enterprise Library 5.0

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜