protected override void ValidateRepeat(RomanCalculator connector) { if (connector.Contains($"{this.ToString()}{this.ToString()}")) { throw new Exception($"{this.ToString()} can nerver be repeated."); } }
protected virtual void ValidateRepeat(RomanCalculator connector) { if (connector.Contains($"{this.ToString()}{this.ToString()}{this.ToString()}{this.ToString()}")) { throw new Exception($"{this.Symbol} can not be repeated over than 3 times in successive."); } MatchCollection matches = null; if (connector.Contains(new Regex("^[" + this.ToString() + "]{3}([.]){1}" + this.ToString() + "$"), out matches)) { var midNumber = RomanNumber.Create(matches[0].Value); if (midNumber.Value >= this.Value) { throw new Exception($"{midNumber.Symbol} must be less than {this.ToString()}'s value : {this.ToString()}."); } } }