ExpressionEditor.cs 946 B

1234567891011121314151617181920212223242526272829303132
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. namespace InABox.Core
  7. {
  8. public class ExpressionEditor : BaseEditor
  9. {
  10. /// <summary>
  11. /// The <see cref="IExpressionModel"/> to use for this expression; if set to null, the variables must be manually set for the editor.
  12. /// </summary>
  13. public Type? ModelType { get; set; }
  14. [DoNotSerialize]
  15. [JsonIgnore]
  16. public List<string>? VariableNames { get; set; }
  17. public ExpressionEditor(Type? modelType)
  18. {
  19. if (modelType != null && !typeof(IExpressionModel).IsAssignableFrom(modelType))
  20. throw new Exception($"Expression type must be a {nameof(IExpressionModel)}");
  21. ModelType = modelType;
  22. }
  23. protected override BaseEditor DoClone()
  24. {
  25. return new ExpressionEditor(ModelType);
  26. }
  27. }
  28. }