コード例 #1
0
        private void ValidateBreakType()
        {
            if (BreakType is null)
            {
                return;
            }

            var value = BreakType.Trim();

            if (!BreakType.Equals(value, StringComparison.OrdinalIgnoreCase))
            {
                var guruMeditation = new BreakTypeTooShortException();
                guruMeditation.Data.Add(nameof(ExternalSpotRef), ExternalSpotRef);

                throw guruMeditation;
            }

            if (value.Length < BreakConstants.MinimumBreakTypeLength)
            {
                var guruMeditation = new BreakTypeTooShortException();
                guruMeditation.Data.Add(nameof(ExternalSpotRef), ExternalSpotRef);

                throw guruMeditation;
            }

            // Check that the first two characters are would be long enough.
            // Optimiser uses just the first two character so they must be valid
            // in isolation.
            var prefix = BreakType.Substring(0, 2).Trim();

            if (prefix.Length < BreakConstants.MinimumBreakTypeLength)
            {
                var guruMeditation = new BreakTypePrefixTooShortException();
                guruMeditation.Data.Add(nameof(ExternalSpotRef), ExternalSpotRef);

                throw guruMeditation;
            }
        }