public override void AddTag(TagBase tag) { if (!(tag is ISubtractableTag)) { throw new InvalidRulesException($"Tried to sum non-subtractable tag '{tag.RenderForLog()}' on '{Owner.RenderForLog()}'."); } ISubtractableTag newTag = null; foreach (ISubtractableTag that in Tags.Append(tag).Where(x => x.Key == tag.Key).OfType <ISubtractableTag>()) { newTag = newTag == null ? that : newTag.SubtractTag(that); } Tags.RemoveAll(x => x.Key == tag.Key); Tags.Add((TagBase)newTag); }
public override void AddTag(TagBase tag) { IAddableTag addableTag = tag as IAddableTag; if (addableTag == null) { throw new InvalidRulesException($"Tried to sum non-addable tag '{tag.RenderForLog()}' on '{Owner.RenderForLog()}'."); } foreach (IAddableTag that in Tags.Where(x => x.Key == tag.Key).OfType <IAddableTag>()) { addableTag = addableTag.AddTag(that); } Tags.RemoveAll(x => x.Key == tag.Key); Tags.Add((TagBase)addableTag); }
public override void AddTag(TagBase tag) { ValueTagBase valueTag = tag as ValueTagBase; if (valueTag == null) { throw new InvalidRulesException( $"Tried to keep smallest non-value tag '{tag.RenderForLog()}' on '{Owner.RenderForLog()}'."); } TagBase tagToAdd = Tags .OfType <ValueTagBase>() .Where(x => x.Key == tag.Key) .Append(valueTag) .Min(); Tags.RemoveAll(x => x.Key == tag.Key); Tags.Add(tagToAdd); }
protected TagBase(TagBase that, int?duration) : this(that.Key, duration) { }
protected TagBase(TagBase that, string key) : this(key, that.Duration) { }
protected TagBase(TagBase that) : this(that.Key, that.Duration) { }
public override void AddTag(TagBase tag) { Tags.RemoveAll(x => x.Key == tag.Key); Tags.Add(tag); }
public override void AddTag(TagBase tag) { Tags.Add(tag); }
public abstract void AddTag(TagBase tag);