public IAddableTag AddTag(IAddableTag tag) { if (tag == null) { throw new ArgumentNullException(nameof(tag)); } StringValueTag that = tag as StringValueTag; if (that == default(StringValueTag)) { throw new InvalidRulesException($"Tried to add tags of different types '{RenderForLog()}' and '{tag.RenderForLog()}'."); } return(new StringValueTag(Key, Value + that.Value, Duration)); }
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); }