Ejemplo n.º 1
0
        /// <summary>
        /// Resolves the pseudo selector by element
        /// </summary>
        private ModifierBase resolveModifier(ModifierElement element)
        {
            var descriptors = DescriptorRepository.GetModifierDescriptors();
            var elements    = descriptors.Where(descriptor => NameMatcher.Match(descriptor.Value, element.Name))
                              .Where(descriptor => descriptor.Arguments.Count() == element.Arguments.Count())
                              .Select(pseudo => new
            {
                pseudo.Type,
                Arguments = element.Arguments.Select(createModifierSelectorArgument)
            })
                              .ToArray();

            if (elements.Length > 1)
            {
                throw new Exception($"Ambiguity of modifier selector: {element.Name}");
            }
            if (!elements.Any())
            {
                throw new Exception($"Not found modifier selector: {element.Name}");
            }

            var modifier = elements.Single();

            return(SelectorFactory.CreateModifier(modifier.Type, modifier.Arguments));
        }
        private IEnumerable <CommandDescriptor> resolveCommandDescriptorsByName(CommandCallDescriptor descriptor)
        {
            // get all available command descriptors
            var commandDescriptors = DescriptorRepository.GetCommandDescriptors();

            // filter command descriptors by their command name
            var filteredDescriptors = commandDescriptors.Where(commandDescriptor => commandDescriptor.CommandNames.Contains(descriptor.Name));

            return(filteredDescriptors.ToList());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Resolves the CombinatorElement.
        /// </summary>
        private BinaryCombinator resolveCombinator(CombinatorElementBase combinatorElement, CombinatorBase left, CombinatorBase right)
        {
            var combinators = DescriptorRepository.GetCombinatorDescriptors()
                              .Where(combinator => NameMatcher.Match(combinator.Value, combinatorElement.Value))
                              .ToArray();

            if (combinators.Count() > 1)
            {
                throw new Exception($"Ambiguity of combinator element: {combinatorElement.Value}");
            }

            if (!combinators.Any())
            {
                throw new Exception($"Combinator is not found: {combinatorElement.Value}");
            }

            return(SelectorFactory.CreateCombinator(combinators[0].CombinatorType, left, right));
        }
Ejemplo n.º 4
0
 protected SelectorDescriptor ResolveSelectorDescriptor(TypeSelectorElement typeSelectorElement)
 {
     return(DescriptorRepository.GetSelectorDescriptors()
            .SingleOrDefault(s => NameMatcher.Match(s.Value, typeSelectorElement.Name)));
 }