Пример #1
0
        public PatternStyleMap(string name, PatternDefinition patternDefinition, SyntaxStyle syntaxStyle)
        {
            if (patternDefinition == null)
            {
                throw new ArgumentNullException("patternDefinition");
            }
            if (syntaxStyle == null)
            {
                throw new ArgumentNullException("syntaxStyle");
            }
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("name must not be null or empty", "name");
            }

            Name = name;
            PatternDefinition = patternDefinition;
            SyntaxStyle       = syntaxStyle;
        }
        public void AddPattern(string name, PatternDefinition patternDefinition, SyntaxStyle syntaxStyle)
        {
            if (patternDefinition == null)
            {
                throw new ArgumentNullException("patternDefinition");
            }
            if (syntaxStyle == null)
            {
                throw new ArgumentNullException("syntaxStyle");
            }
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("name must not be null or empty", "name");
            }

            var existingPatternStyle = FindPatternStyle(name);

            if (existingPatternStyle != null)
            {
                throw new ArgumentException("A pattern style pair with the same name already exists");
            }

            _patternStyles.Add(new PatternStyleMap(name, patternDefinition, syntaxStyle));
        }
 public void AddPattern(PatternDefinition patternDefinition, SyntaxStyle syntaxStyle)
 {
     AddPattern((_patternStyles.Count + 1).ToString(CultureInfo.InvariantCulture), patternDefinition, syntaxStyle);
 }
 public PatternStyleMap(string name, PatternDefinition patternDefinition, SyntaxStyle syntaxStyle)
 {
     Name = !string.IsNullOrEmpty(name) ? name : throw new ArgumentException("name must not be null or empty", nameof(name));
     PatternDefinition = patternDefinition ?? throw new ArgumentNullException(nameof(patternDefinition));
     SyntaxStyle       = syntaxStyle ?? throw new ArgumentNullException("syntaxStyle");
 }