Resx资源文件的另类用法

首先为VS安装上这2个插件ResXFileCodeGeneratorComment.msi  ResXFileCodeGeneratorEx.msi

然后新建个Resx文件,例如 CarrierCode.Resx这个文件主要是记录些,错误代码以及说明.

右键该CarrierCode.Resx的属性将 在自定义工具这栏ResXFileCodeGenerator改为ResXFileCodeGeneratorComment.

       原代码

    

namespace WcfServer.Common.Resource {
    using System;
    
    
    /// 
    ///   强类型资源类,用于查找本地化字符串等。
    /// 
    // 此类是由 StronglyTypedResourceBuilder
    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
    // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
    // (以 /str 作为命令选项),或重新生成 VS 项目。
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class Resource1 {
        
        private static global::System.Resources.ResourceManager resourceMan;
        
        private static global::System.Globalization.CultureInfo resourceCulture;
        
        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal Resource1() {
        }
        
        /// 
        ///   返回此类使用的缓存 ResourceManager 实例。
        /// 
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WcfServer.Common.Resource.Resource1", typeof(Resource1).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }
        
        /// 
        ///   为使用此强类型资源类的所有资源查找
        ///   重写当前线程的 CurrentUICulture 属性。
        /// 
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }
    }
}

更改后的代码为

//------------------------------------------------------------------------------
// 
 
 
  
  
//     此代码由工具生成。
//     运行库版本:2.0.50727.1433
//
//     对此文件的更改可能会导致不正确的行为,并且如果
//     重新生成代码,这些更改将会丢失。
// 
 
 
//------------------------------------------------------------------------------

namespace WcfServer.Common.Resource {
    using System;
    
    
    /// 
    /// A strongly-typed resource class, for looking up localized strings, formatting them, etc.
    /// 
    // This class was auto-generated by the StronglyTypedResourceBuilderComment class via the ResXFileCodeGeneratorComment custom tool.
    // To add or remove a member, edit your .ResX file then rerun the ResXFileCodeGeneratorComment custom tool or rebuild your VS.NET project.
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("DMKSoftware.CodeGenerators.Tools.StronglyTypedResourceBuilderComment", "2.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    public sealed class CarrierCode {
        
        private static global::System.Resources.ResourceManager _resourceManager;
        
        private static global::System.Globalization.CultureInfo _resourceCulture;
        
        public const string aaa = ((string)("1000"));
        
        private CarrierCode() {
        }
        
        /// 
        /// Returns the cached ResourceManager instance used by this class.
        /// 
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        public static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(_resourceManager, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WcfServer.Common.Resource.CarrierCode", typeof(CarrierCode).Assembly);
                    _resourceManager = temp;
                }
                return _resourceManager;
            }
        }
        
        /// 
        /// Overrides the current thread's CurrentUICulture property for all
        /// resource lookups using this strongly typed resource class.
        /// 
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        public static global::System.Globalization.CultureInfo Culture {
            get {
                return _resourceCulture;
            }
            set {
                _resourceCulture = value;
            }
        }
        
        /// 
        /// Get value by name!
        /// 
        public static object GetValue(string name) {
            return ResourceManager.GetObject(name, _resourceCulture);
        }
    }
}

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值