Guest User

textbank

a guest
Jul 3rd, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. /// <summary>
  2. /// Represents an immutable repository of strings for localization.
  3. /// </summary>
  4. public class TextBank
  5. {
  6.     /// <summary>
  7.     /// Initializes a new TextBank containing the specified collection of strings.
  8.     /// </summary>
  9.     /// <param name="texts">The collection of strings that should be stored in the repository.</param>
  10.     /// <remarks>The main purpose of a TextBank is localization, they should only ever be loaded from file.
  11.     /// This constructor is intended for tools that generate the localization files.</remarks>
  12.     public TextBank(IEnumerable<string> texts)
  13.     {
  14.         this.texts = (string[])texts.ToArray().Clone();
  15.     }
  16.  
  17.     string[] texts;
  18.  
  19.     /// <summary>
  20.     /// The number of strings contained in the repository.
  21.     /// </summary>
  22.     public int Length
  23.     {
  24.         get { return texts.Length; }
  25.     }
  26.  
  27.     /// <summary>
  28.     /// Gets the string identified by the specified integer key.
  29.     /// </summary>
  30.     /// <param name="key">A non-negative key that identifies the returned string. Must not be greater than or equal to <see cref="Length"/>.</param>
  31.     public string this[int key]
  32.     {
  33.         get { return texts[key]; }
  34.     }
  35. }
Add Comment
Please, Sign In to add comment