Ejemplo n.º 1
0
        public void AddError(string className, string Key, Enum Value)
        {
            if (string.IsNullOrEmpty(_BaseLanguage))
            {
                _BaseLanguage = "VN";
            }
            if (Errors == null)
            {
                Errors = new Dictionary <string, string>();
            }

            string file    = string.Format("{0}.{1}", _BaseLanguage, className);
            string path    = string.Format("{0}.{1}.{2}", ErrorPath, Key, Value.ToString());
            JToken token   = ErrorResource.GetValueOrDefault(file)?.SelectToken(path);
            string content = token == null?Value.ToString() : token.ToString();

            if (Errors.ContainsKey(Key))
            {
                if (!Errors[Key].Contains(content))
                {
                    Errors[Key] += content;
                }
            }
            else
            {
                Errors.Add(Key, content);
            }
        }
Ejemplo n.º 2
0
        public string GetErrorMessage(string path, string Value)
        {
            if (string.IsNullOrEmpty(_BaseLanguage))
            {
                _BaseLanguage = "VN";
            }

            JToken token = ErrorResource.GetValueOrDefault(_BaseLanguage).SelectToken(path + "." + Value);

            return(token?.Value <string>());
        }