DefineSymbols.cs 856 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections.Generic;
  2. // ReSharper disable MemberCanBePrivate.Global
  3. /// <summary>
  4. /// Utility class to manage a list of symbol strings.
  5. /// </summary>
  6. public class DefineSymbols {
  7. private List<string> symbols;
  8. public DefineSymbols(string symbols)
  9. {
  10. Set(symbols);
  11. }
  12. public void Set(string sym)
  13. {
  14. symbols = new List<string>(sym.Split(new [] { ";" }, System.StringSplitOptions.None));
  15. }
  16. public bool Has(string symbol)
  17. {
  18. return (symbols.FindIndex(obj => obj == symbol) >= 0);
  19. }
  20. public void Add(string symbol)
  21. {
  22. if (!Has(symbol))
  23. {
  24. symbols.Add(symbol);
  25. }
  26. }
  27. public void Remove(string symbol)
  28. {
  29. symbols.Remove(symbol);
  30. }
  31. public string Get()
  32. {
  33. return string.Join(";", symbols.ToArray());
  34. }
  35. }