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