|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionOne of the great new features of the Visual Studio .NET 2005/2008 IDE is a custom tool called The two screenshots below illustrate the default properties of a resource file added to Visual Studio .NET 2005 and the Resource.Designer.cs source file, which is dependent upon Resource.resx and is automatically generated by the ResXFileCodeGenerator custom tool.
All of the properties exposed by the generated
If your resource file contains only one /// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[GeneratedCodeAttribute("Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[DebuggerNonUserCodeAttribute()]
[CompilerGeneratedAttribute()]
internal class Resource {
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[SuppressMessageAttribute(
"Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resource() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
ResourceManager temp =
new ResourceManager("MyApp.Resource", typeof(Resource).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Message text.
/// </summary>
internal static string Message {
get {
return ResourceManager.GetString("Message", resourceCulture);
}
}
}
BackgroundDespite the fact that the
The Extended Strongly Typed Resource GeneratorIn regard to the above described Using an extended version of the strongly typed resource generator is extremely straightforward and does not differ from using the resource code generator shipped with Visual Studio .NET 2005 and 2008. The extended strongly typed resource generator is represented by two new custom tools:
First of all, you have to install and register the extended strongly types resource generator (e.g.
After the extended strongly typed resource generator is installed on your box, you have to restart all running instances of Visual Studio .NET 2005 and 2008.
From this point on, you can use all advantages of the extended strongly typed resource generator in your projects. You can manually specify the Let's take the
The /// <summary>
/// A strongly-typed resource class, for looking up localized strings,
/// formatting them, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilderEx class via the
// ResXFileCodeGeneratorEx custom tool. To add or remove a member, edit your .ResX file
// then rerun the ResXFileCodeGeneratorEx custom tool or rebuild your VS.NET project.
// Copyright (c) Dmytro Kryvko 2006-2008 (http://dmytro.kryvko.googlepages.com/)
[GeneratedCodeAttribute
("DMKSoftware.CodeGenerators.Tools.StronglyTypedResourceBuilderEx",
"2.1.0.0")]
[DebuggerNonUserCodeAttribute()]
public class Resource {
private static ResourceManager _resourceManager;
private static object _internalSyncObject;
private static CultureInfo _resourceCulture;
[SuppressMessageAttribute
("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resource() {
}
public static object InternalSyncObject {
get {
if (object.ReferenceEquals(_internalSyncObject, null)) {
CompareExchange(ref _internalSyncObject, new object(), null);
}
return _internalSyncObject;
}
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
public static ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(_resourceManager, null)) {
Monitor.Enter(InternalSyncObject);
try {
if (object.ReferenceEquals(_resourceManager, null)) {
Interlocked.Exchange(ref _resourceManager,
new ResourceManager("MyApp.Resource",
typeof(Resource).Assembly));
}
}
finally {
Monitor.Exit(InternalSyncObject);
}
}
return _resourceManager;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
public static CultureInfo Culture {
get {
return _resourceCulture;
}
set {
_resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to 'Hello, {0}!'.
/// </summary>
public static string Hello {
get {
return ResourceManager.GetString("Hello", _resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 'Message text'.
/// </summary>
public static string Message {
get {
return ResourceManager.GetString("Message", _resourceCulture);
}
}
/// <summary>
/// Formats a localized string similar to 'Hello, {0}!'.
/// </summary>
/// <param name="arg0">An object (0) to format.</param>
/// <returns>A copy of format string in which the format
/// items have been replaced by the String equivalent of
/// the corresponding instances of Object in arguments.</returns>
public static string HelloFormat(object arg0) {
return string.Format(_resourceCulture, Hello, arg0);
}
/// <summary>
/// The stub formatting method returning the Message property value.
/// </summary>
/// <returns>The Message property value.</returns>
public static string MessageFormat() {
return Message;
}
}
As you can see, the generated class is The name of a format method is always generated in the following way:
The 2.1 version of the extended strongly typed Another tiny improvement over the standard Visual Studio Generation of /// <summary>
/// A strongly-typed resource class, for looking up localized strings,
/// formatting them, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilderEx class via
// the InternalResXFileCodeGeneratorEx custom tool.
// To add or remove a member, edit your .ResX
// file then rerun the InternalResXFileCodeGeneratorEx custom tool or
// rebuild your VS.NET project.
// Copyright (c) Dmytro Kryvko 2006-2008 (http://dmytro.kryvko.googlepages.com/)
[GeneratedCodeAttribute
("DMKSoftware.CodeGenerators.Tools.StronglyTypedResourceBuilderEx",
"2.1.0.0")]
[DebuggerNonUserCodeAttribute()]
internal class Resource {
private static ResourceManager _resourceManager;
private static object _internalSyncObject;
private static CultureInfo _resourceCulture;
[SuppressMessageAttribute
("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resource() {
}
internal static object InternalSyncObject {
get {
if (object.ReferenceEquals(_internalSyncObject, null)) {
Interlocked.CompareExchange(ref _internalSyncObject, new object(), null);
}
return _internalSyncObject;
}
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
internal ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(_resourceManager, null)) {
Monitor.Enter(InternalSyncObject);
try {
if (object.ReferenceEquals(_resourceManager, null)) {
Interlocked.Exchange(ref _resourceManager,
new ResourceManager("MyApp.Resource",
typeof(Resource).Assembly));
}
}
finally {
Monitor.Exit(InternalSyncObject);
}
}
return _resourceManager;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture {
get {
return _resourceCulture;
}
set {
_resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to 'Hello, {0}!'.
/// </summary>
internal static string Hello {
get {
return ResourceManager.GetString("Hello", _resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 'Message text'.
/// </summary>
internal static string Message {
get {
return ResourceManager.GetString("Message", _resourceCulture);
}
}
/// <summary>
/// Formats a localized string similar to 'Hello, {0}!'.
/// </summary>
/// <param name="arg0">An object (0) to format.</param>
/// <returns>A copy of format string in which the format
/// items have been replaced by the String equivalent of
/// the corresponding instances of Object in arguments.</returns>
internal static string HelloFormat(object arg0) {
return string.Format(_resourceCulture, Hello, arg0);
}
/// <summary>
/// The stub formatting method returning the Message property value.
/// </summary>
/// <returns>The Message property value.</returns>
internal static string MessageFormat() {
return Message;
}
}
Roadmap
History
| ||||||||||||||||||||||