Пример #1
0
        private PlantUmlComponent CreateNewComponent(string input)
        {
            PlantUmlComponentMatcher matcher = _plantUmlPatterns.MatchComponent(input);

            var componentName = new ComponentName(matcher.MatchComponentName());
            ImmutableHashSet <Stereotype> immutableStereotypes = IdentifyStereotypes(matcher, componentName);
            string alias = matcher.MatchAlias();

            return(new PlantUmlComponent(componentName, immutableStereotypes, alias != null ? new Alias(alias) : null));
        }
Пример #2
0
        private ImmutableHashSet <Stereotype> IdentifyStereotypes(PlantUmlComponentMatcher matcher, ComponentName componentName)
        {
            var stereotypes = ImmutableHashSet.CreateBuilder <Stereotype>();

            foreach (string stereotype in matcher.MatchStereoTypes())
            {
                stereotypes.Add(new Stereotype(stereotype));
            }

            ImmutableHashSet <Stereotype> result = stereotypes.ToImmutable();

            if (result.IsEmpty)
            {
                throw new IllegalDiagramException(string.Format("Components must include at least one stereotype"
                                                                + " specifying the namespace identifier (<<.*>>), but component '{0}' does not", componentName.AsString()));
            }
            return(result);
        }