VoiceOver.cs 990 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using I2.Loc;
  6. namespace DatabaseModel
  7. {
  8. public class VoiceOver
  9. {
  10. public string Key { get; private set; }
  11. public string FilePath { get; private set; }
  12. public string FileName { get; private set; }
  13. public string LocalizedSubtitle
  14. {
  15. get
  16. {
  17. return ScriptLocalization.Get("subtitle/" + this.Key);
  18. }
  19. }
  20. public static VoiceOver[] FindByKey(string key)
  21. {
  22. if (DB.VoiceOvers.ContainsKey(key))
  23. {
  24. return (from pair in DB.VoiceOvers
  25. where Regex.IsMatch(pair.Key, string.Format("^{0}(\\.\\d+)?$", key))
  26. select pair.Value).ToArray<VoiceOver>();
  27. }
  28. throw new KeyNotFoundException(key + "不在数据库VoiceOver中");
  29. }
  30. public static VoiceOver SetValue(string[] strings)
  31. {
  32. return new VoiceOver
  33. {
  34. Key = strings[0],
  35. FilePath = strings[1],
  36. FileName = strings[2]
  37. };
  38. }
  39. }
  40. }