Пример #1
0
        private void OpenXML_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "TXT File|*.xml";
            openFileDialog.Title            = "XML opening";
            openFileDialog.RestoreDirectory = true;


            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                if (Library.TryOpenXml(openFileDialog.FileName))
                {
                    Library.FileName = openFileDialog.SafeFileName;

                    Context         context          = new Context();
                    int             method           = DefineMethod();
                    ISearchStrategy concreteStrategy = Context.Strategies[method];

                    context.SetStrategy(concreteStrategy);

                    Library.Books = context.GetBooks();

                    AddItemsToComboBox();
                }
            }
        }
Пример #2
0
        public Graph(IEdgeHandlerStrategy edgeHandlerStrategy, ISearchStrategy searchStrategy)
        {
            _edgeHandlerStrategy = edgeHandlerStrategy;
            _searchStrategy      = searchStrategy;

            Vertexes = new List <Vertex>();
        }
Пример #3
0
        internal Solver(FactSet partialModel, Model source, CancellationToken cancel)
        {
            Contract.Requires(partialModel != null);
            Contract.Requires(source != null);
            this.cancel = cancel;

            Source       = source;
            PartialModel = partialModel;

            //// Step 1. Create Z3 Context and Solver
            CreateContextAndSolver();

            //// Step 2. Create type embedder
            CreateTypeEmbedder();

            //// Step 3. Create cardinality system.
            Cardinalities = new CardSystem(partialModel);

            //// Step 4. Try to create the search strategy.
            if (!Cardinalities.IsUnsat)
            {
                Strategy = CreateStrategy(solverFlags);
            }

            var se = new SymExecuter(this);
        }
 public static bool FindInList(this List <int> list, int number, ISearchStrategy searchStrategy = null)
 {
     if (searchStrategy == null)
     {
         return(list.BinarySearch(number) >= 1);
     }
     return(searchStrategy.Search(list, number));
 }
Пример #5
0
 public SimpleSearch(ISearchStrategy strategy, bool avoidRepetition = true)
 {
     Strategy = strategy;
     if (avoidRepetition)
         _closed = new List<IState>();
     else
         _closed = null;
 }
Пример #6
0
        public Dictionary <int, string> GetManualResult(string text, bool regexMode, bool ignoreCaseMode)
        {
            Dictionary <int, string> returnValue = new Dictionary <int, string>();
            ISearchStrategy          strategy    = SearchStrategyFactory.Create(text, ignoreCaseMode, false, regexMode ? SearchMode.RegEx : SearchMode.Normal);

            GetSearchResult(ref returnValue, strategy);
            return(returnValue);
        }
Пример #7
0
 public SearchRun(ISearchStrategy strategy, SearchableFileContentFinder fileFinder, IEnumerable <FileName> fileList, IProgressMonitor monitor)
 {
     this.strategy   = strategy;
     this.fileFinder = fileFinder;
     this.fileList   = fileList;
     this.monitor    = monitor;
     this.cts        = new CancellationTokenSource();
 }
Пример #8
0
 public PathFinder(int[,] grid, Location startLoc, Location goalLoc, 
     ISearchStrategy searchStrategy)
 {
     _grid = grid;
     _startLoc = startLoc;
     _goalLoc = goalLoc;
     _searchStrategy = searchStrategy;
 }
Пример #9
0
		public bool Equals(ISearchStrategy other)
		{
			var strategy = other as RegexSearchStrategy;
			return strategy != null &&
				strategy.searchPattern.ToString() == searchPattern.ToString() &&
				strategy.searchPattern.Options == searchPattern.Options &&
				strategy.searchPattern.RightToLeft == searchPattern.RightToLeft;
		}
Пример #10
0
        public bool Equals(ISearchStrategy other)
        {
            var strategy = other as RegexSearchStrategy;

            return(strategy != null &&
                   strategy.searchPattern.ToString() == searchPattern.ToString() &&
                   strategy.searchPattern.Options == searchPattern.Options &&
                   strategy.searchPattern.RightToLeft == searchPattern.RightToLeft);
        }
Пример #11
0
 public void UpdateSearch()
 {
     // only reset as long as there are results
     // if no results are found, the "no matches found" message should not flicker.
     // if results are found by the next run, the message will be hidden inside DoSearch ...
     strategy = SearchStrategyFactory.Create(SearchPattern ?? "", true, false, SearchMode.Normal);
     OnSearchOptionsChanged(new SearchOptionsChangedEventArgs(SearchPattern, true, false, false));
     DoSearch(true);
 }
    public FishingMachine(IClicker clicker, IScreenCapture screenCapture, ISearchStrategy searchStrategy, CancellationToken mToken = default)
    {
        this.m_Clicker        = clicker;
        this.m_ScreenCapture  = screenCapture;
        this.m_SearchStrategy = searchStrategy;
        this.m_token          = mToken;

        this._stateMachine = new StateMachine <State, Trigger>(State.LookingForHook);
        ConfigureStateMachine();
    }
Пример #13
0
        public static IEnumerable <SearchedFile> FindAll(ISearchStrategy strategy, SearchLocation location, IProgressMonitor progressMonitor)
        {
            currentSearchRegion = null;
            SearchableFileContentFinder fileFinder = new SearchableFileContentFinder();

            return(new SearchRun(strategy, fileFinder, location.GenerateFileList(), progressMonitor)
            {
                Target = location.Target, Selection = location.Selection
            }.GetResults());
        }
Пример #14
0
 SearchRegion(FileName[] files, ISearchStrategy strategy, SearchLocation location)
 {
     if (files == null)
     {
         throw new ArgumentNullException("files");
     }
     this.files    = files;
     this.strategy = strategy;
     this.location = location;
 }
Пример #15
0
        public async Task <List <Book> > GetSearchedBooks(string filter, string radioFilter)
        {
            ISearchStrategy searchStrategy = _searchStrategyFactory.GetSearchStrategy(radioFilter);

            if (searchStrategy != null)
            {
                return(await searchStrategy.GetSearchedBook(filter));
            }

            return(null);
        }
Пример #16
0
            public static SearchRegion CreateSearchRegion(FileName[] files, ISearchStrategy strategy, SearchLocation location)
            {
                ITextEditor editor = GetActiveTextEditor();

                if (editor != null)
                {
                    return(new SearchRegion(files, strategy, location));
                }

                return(null);
            }
Пример #17
0
 void UpdateSearch()
 {
     // only reset as long as there are results
     // if no results are found, the "no matches found" message should not flicker.
     // if results are found by the next run, the message will be hidden inside DoSearch ...
     if (renderer.CurrentResults.Any())
     {
         messageView.IsOpen = false;
     }
     strategy = SearchStrategyFactory.Create(SearchPattern ?? "", !MatchCase, WholeWords, UseRegex ? SearchMode.RegEx : SearchMode.Normal);
     DoSearch(true);
 }
Пример #18
0
 public SimpleSearch(ISearchStrategy strategy, bool avoidRepetition = true)
 {
     Strategy = strategy;
     if (avoidRepetition)
     {
         _closed = new List <IState>();
     }
     else
     {
         _closed = null;
     }
 }
Пример #19
0
 private void UpdateSearch()
 {
     try
     {
         this._strategy = SearchFactory.Create(txtFind.Text ?? ""
                                               , !mniMatchCase.Checked, false, _mode);
         this.DoSearch(true);
     }
     catch (SearchPatternException)
     {
         // Eat any regex parse errors
     }
 }
Пример #20
0
        void UpdateSearch()
        {
            // only reset as long as there are results
            // if no results are found, the "no matches found" message should not flicker.
            // if results are found by the next run, the message will be hidden inside DoSearch ...
            if (renderer.CurrentResults.Any())
            {
                messageView.IsOpen = false;
            }

            strategy = SearchStrategyFactory.Create(SearchPattern ?? "", !MatchCase, WholeWords, GetSearchMode());
            OnSearchOptionsChanged(new SearchOptionsChangedEventArgs(SearchPattern, MatchCase, UseWildCards, UseRegex, WholeWords));
            DoSearch(true);
        }
Пример #21
0
        private static ISearchStrategy _isearchstrategy = null; //搜索策略

        #endregion Fields

        #region Constructors

        static BSPSearch()
        {
            try
            {
                string[] fileNameList = Directory.GetFiles(System.Web.HttpRuntime.BinDirectory, "BrnShop.SearchStrategy.*.dll", SearchOption.TopDirectoryOnly);
                _isearchstrategy = (ISearchStrategy)Activator.CreateInstance(Type.GetType(string.Format("BrnShop.SearchStrategy.{0}.SearchStrategy, BrnShop.SearchStrategy.{0}", fileNameList[0].Substring(fileNameList[0].IndexOf("SearchStrategy.") + 15).Replace(".dll", "")),
                                                                                          false,
                                                                                          true));
            }
            catch
            {
                throw new BSPException("创建'搜索策略对象'失败,可能存在的原因:未将'搜索策略对象'添加到bin目录中;'搜索策略对象'文件名不符合'BrnShop.SearchStrategy.{策略名称}.dll'格式");
            }
        }
Пример #22
0
        private static ISearchStrategy _isearchstrategy = null;//搜索策略

        static BMASearch()
        {
            try
            {
                string[] fileNameList = Directory.GetFiles(System.Web.HttpRuntime.BinDirectory, "BrnMall.SearchStrategy.*.dll", SearchOption.TopDirectoryOnly);
                _isearchstrategy = (ISearchStrategy)Activator.CreateInstance(Type.GetType(string.Format("BrnMall.SearchStrategy.{0}.SearchStrategy, BrnMall.SearchStrategy.{0}", fileNameList[0].Substring(fileNameList[0].IndexOf("SearchStrategy.") + 15).Replace(".dll", "")),
                                                                                          false,
                                                                                          true));
            }
            catch
            {
                throw new BMAException("创建'搜索策略对象'失败,可能存在的原因:未将'搜索策略对象'添加到bin目录中;'搜索策略对象'文件名不符合'BrnMall.SearchStrategy.{策略名称}.dll'格式");
            }
        }
Пример #23
0
        private void GetSearchResult(ref Dictionary <int, string> privateObject, ISearchStrategy searchStrategy)
        {
            foreach (ISearchResult result in searchStrategy.FindAll(document, 0, document.TextLength))
            {
                ISegment     segment    = result as ISegment;
                DocumentLine docLine    = document.GetLineByOffset(segment.Offset);
                int          lineNumber = docLine.LineNumber;
                string       lineText   = document.GetText(docLine.Offset, docLine.Length);

                if (!privateObject.ContainsKey(lineNumber))
                {
                    privateObject.Add(lineNumber, lineText);
                }
            }
        }
 /// <summary>
 /// Constructs a new SearchContext.
 /// </summary>
 /// <param name="domain"><see cref="SearchContext{D, P, A, S, Sol, N}.Domain"/></param>
 /// <param name="source"><see cref="SearchContext{D, P, A, S, Sol, N}.Source"/></param>
 /// <param name="target"><see cref="SearchContext{D, P, A, S, Sol, N}.Target"/></param>
 /// <param name="subject"><see cref="SearchContext{D, P, A, S, Sol, N}.Subject"/></param>
 /// <param name="solution"><see cref="SearchContext{D, P, A, S, Sol, N}.Solution"/></param>
 /// <param name="status"><see cref="SearchContext{D, P, A, S, Sol, N}.Status"/></param>
 /// <param name="startNode"><see cref="SearchContext{D, P, A, S, Sol, N}.StartNode"/></param>
 /// <param name="search"><see cref="SearchContext{D, P, A, S, Sol, N}.Search"/></param>
 /// <param name="expansion"><see cref="SearchContext{D, P, A, S, Sol, N}.Expansion"/></param>
 /// <param name="application"><see cref="SearchContext{D, P, A, S, Sol, N}.Application"/></param>
 /// <param name="evaluation"><see cref="SearchContext{D, P, A, S, Sol, N}.Evaluation"/></param>
 /// <param name="goal"><see cref="SearchContext{D, P, A, S, Sol, N}.Goal"/></param>
 /// <param name="cloner"><see cref="SearchContext{D, P, A, S, Sol, N}.Cloner"/></param>
 public SearchContext(D domain, P source, P target, S subject, Sol solution, SearchStatus status, SearchNode <P, A> startNode, ISearchStrategy <D, P, A, S, Sol> search, IExpansionStrategy <D, P, A, S, Sol, A> expansion, IApplicationStrategy <D, P, A, S, Sol> application, IEvaluationStrategy <D, P, A, S, Sol> evaluation, IGoalStrategy <D, P, A, S, Sol> goal, ICloneStrategy <P> cloner)
 {
     Domain      = domain;
     Source      = source?.Copy();
     Target      = target?.Copy();
     Subject     = subject;
     Solution    = solution;
     Status      = status;
     StartNode   = startNode?.Copy();
     Search      = search;
     Expansion   = expansion;
     Application = application;
     Evaluation  = evaluation;
     Goal        = goal;
     Cloner      = cloner;
 }
        private void ChangeSearchStrategy(ISearchStrategy searchStrategy)
        {
            runViewModel.SearchStrategy          = searchStrategy;
            searchStrategy.OnItterationComplete += ItterationCompleteHandler;

            if (searchStrategy != null)
            {
                searchStrategy.OnItterationComplete += ItterationCompleteHandler;
            }
            ReadyToComputeCheck();

            void ItterationCompleteHandler(ISearchStrategy sender, Log log)
            {
                //TODO console
                runViewModel.Add(log.timeToCompute, log.bestRouteCost);;
                pltPlot.InvalidatePlot(true);
            }
        }
Пример #26
0
        private IEnumerable <FindResult> GetResults(ISearchStrategy strategy, ISourceFile file)
        {
            using (var fileStream = file.OpenText())
            {
                using (var reader = new StreamReader(fileStream))
                {
                    var document = new TextDocument(reader.ReadToEnd());

                    var results = strategy.FindAll(document, 0, document.TextLength);

                    foreach (var result in results.GroupBy(sr => document.GetLineByOffset(sr.Offset).LineNumber).Select(group => group.First()))
                    {
                        var line = document.GetLineByOffset(result.Offset);

                        yield return(new FindResult(file, result.Offset, result.Length, line.LineNumber, line.Offset, document.GetText(line)));
                    }
                }
            }
        }
Пример #27
0
        /// <summary>
        /// Causes the background renderer to draw.
        /// </summary>
        /// <param name="textView"></param>
        /// <param name="drawingContext"></param>
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (String.IsNullOrWhiteSpace(editor.SelectedText) ||
                !editor.SelectedText.All(Char.IsLetterOrDigit))
            {
                return;
            }
            ISearchStrategy strategy = SearchStrategyFactory.Create(editor.SelectedText, false, true, SearchMode.Normal);

            foreach (ISearchResult result in strategy.FindAll(textView.Document, 0, textView.Document.TextLength))
            {
                BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder()
                {
                    CornerRadius = 1
                };
                builder.AddSegment(textView, result);
                drawingContext.DrawGeometry(BrushStyle, PenStyle, builder.CreateGeometry());
            }
        }
Пример #28
0
        public static SearchResultMatch FindNext(ISearchStrategy strategy, SearchLocation location)
        {
            var files = location.GenerateFileList().ToArray();

            if (files.Length == 0)
            {
                return(null);
            }
            if (currentSearchRegion == null || !currentSearchRegion.IsSameState(files, strategy, location))
            {
                currentSearchRegion = SearchRegion.CreateSearchRegion(files, strategy, location);
            }
            if (currentSearchRegion == null)
            {
                return(null);
            }
            var result = currentSearchRegion.FindNext();

            if (result == null)
            {
                currentSearchRegion = null;
            }
            return(result);
        }
Пример #29
0
 public SearchAgent(
     ISearchStrategy <ProblemState <T>, ProblemAction> searchStrategy)
     : base(searchStrategy)
 {
 }
Пример #30
0
 private static void ItterationEventHandler(ISearchStrategy s, Log log)
 {
     Console.WriteLine(log.ToString());
 }
Пример #31
0
 void UpdateSearch()
 {
     // only reset as long as there are results
     // if no results are found, the "no matches found" message should not flicker.
     // if results are found by the next run, the message will be hidden inside DoSearch ...
     if (renderer.CurrentResults.Any())
         messageView.IsOpen = false;
     ISearchStrategy result = SearchStrategyFactory.Create(SearchPattern ?? "", !MatchCase, WholeWords, UseRegex ? SearchMode.RegEx : SearchMode.Normal);
     if (result == null) return;
     else strategy = result;
     OnSearchOptionsChanged(new SearchOptionsChangedEventArgs(SearchPattern, MatchCase, UseRegex, WholeWords));
     DoSearch(true);
 }
Пример #32
0
 private void UpdateSearch()
 {
   try
   {
     this._strategy = SearchFactory.Create(txtFind.Text ?? ""
       , !mniMatchCase.Checked, false, _mode);
     this.DoSearch(true);
   }
   catch (SearchPatternException)
   {
     // Eat any regex parse errors
   }
 }
        /// <summary>
        /// Searches the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="searchStrategy">The search strategy.</param>
        /// <param name="startAge">The start age.</param>
        /// <param name="endAge">The end age.</param>
        /// <param name="sortExpression">The sort expression.</param>
        /// <param name="sortDirection">The sort direction.</param>
        public static List<Resume> Search(string value,
                                                                           ISearchStrategy searchStrategy,
                                                                           int startAge,
                                                                           int endAge,
                                                                           string sortExpression,
                                                                           string sortDirection)
        {
            if (searchStrategy == null)
                throw new CustomException("Invalid search","Search arguments were lost");

            searchStrategy.SetContext = Context;

            var result = string.IsNullOrEmpty(value) ? GetResumes().ToList() :
                                                                                           searchStrategy.Search(value);
            result=Sort(result,sortExpression, sortDirection);
            result = FindByAge(result, startAge, endAge);

            return result;
        }
 public RecursiveBestFirstSearch(ISearchStrategy <A, S, T, C> search, Func <IQueue <T> > fringe)
     : base(search, fringe)
 {
 }
Пример #35
0
 protected SimpleProblemSolvingAgentBase(ISearchStrategy <TState, TAction> searchStrategy)
 {
     SearchStrategy = searchStrategy;
 }
Пример #36
0
 private void InitSearch()
 {
     this.Search = new SearchElement();
 }
Пример #37
0
		void UpdateSearch()
		{
			messageView.IsOpen = false;
			strategy = SearchStrategyFactory.Create(searchPattern ?? "", !MatchCase, UseRegex, WholeWords);
			DoSearch(true);
		}
Пример #38
0
		void UpdateSearch()
		{
			// only reset as long as there are results
			// if no results are found, the "no matches found" message should not flicker.
			// if results are found by the next run, the message will be hidden inside DoSearch ...
			if (renderer.CurrentResults.Any())
				messageView.IsOpen = false;
			strategy = SearchStrategyFactory.Create(SearchPattern ?? "", !MatchCase, WholeWords, UseRegex ? SearchMode.RegEx : SearchMode.Normal);
			DoSearch(true);
		}
Пример #39
0
 public void ChangeText()
 {
     fStrategy = new SearchStrategy(fWorkWindow, fView.SearchPattern.Text);
 }
Пример #40
0
		public bool Equals(ISearchStrategy other) {
			return other == this;
		}
 public bool Equals(ISearchStrategy other)
 {
   var xPath = other as XPathSearchStrategy;
   return xPath != null && xPath._xPath == this._xPath;
 }
Пример #42
0
        public void Build(ISearchStrategy strategy, ITextIterator it, SearchOptions options)
        {
            int startPos = it.Position;
            it.Reset ();

            ISearchResult res = strategy.FindNext (it, options, false);
            while (res != null) {
                matches.Add (res);
                res = strategy.FindNext (it, options, false);
            }
            it.Position = startPos;
        }