Beispiel #1
0
        public PatternMatcher(PatternRepository patternRepository)
        {
            IEnumerable <IPattern> patterns = patternRepository.Get();

            this.allPatterns    = patterns.GroupBy(p => p.Pieces.Count()).Select(g => new HashSet <IPattern>(g)).ToList();
            this.hashAndPattern = GetPatternHashes(patterns);
        }
        /// <summary>
        /// Parses the specified raw pattern to produce appropriate <see cref="IPatternTranslator"/>s.
        /// </summary>
        /// <param name="rawPattern">A raw pattern to be splitted into individual pattern strings, which will be further matched with
        /// registered patterns to get the <see cref="IPatternTranslator"/>s.</param>
        /// <example>
        /// For example, a raw pattern '{China} - {ZhongHua}China' contains 4 pattern strings, and will thus produce 4 <see cref="IPatternTranslator"/>s.
        /// </example>
        /// <returns></returns>
        public static IEnumerable <IPatternTranslator> Parse(string rawPattern)
        {
            Requires.Instance.NotNullOrWhiteSpace(rawPattern, "rawPattern");

            var matchItems         = ParsePattern(rawPattern);
            var patternTranslators = new List <IPatternTranslator>(matchItems.Count);

            foreach (var matchItem in matchItems)
            {
                IPatternTranslator patternTranslator;
                if (matchItem.IsTaggedValue)
                {
                    if (!PatternRepository.TryGet(matchItem.MatchedString, out patternTranslator))
                    {
                        patternTranslator = new ConstPatternTranslator(OpeningTag + matchItem.MatchedString + ClosingTag);
                    }
                }
                else
                {
                    patternTranslator = new ConstPatternTranslator(matchItem.MatchedString);
                }

                patternTranslators.Add(patternTranslator);
            }

            return(patternTranslators);
        }
        public EditPatternViewModelTests() : base(new Pattern())
        {
            _patternRepository = SimpleIoc.Default.GetInstance <PatternRepository>();
            _threadRepository  = SimpleIoc.Default.GetInstance <ThreadRepository>();

            _patternRepository.Clear();
            _threadRepository.Clear();
        }
Beispiel #4
0
        public MainViewModel()
        {
            Pattern     = new PatternRepository();
            MatchGroups = new ObservableCollection <string>();

            View = new MainWindow(this);
            View.Show();
        }
        public EditPatternViewModel(PatternRepository patternRepository,
                                    ThreadReferenceRepository threadReferenceRepository,
                                    ThreadRepository threadRepository,
                                    IDialogService dialogService)
            : base(threadReferenceRepository, threadRepository, dialogService)
        {
            _patternRepository = patternRepository;

            GenerateOrderCommand = new RelayCommand(OnGenerateOrder, CanGenerateOrder);
        }
Beispiel #6
0
        public EditProjectViewModelTests()
        {
            _projectRepository        = Instance <ProjectRepository>();
            _orderRepository          = Instance <OrderRepository>();
            _patternProjectRepository = Instance <PatternProjectRepository>();
            _patternRepository        = Instance <PatternRepository>();

            _projectRepository.Clear();
            _patternProjectRepository.Clear();
            _patternRepository.Clear();
        }
        public ManagePatternsViewModel(
            INavigationService navigationService,
            PatternRepository patternRepository,
            IDialogService dialogService)
        {
            _patternRepository = patternRepository;
            _dialogService     = dialogService;

            NewPatternCommand    = new RelayCommand(OnNewPattern);
            EditPatternCommand   = new RelayCommand <Pattern>(OnPatternEdit);
            DeletePatternCommand = new RelayCommand <Pattern>(OnDeletePattern);
            RefreshCommand       = new RelayCommand(PopulatePatterns);
        }
Beispiel #8
0
        public PatternRepository Create()
        {
            PatternRepository patternRepository = new PatternRepository();

            foreach (var p1 in P1Patterns)
            {
                patternRepository.Add(p1.Player, p1.PatternType, p1);

                var p2 = GetOther(p1);
                patternRepository.Add(p2.Player, p2.PatternType, p2);
            }

            return(patternRepository);
        }
        public EditProjectViewModel(INavigationService navigationService,
                                    PatternRepository patternRepository,
                                    ProjectRepository projectRepository,
                                    IDialogService dialogService,
                                    PatternProjectRepository patternProjectRepository,
                                    ThreadRepository threadRepository,
                                    ICurrentDateService dateTimeProvider)
        {
            SaveCommand               = new RelayCommand(OnSave);
            UpdatePatternsCommand     = new RelayCommand <Project>(OnUpdatePatterns);
            GenerateOrderCommand      = new RelayCommand(OnGenerateOrder, CanGenerateOrder);
            _patternRepository        = patternRepository;
            _projectRepository        = projectRepository;
            _dialogService            = dialogService;
            _patternProjectRepository = patternProjectRepository;
            _threadRepository         = threadRepository;
            _dateTimeProvider         = dateTimeProvider;

            PatternSelectionDto = new PatternSelection();
        }
Beispiel #10
0
 public void RemovePatternMatcher(IPatternMatcher matcher)
 {
     PatternRepository.Remove(matcher);
 }
Beispiel #11
0
 public void AddPatternMatchers(IEnumerable <IPatternMatcher> matchers)
 {
     PatternRepository.AddRange(matchers);
 }
Beispiel #12
0
 public void AddPatternMatcher(IPatternMatcher matcher)
 {
     PatternRepository.Add(matcher);
 }
 public PatternScorer(PositionManager positions, PatternRepository patternRepository, PatternMatcher matcher)
 {
     this.positions         = positions;
     this.patternRepository = patternRepository;
     this.matcher           = matcher;
 }
        public UpdateProjectPatternsViewModel(PatternRepository patternRepository)
        {
            _patternRepository = patternRepository;

            ConfirmCommand = new RelayCommand(OnConfirm);
        }