using System; using System.Reflection; using Core.Common.Utils.Properties; namespace Core.Common.Utils { /// /// Helper method for interacting with . /// public static class ResourceHelper { /// /// Retrieve the string resource with the given name. /// /// Type of the resource file. /// Name of the resource property to be retrieved. /// String resource in the resources file. public static string GetResourceLookup(Type resourceType, string resourceName) { if ((resourceType != null) && (resourceName != null)) { var property = resourceType.GetProperty(resourceName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); if (property == null) { throw new InvalidOperationException("Resource Type Does Not Have Property"); } if (property.PropertyType != typeof(string)) { throw new InvalidOperationException("Resource Property is Not String Type"); } return (string) property.GetValue(null, null); } return null; } } }