Extension of the resource file in MVC

Source: Internet
Author: User
Tags httpcontext

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.