Click here to Skip to main content
15,891,529 members
Articles / Programming Languages / Visual Basic

VS.NET CodeDOM-Based Custom Tool for String Resource Management

Rate me:
Please Sign up or sign in to vote.
4.52/5 (12 votes)
22 Jun 200413 min read 123.7K   1.1K   48  
A VS.NET custom tool, created with the help of CodeDOM and EnvDTE, used to facilitate management of resource strings via IntelliSense and error checking in VS.NET environment.
//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.1.4322.573
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

using System;
using System.Resources;
using System.Reflection;

// -----------------------------------------------------------------------------
//  <autogeneratedinfo>
//      This code was generated by:
//        ResourceClassGenerator custom tool for VS.NET
// 
//      It contains classes defined from the contents of the resource file:
//        C:\Development\DotNet\Essential Tools\ResourceClassGenerator\TestCSharp\Resources\Strings.en.resx
// 
//      Generated: Wednesday, June 23, 2004 10:30 AM
//  </autogeneratedinfo>
// -----------------------------------------------------------------------------
namespace Resources.Strings {
    
    
    /// <summary>
    /// Provides access to an assembly's string resources
    /// </summary>
    class ResourceFormatter {
        
        private static System.Resources.ResourceManager _ResourceManager;
        
        /// <summary>
        /// ResourceManager property with lazy initialization
        /// </summary>
        /// <value>An instance of the ResourceManager class.</value>
        private static System.Resources.ResourceManager ResourceManager {
            get {
                if ((_ResourceManager == null)) {
                    _ResourceManager = new System.Resources.ResourceManager("TestCSharp.Resources.Strings", System.Reflection.Assembly.GetExecutingAssembly());
                }
                return _ResourceManager;
            }
        }
        
        /// <summary>
        /// Loads an unformatted string
        /// </summary>
        /// <param name="resourceId">Identifier of string resource</param>
        /// <returns>string</returns>
        public static string GetString(string resourceId) {
            return ResourceFormatter.ResourceManager.GetString(resourceId);
        }
        
        /// <summary>
        /// Loads a formatted string
        /// </summary>
        /// <param name="resourceId">Identifier of string resource</param>
        /// <param name="objects">Array of objects to be passed to string.Format</param>
        /// <returns>string</returns>
        public static string GetString(string resourceId, object[] args) {
            string format = ResourceFormatter.ResourceManager.GetString(resourceId);
            return string.Format(format, args);
        }
    }
    
    /// <summary>
    /// Access to resource identifier Label1
    /// </summary>
    class Label1 {
        
        public static string GetString() {
            return ResourceFormatter.GetString("Label1");
        }
    }
    
    /// <summary>
    /// Access to resource identifier Label2
    /// </summary>
    class Label2 {
        
        public static string GetString(object arg0, object arg1) {
            return ResourceFormatter.GetString("Label2", new object[] {
                        arg0,
                        arg1});
        }
    }
    
    /// <summary>
    /// Access to resource identifier Label3
    /// </summary>
    class Label3 {
        
        public static string GetString() {
            return ResourceFormatter.GetString("Label3");
        }
    }
    
    /// <summary>
    /// Access to resource identifier Label4
    /// </summary>
    class Label4 {
        
        public static string GetString() {
            return ResourceFormatter.GetString("Label4");
        }
    }
    
    /// <summary>
    /// Access to resource identifier Label5
    /// </summary>
    class Label5 {
        
        public static string GetString() {
            return ResourceFormatter.GetString("Label5");
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer Mono Ltd
Croatia Croatia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions