using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Web;

namespace MvcResourceLang.Models {
	public class LocalDisplayName : DisplayNameAttribute {
		private string _defaultName = "";
		public Type ResourceType {
			get { return (Thread.CurrentThread.CurrentUICulture.Name == "en-US") ? typeof(Resources.en_US) : typeof(Resources.zh_CN); }
		}
		public string ResourceName {
			get;
			set;
		}
		public LocalDisplayName(string defaultName) {
			_defaultName = defaultName;
		}
		public override string DisplayName {
			get {
				PropertyInfo p = ResourceType.GetProperty(ResourceName);
				if (p != null)
					return p.GetValue(null, null).ToString();
				else
					return _defaultName;
			}
		}
	}
}