added samples
[windows-sources.git] / sdk / samples / WPFSamples / LocBaml / csharp / stringloader.cs
blobd2f17c765070a94ac5e09b04d5be4f341f71f08c
1 //-------------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 // Description: String Loader class, loading strings from StringTable Resource.
4 //-------------------------------------------------------------------------------
7 using System;
8 using System.Resources;
9 using System.Globalization;
11 namespace BamlLocalization
13 internal class StringLoader
15 public static string Get( string id, params object[] args)
17 string message = _resourceManager.GetString(id);
18 if (message != null)
20 // Apply arguments to formatted string (if applicable)
21 if (args != null && args.Length > 0)
23 message = String.Format(CultureInfo.CurrentCulture, message, args);
26 return message;
28 // Get exception string resources for current locale
29 private static ResourceManager _resourceManager = new ResourceManager("Resources.StringTable", typeof(StringLoader).Assembly);
30 }//endof class StringLoader
31 }//endof namespace