Advertisement
Guest User

T4 Template

a guest
Sep 26th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <#@ template debug="false" hostspecific="true" language="C#" #>
  2. <#@ assembly name="System.Core" #>
  3. <#@ import namespace="System.Linq" #>
  4. <#@ import namespace="System.IO" #>
  5. <#@ output extension=".cs" #>
  6.  
  7. namespace MyNamespace
  8. {
  9. public enum SoundNames
  10. {
  11. <#
  12. string path = this.Host.ResolvePath("");
  13. Directory.SetCurrentDirectory(path);
  14.  
  15. string soundFilesPath = @".\Sounds\";
  16. var soundNames = Directory
  17. .GetFiles(soundFilesPath, "*.*", SearchOption.AllDirectories)
  18. .Where(file => file.ToLower().EndsWith("wav") || file.ToLower().EndsWith("mp3"))
  19. .Select(soundFilePath => Path.GetFileNameWithoutExtension(soundFilePath))
  20. .ToList();
  21.  
  22. foreach (var name in soundNames)
  23. {
  24. #>
  25. <#= name #>,
  26. <#
  27. }
  28. #>
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement