namespace system.web.mvc{//<summary>// extended htmlhelper//</summary> public Static Class Htmlhelperextension {public static htmlstring Lang (This htmlhelper hepler, string resourcefile, String ResourceKey) { String value = Httpcontext.getglobalresourceobject (Resourcefile, ResourceKey). ToString (); String str = Resources. return new htmlstring (value);}}
<summary>//App_global and app_local Resource Provider. </summary> public interface IResourceProvider {//<summary>/To get the Global Re Sources from a file on the basis of provided key///</summary>//<typeparam name= "T" >value Ty pe</typeparam>//<param name= "resourcefile" >class name</param>//<param name= "Resou Rcekey ">key name</param>//<returns></returns> T getglobalresocevalue<t> (string Resourcefile, string resourceKey); <summary>//To get the Local Resources from a file on the basis of provided key///</summary >//<typeparam name= "T" >value type</typeparam>//<param name= "Resourcefile" >Class N ame</param>//<param name= "ResourceKey" >key name</param>//<returns></returns > T GetlocalresoCevalue<t> (String resourcefile, string resourceKey); }
public class Resourceprovider:iresourceprovider {//<summary>//Get the Global Resource Va Lues from the app_global_resources///</summary>//<typeparam name= "T" >return Type</typepa ram>//<param name= "resourcefile" >file name</param>//<param name= "ResourceKey" > Ke Y name</param>//<returns></returns> public T getglobalresocevalue<t> (string Resou Rcefile, String ResourceKey) {return (T) httpcontext.getglobalresourceobject (resourcefile, ResourceKey); }//<summary>//Get the Local Resources///</summary>//<typepar Am Name= "T" >return type</typeparam>//<param name= "resourcefile" ></param>//<par Am Name= "ResourceKey" ></param>///<returns></returns> public T getlocalresocevalue< T> (String ResourcefilE, String ResourceKey) {return (T) httpcontext.getlocalresourceobject (resourcefile, ResourceKey); } }
Extension of the resource file in MVC