Exemplo n.º 1
0
        public void EnableOnAllConditions(EditorID editor)
        {
            if (ConditionMode == ConditionModes.All)
            {
                return;
            }

            ApplyEvent(new EnabledOnAllConditions(editor));
        }
Exemplo n.º 2
0
        public void RemoveTag(EditorID editor, string tag)
        {
            if (_tags.Contains(tag) == false)
            {
                return;
            }

            ApplyEvent(new TagRemoved(editor, tag));
        }
Exemplo n.º 3
0
        public void EnableOnAnyCondition(EditorID editor)
        {
            if (ConditionMode == ConditionModes.Any)
            {
                return;
            }

            ApplyEvent(new EnabledOnAnyCondition(editor));
        }
Exemplo n.º 4
0
        //public methods which do domainy things
        public void AddTag(EditorID editor, string tag)
        {
            if (_tags.Contains(tag))
            {
                return;
            }

            ApplyEvent(new TagAdded(editor, tag));
        }
Exemplo n.º 5
0
        public void RemoveCondition(EditorID editor, ConditionID conditionID)
        {
            if (_conditions.HasCondition(conditionID) == false)
            {
                throw new ConditionNotFoundException(conditionID);
            }

            ApplyEvent(new ConditionRemoved(editor, conditionID));
        }
Exemplo n.º 6
0
        public void ChangeDescription(EditorID editor, string newDescription)
        {
            if (Description == newDescription)
            {
                return;
            }

            ApplyEvent(new ToggleDescriptionChanged(editor, newDescription));
        }
Exemplo n.º 7
0
        public void Rename(EditorID editor, string newName)
        {
            if (string.IsNullOrWhiteSpace(newName))
            {
                throw new ArgumentNullException(nameof(newName), "Toggles must have a non-whitespace name.");
            }

            if (Name == newName)
            {
                return;
            }

            ApplyEvent(new ToggleRenamed(editor, newName));
        }
Exemplo n.º 8
0
        public ConditionID AddCondition(EditorID editor, Dictionary <string, object> conditionProperties, ConditionID parentConditionID = null)
        {
            var messages = _conditionBuilder.CanCreateFrom(conditionProperties).ToArray();

            if (messages.Any())
            {
                throw new ConditionException(messages.First());
            }

            ValidateParentCondition(parentConditionID);

            var conditionID = NextConditionID();

            ApplyEvent(new ConditionAdded(editor, conditionID, parentConditionID, conditionProperties));

            return(conditionID);
        }
Exemplo n.º 9
0
        public static Toggle CreateNew(EditorID creator, string name, string description = "", ToggleID toggleID = null)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name), "Toggles must have a non-whitespace name.");
            }

            var toggle = new Toggle();

            toggle.ApplyEvent(new ToggleCreated(
                                  creator,
                                  toggleID ?? ToggleID.CreateNew(),
                                  name.Trim(),
                                  description));

            return(toggle);
        }
Exemplo n.º 10
0
 protected override object Parse(string value) => EditorID.Parse(value);
Exemplo n.º 11
0
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 {
     return(EditorID.Parse(Convert.ToString(reader.Value) ?? string.Empty));
 }