Exemplo n.º 1
0
            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);
            }
Exemplo n.º 2
0
            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);
            }
Exemplo n.º 3
0
            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);
            }
Exemplo n.º 4
0
 protected TagBase(TagBase that, int?duration)
     : this(that.Key, duration)
 {
 }
Exemplo n.º 5
0
 protected TagBase(TagBase that, string key)
     : this(key, that.Duration)
 {
 }
Exemplo n.º 6
0
 protected TagBase(TagBase that)
     : this(that.Key, that.Duration)
 {
 }
Exemplo n.º 7
0
 public override void AddTag(TagBase tag)
 {
     Tags.RemoveAll(x => x.Key == tag.Key);
     Tags.Add(tag);
 }
Exemplo n.º 8
0
 public override void AddTag(TagBase tag)
 {
     Tags.Add(tag);
 }
Exemplo n.º 9
0
 public abstract void AddTag(TagBase tag);