Exemple #1
0
        public static bool IsContextBaseClass(this IDeclaredElement element)
        {
            var clazz = element as IClass;

            if (clazz == null)
            {
                return(false);
            }

            var contextBaseCandidate = !element.IsContext() &&
                                       clazz.IsValid() &&
                                       clazz.GetContainingType() == null &&
                                       clazz.GetAccessRights() == AccessRights.PUBLIC;

            if (!contextBaseCandidate)
            {
                return(false);
            }

            IFinder finder       = clazz.GetManager().Finder;
            var     searchDomain = clazz.GetSearchDomain();

            var findResult = new InheritedContextFinder();

            finder.FindInheritors(clazz,
                                  searchDomain,
                                  findResult.Consumer,
                                  NullProgressIndicator.Instance);

            return(findResult.Found);
        }
Exemple #2
0
        public static bool IsContextBaseClass(this IDeclaredElement element)
        {
            var clazz = element as IClass;

            if (clazz == null)
            {
                return(false);
            }

            var contextBaseCandidate = !element.IsContext() &&
                                       clazz.IsValid() &&
                                       clazz.GetContainingType() == null;

            if (!contextBaseCandidate)
            {
                return(false);
            }

#if RESHARPER_6
            IFinder finder = clazz.GetSolution().GetPsiServices().Finder;
#else
            IFinder finder = clazz.GetManager().Finder;
#endif
            var searchDomain = clazz.GetSearchDomain();

            var findResult = new InheritedContextFinder();

            finder.FindInheritors(clazz,
                                  searchDomain,
                                  findResult.Consumer,
                                  NullProgressIndicator.Instance);

            return(findResult.Found);
        }
Exemple #3
0
 private void InitializeFinder()
 {
     Finder = new Finder();
     Finder.StateChanged    += Finder_StateChanged;
     Finder.ProgressChanged += Finder_ProgressChanged;
     tbState.Text            = Finder.State.ToString();
 }
Exemple #4
0
        private void RunFinders(string searchRegexText, string outputDirectoryRoot)
        {
            foreach (KeyValuePair <IFinder, List <string> > keyValuePair in _iFinderToFileName)
            {
                IFinder       finder          = keyValuePair.Key;
                List <string> filesToSearchIn = keyValuePair.Value;
                Logger.Info($"Running finder {finder.GetName()}");
                foreach (string filename in filesToSearchIn)
                {
                    bool?textFound = false;
                    Logger.Debug($"Searching in file {filename}");
                    Dispatcher.Invoke(() => { textFound = finder.Search(filename, searchRegexText); });
                    if (textFound != null && textFound.Value)
                    {
                        finder.FileFound(filename, outputDirectoryRoot);
                    }

                    _totalNumberOfFilesSoFar++;
                    Dispatcher.Invoke(() =>
                    {
                        progressBar.Value = ((double)_totalNumberOfFilesSoFar / _totalNumberOfFilesToSearch) * 100;
                    });
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Esegue il sort di una colonna nella griglia.
        /// Reperisco dalla griglia il nome della colonna da ordinare.
        /// Creo l'espressione Lambda corretta e la inserisco nel finder e poi lo persisto nella sessione.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="THeader"></typeparam>
        /// <param name="e"></param>
        public void FinderSorting <T, THeader>(GridSortCommandEventArgs e)
        {
            // TODO: verificare gli ordinamenti sui campi dell'entità Header. In questo momento l'ordinamento funziona solo se il campo è settato sull'entità padre

            IFinder <T, THeader> finderToExecute = Finder as IFinder <T, THeader>;

            finderToExecute.SortExpressionsClear();
            SortDirection sortOrder;

            if (e.NewSortOrder == GridSortOrder.None && e.OldSortOrder == GridSortOrder.Descending)
            {
                sortOrder = SortDirection.Descending;
            }
            else
            {
                sortOrder = e.NewSortOrder == GridSortOrder.Ascending ? SortDirection.Ascending : SortDirection.Descending;
            }

            string parameterName = e.SortExpression;
            ParameterExpression            param = Expression.Parameter(typeof(T), "x");
            Expression <Func <T, object> > expr  = Expression.Lambda <Func <T, object> >(Expression.Convert(Expression.Property(param, parameterName), typeof(object)), param);

            finderToExecute.SortExpressions.Add(new SortExpression <T>()
            {
                Expression = expr, Direction = sortOrder
            });
            Finder = finderToExecute;

            PersistFinder();
        }
Exemple #6
0
        public void Init(bool isFirstGame = true)
        {
            SetState(GameState.Ready);
            System.Diagnostics.Debug.WriteLine("Start");
            totalElapsedSeconds = 0;
            drawer = Context.Instance.Drawer;

            IMazeGenerator generator = new RecursiveGenerator();

            maze = generator.Generate(Context.Instance.TileWidth, Context.Instance.TileHeight);

            world = new World();
            world.Init(maze, Context.Instance.ScreenWidth - H_OFFSET, Context.Instance.ScreenHeight - V_OFFSET, 10, H_OFFSET / 2);
            centerPoint = world.FindCenterPoint();

            pathFinder = new AStarFinder();
            pathFinder.Init(maze.Tiles, Context.Instance.TileWidth);

            InitWalls();
            InitFood();
            InitCharacters();

            InitDirectionButtons();
            InitFunctionalButtons();
            InitText();
        }
Exemple #7
0
        private void ReplaceMethodToAsync(IFinder finder, IPsiModule psiModule, CSharpElementFactory factory, IMethodDeclaration method)
        {
            if (!method.IsValid())
            {
                return;
            }

            var methodDeclaredElement = method.DeclaredElement;

            if (methodDeclaredElement == null)
            {
                return;
            }

            var usages = finder.FindAllReferences(methodDeclaredElement);

            foreach (var usage in usages)
            {
                var invocation = usage.GetTreeNode().Parent as IInvocationExpression;
                var containingFunctionDeclarationIgnoringClosures = invocation?.InvokedExpression.GetContainingFunctionDeclarationIgnoringClosures();
                if (containingFunctionDeclarationIgnoringClosures == null)
                {
                    continue;
                }
                AsyncHelper.ReplaceCallToAsync(invocation, factory, containingFunctionDeclarationIgnoringClosures.IsAsync);
            }
            var invocationExpressions = method.Body.Descendants <IInvocationExpression>();

            foreach (var invocationExpression in invocationExpressions)
            {
                AsyncHelper.TryReplaceInvocationToAsync(invocationExpression, factory, psiModule);
            }

            AsyncHelper.ReplaceMethodSignatureToAsync(methodDeclaredElement, psiModule, method);
        }
Exemple #8
0
 public HircineOracle(IFinder finder, List<WeightedMetric> metric, int lookupDepth, int lookupWidth)
 {
     this.finder = finder;
     this.metric = metric;
     this.lookupDepth = lookupDepth;
     this.lookupWidth = lookupWidth;
 }
Exemple #9
0
 /// <summary>
 /// Inizializza il conteggio delle righe in griglia
 /// </summary>
 /// <param name="finderToExecute"></param>
 private void InitializeVirtualItemCount(IFinder finderToExecute)
 {
     if (VirtualItemCount == 0)
     {
         VirtualItemCount = FinderExecuteCount(finderToExecute);
     }
 }
Exemple #10
0
 public MagicDfsFinder(Phrases phrases, int maxDepth = 3)
 {
     this.phrases = phrases;
     this.maxDepth = maxDepth;
     dfsFinder = new HackedDfsFinder(phrases);
     allSpells = phrases.AsDirections.Reverse().ToArray();
 }
Exemple #11
0
        /// <summary>
        /// Gets a reference to the generic "FindBy" method of the given finder
        /// for the given message type using a hashtable lookup rather than reflection.
        /// </summary>
        /// <param name="finder"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static MethodInfo GetFindByMethodForFinder(IFinder finder, object message)
        {
            MethodInfo result = null;

            IDictionary <Type, MethodInfo> methods;

            FinderTypeToMessageToMethodInfoLookup.TryGetValue(finder.GetType(), out methods);

            if (methods != null)
            {
                methods.TryGetValue(message.GetType(), out result);

                if (result == null)
                {
                    foreach (Type messageType in methods.Keys)
                    {
                        if (messageType.IsInstanceOfType(message))
                        {
                            result = methods[messageType];
                        }
                    }
                }
            }

            return(result);
        }
Exemple #12
0
        /// <summary>
        /// Esegue la ricerca attraverso il finder interno eseguendo anche il count dei risultati totali
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="THeader"></typeparam>
        public void DataBindFinder <T, THeader>()
        {
            IFinder <T, THeader> finderToExecute = Finder as IFinder <T, THeader>;

            if (finderToExecute == null)
            {
                return;
            }
            ICollection <THeader> results = FinderExecuteDoSearchHeader <T, THeader>();

            DataSource = results;

            if (results != null)
            {
                InitializeVirtualItemCount(Finder);

                if (((MasterTableView.GroupByExpressions.Count > 0) || IsGrouping))
                {
                    CurrentPageIndex = 0;
                }
                //TODO: Inserire l'ordinamento qui per la parte di esportazione
            }

            DataBind();
        }
Exemple #13
0
        /// <summary>
        /// Pulisce la sessione dal finder
        /// </summary>
        public void DiscardFinder()
        {
            string identifier = GetFinderSessionIdentifier();

            HttpContext.Current.Session[identifier] = null;
            _finder = null;
        }
Exemple #14
0
        /// <summary>
        /// Questo metodo mi permette di isolare la gestione della ricerca e di settare il finder nella property.
        /// Questo metodo viene delegato allo sviluppatore. E' necessario implementarlo per eseguire il DoSearchHeader.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="THeader"></typeparam>
        /// <returns></returns>
        public ICollection <THeader> FinderExecuteDoSearchHeader <T, THeader>()
        {
            IFinder <T, THeader> finderToExecute = null;

            try
            {
                finderToExecute = Finder as IFinder <T, THeader>;
                if (finderToExecute != null)
                {
                    if (ImpersonateCurrentUser)
                    {
                        return(ExecuteSearchWithImpersonation <ICollection <THeader> >(finderToExecute.DoSearchHeader));
                    }
                    else
                    {
                        return(finderToExecute.DoSearchHeader());
                    }
                }
                return(new List <THeader>());
            }
            catch (Exception ex)
            {
                PrintSearchException(ex);
                FileLogger.Warn(LogName.FileLog, String.Format("Errore nell'uso del finder [{0}]", finderToExecute.GetType()), ex);
                return(null);
            }
        }
Exemple #15
0
        public override bool Load()
        {
            dataBook = (DataBook)GetDataBook(mainWindow);

            // create the finder object
            ProgressDialog findProgressDialog = new ProgressDialog("", mainWindow);

            finder            = new DataBookFinder(dataBook, findProgressDialog.Update);
            finder.Strategy   = new BMFindStrategy();
            finder.FirstFind += OnFirstFind;

            // create the FindReplaceWidget (hidden)
            widget         = new FindReplaceWidget(dataBook, finder);
            widget.Visible = false;

            WidgetGroup wgroup = (WidgetGroup)GetWidgetGroup(mainWindow, 0);

            wgroup.Add(widget);

            // add the menu items
            AddActions(uiManager);

            dataBook.PageAdded   += new DataView.DataViewEventHandler(OnDataViewAdded);
            dataBook.PageRemoved += new DataView.DataViewEventHandler(OnDataViewRemoved);
            dataBook.SwitchPage  += new SwitchPageHandler(OnSwitchPage);

            loaded = true;
            return(true);
        }
Exemple #16
0
        static void Main(string[] args)
        {
            DisplayBanner();
            if (args.Length < 1)
            {
                DisplayHelp();
                return;
            }

            IIocContainer iocContainer = InitializeIocContainer();

            ReadOnlyControlFile    control         = new ReadOnlyControlFile(args[0]);
            IFinder                finder          = iocContainer.Resolve <IFinder>();
            ICopier                copier          = iocContainer.Resolve <ICopier>();
            IUnwantedFileRemover   remover         = iocContainer.Resolve <IUnwantedFileRemover>();
            IUnwantedFolderRemover folderRemover   = iocContainer.Resolve <IUnwantedFolderRemover>();
            IFileUtilities         fileUtilities   = iocContainer.Resolve <IFileUtilities>();
            IPathUtilities         pathUtilities   = iocContainer.Resolve <IPathUtilities>();
            IPlaylistFactory       playlistFactory = iocContainer.Resolve <IPlaylistFactory>();

            Generator generator = new Generator(finder, fileUtilities, pathUtilities, playlistFactory);

            generator.StatusUpdate += new EventHandler <StatusUpdateEventArgs>(StatusUpdate);

            Synchronizer synchronizer = new Synchronizer(finder, copier, remover, folderRemover);

            synchronizer.StatusUpdate += new EventHandler <StatusUpdateEventArgs>(StatusUpdate);

            synchronizer.Synchronize(control, false);

            if (!string.IsNullOrEmpty(control.GetPlaylistFileName()))
            {
                generator.GeneratePlaylist(control, true);
            }
        }
        /// <summary>
        ///     Gets a reference to the generic "FindBy" method of the given finder
        ///     for the given message type using a hashtable lookup rather than reflection.
        /// </summary>
        public MethodInfo GetFindByMethodForFinder(IFinder finder, object message)
        {
            MethodInfo result = null;

            Dictionary<Type, MethodInfo> methods;
            FinderTypeToMessageToMethodInfoLookup.TryGetValue(finder.GetType(), out methods);

            if (methods != null)
            {
                methods.TryGetValue(message.GetType(), out result);

                if (result == null)
                {
                    foreach (var messageTypePair in methods)
                    {
                        if (messageTypePair.Key.IsInstanceOfType(message))
                        {
                            result = messageTypePair.Value;
                        }
                    }
                }
            }

            return result;
        }
Exemple #18
0
 public void EnsureUpRelations(object Sender, Type ClassType, IFinder Finder)
 {
     foreach (MongoRelation relation in GetUpRelations(ClassType))
     {
         CheckRelation(Sender, relation, true);
     }
 }
Exemple #19
0
        public FindReplaceWidget(DataBook db, IFinder iFinder)
        {
            finder   = iFinder;
            dataBook = db;

            Gtk.Builder builder = new Gtk.Builder();
            builder.AddFromFile(FileResourcePath.GetDataPath("ui", "FindReplacePlugin.ui"));
            builder.Autoconnect(this);

            this.Shown += OnWidgetShown;
            SearchPatternEntry.Activated  += OnSearchPatternEntryActivated;
            ReplacePatternEntry.Activated += OnReplacePatternEntryActivated;

            SearchPatternEntry.FocusGrabbed  += OnFocusGrabbed;
            ReplacePatternEntry.FocusGrabbed += OnFocusGrabbed;

            SearchAsComboBox.Active  = 0;
            ReplaceAsComboBox.Active = 0;

            SearchPatternEntry.Completion            = new EntryCompletion();
            SearchPatternEntry.Completion.Model      = new ListStore(typeof(string));
            SearchPatternEntry.Completion.TextColumn = 0;

            ReplacePatternEntry.Completion            = new EntryCompletion();
            ReplacePatternEntry.Completion.Model      = new ListStore(typeof(string));
            ReplacePatternEntry.Completion.TextColumn = 0;

            // initialize replace pattern
            replacePattern = new byte[0];

            this.Add(FindReplaceTable);
            this.ShowAll();
        }
Exemple #20
0
 public static IEnumerable<OracleSuggestion> GetReachableSugessions(IFinder finder, Map map)
 {
     return
         finder.GetReachablePositions(map)
               .Select(m => TryGetSugession(m, m.Unit))
               .Where(s => s != null);
 }
Exemple #21
0
 public void RecursiveFile()
 {
     _finder = new Finder("..\\..\\..\\Modules\\Debug", true);
     FileInfo t = new FileInfo("E:\\Projects\\VS\\Warframe Activity Manager\\Modules\\Debug\\WAM.Modules.AlertScanner.dll");
     FileInfo f = _finder.FindFile("WAM.Modules.*.dll");
     Assert.AreEqual(t.FullName, f.FullName, "FileInfo comparison failed : \r\n Tested : {0} \r\n Finder : {1}\r\n", t.FullName, f.FullName);
 }
Exemple #22
0
 public void RecursiveFiles()
 {
     _finder = new Finder("..\\..\\..\\Modules\\Debug", true);
     List<String> lt = new List<String>(Directory.GetFiles("E:\\Projects\\VS\\Warframe Activity Manager\\Modules\\Debug", "WAM.Modules.*.dll", SearchOption.AllDirectories));
     List<FileInfo> lf = _finder.FindFiles("WAM.Modules.*.dll");
     Assert.AreEqual(lt.Count, lf.Count, "File List comparison failed : \r\n Tested : {0} \r\n Finder : {1}\r\n", lt.Count, lf.Count);
 }
Exemple #23
0
        public FindReplaceWidget(DataBook db, IFinder iFinder)
        {
            finder   = iFinder;
            dataBook = db;

            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "FindReplaceTable", "bless");
            gxml.Autoconnect(this);

            this.Shown += OnWidgetShown;
            SearchPatternEntry.Activated  += OnSearchPatternEntryActivated;
            ReplacePatternEntry.Activated += OnReplacePatternEntryActivated;

            SearchPatternEntry.FocusGrabbed  += OnFocusGrabbed;
            ReplacePatternEntry.FocusGrabbed += OnFocusGrabbed;

            SearchAsComboBox.Active  = 0;
            ReplaceAsComboBox.Active = 0;

            SearchPatternEntry.Completion            = new EntryCompletion();
            SearchPatternEntry.Completion.Model      = new ListStore(typeof(string));
            SearchPatternEntry.Completion.TextColumn = 0;

            ReplacePatternEntry.Completion            = new EntryCompletion();
            ReplacePatternEntry.Completion.Model      = new ListStore(typeof(string));
            ReplacePatternEntry.Completion.TextColumn = 0;

            // initialize replace pattern
            replacePattern = new byte[0];

            this.Add(FindReplaceTable);
            this.ShowAll();
        }
Exemple #24
0
 public void SetFinder(IFinder finder)
 {
     _finder        = finder;
     _finder.Step  += LoopWraper;
     _finder.End   += EndWraper;
     _finder.Start += StartWraper;
 }
Exemple #25
0
 private void CleanFinder()
 {
     lvMain.ItemsSource      = null;
     Finder.StateChanged    -= Finder_StateChanged;
     Finder.ProgressChanged -= Finder_ProgressChanged;
     (Finder as IDisposable)?.Dispose();
     Finder = null;
 }
Exemple #26
0
 public ManagerModules(IEnumerable <String> paths)
 {
     if (paths == null || paths.Count() == 0)
     {
         throw new ArgumentException("ManagerModules : Path list empty");
     }
     _finder = new Finder(paths, true);
 }
 private static IEnumerable <IMethod> InnerFindBaseMethods([NotNull] IFinder finder, [NotNull] IMethod method, [NotNull] IProgressIndicator pi)
 {
     return(finder
            .FindImmediateBaseElements(method, pi)
            .OfType <IMethod>()
            .SelectMany(innerMethod => innerMethod.FindBaseMethods())
            .Concat(new[] { method }));
 }
 public void BuildParserUtilities(List <string> ALLOWED_STYLES, string CLEN_NASLOV, string ODSTAVEK_NASLOV, string ALINEJA_NASLOV, string CRTA,
                                  IValidator validator, IConverter converter, IFinder finder)
 {
     this.ParserUtilities           = new ParserUtilities(ALLOWED_STYLES, CLEN_NASLOV, ODSTAVEK_NASLOV, ALINEJA_NASLOV, CRTA);
     this.ParserUtilities.Converter = converter;
     this.ParserUtilities.Finder    = finder;
     this.ParserUtilities.Validator = validator;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="parameter"></param>
 /// <returns></returns>
 public Book FindBook(IFinder parameter)
 {
     if (ReferenceEquals(parameter, null))
     {
         throw new ArgumentNullException();
     }
     return(parameter.FindBookByTeg());
 }
Exemple #30
0
 public Program(IFinder <ICommand> cmdFinder, string[] appArguments, IFileReader fileReader)
 {
     _displayManager    = new DisplayManager();
     _commandFinder     = cmdFinder;
     _fileReader        = fileReader;
     _availableCommands = cmdFinder.FindAll().ToDictionary(cmd => cmd.CliCommandName);
     AddHelpCommand();
 }
Exemple #31
0
        public void RecursiveFiles()
        {
            _finder = new Finder("..\\..\\..\\Modules\\Debug", true);
            List <String>   lt = new List <String>(Directory.GetFiles("E:\\Projects\\VS\\Warframe Activity Manager\\Modules\\Debug", "WAM.Modules.*.dll", SearchOption.AllDirectories));
            List <FileInfo> lf = _finder.FindFiles("WAM.Modules.*.dll");

            Assert.AreEqual(lt.Count, lf.Count, "File List comparison failed : \r\n Tested : {0} \r\n Finder : {1}\r\n", lt.Count, lf.Count);
        }
Exemple #32
0
        public void RecursiveFile()
        {
            _finder = new Finder("..\\..\\..\\Modules\\Debug", true);
            FileInfo t = new FileInfo("E:\\Projects\\VS\\Warframe Activity Manager\\Modules\\Debug\\WAM.Modules.AlertScanner.dll");
            FileInfo f = _finder.FindFile("WAM.Modules.*.dll");

            Assert.AreEqual(t.FullName, f.FullName, "FileInfo comparison failed : \r\n Tested : {0} \r\n Finder : {1}\r\n", t.FullName, f.FullName);
        }
Exemple #33
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="finder"> finder, incapsulate find logic by tag </param>
 /// <param name="tag"> name of tag </param>
 /// <returns> fiended book </returns>
 public Book FindByTag(IFinder <Book> finder, object tag)
 {
     if (ReferenceEquals(finder, null))
     {
         throw new ArgumentNullException(nameof(finder));
     }
     return(bookList.Find(finder.Find(tag)));
 }
Exemple #34
0
        private static async Task ExecuteQuery(IFinder finder, URLClassifier classifier, string query)
        {
            try
            {
                var urls = await finder.FindSuggestions(query);

                var entityFinder = new EntityFinder();
                Console.WriteLine("============ Web searches");
                var classificationTasks = urls
                                          .Select(url => classifier.ClassifyOutletDescription(ExtractDomain(url)))
                                          .ToArray();
                var classifications = await Task.WhenAll(classificationTasks);

                for (int i = 0; i < urls.Count; i++)
                {
                    Console.WriteLine($"  [{classifications[i].BiasType}] ({ExtractDomain(urls[i])}) {urls[i]}");
                }

                Console.WriteLine();
                Console.WriteLine("=========== Entities");
                var entities = await entityFinder.GetEntities(query);

                foreach (var entity in entities)
                {
                    var entityName        = entityFinder.ExtractEntityName(entity);
                    var wikiUrl           = entityFinder.ExtractEntityWikiUrl(entity);
                    var politifactPersona = entityFinder.GetPolitifactPersona(entity);
                    var politifactStr     = politifactPersona != null
                        ? politifactPersona.GetFullUrl()
                        : "none found";

                    var party = politifactPersona != null
                        ? "(" + politifactPersona.Party + ")"
                        : "";
                    Console.WriteLine($"  '{entityName}' {party}");
                    Console.WriteLine($"    - wiki: {wikiUrl}");
                    Console.WriteLine($"    - politifact: {politifactStr}");
                    if (politifactPersona != null)
                    {
                        Console.WriteLine($"    - recent statements:");
                        var statements = await politifactPersona.FetchRecentStatements();

                        foreach (var grp in statements.GroupBy(s => s.Ruling).OrderByDescending(grp => grp.Count()))
                        {
                            Console.WriteLine($"      - {grp.Key}: {grp.Count()}");
                        }
                    }
                }
            }
            catch (WebException e)
            {
                var errorMessage = e.Response != null
                    ? await CognitiveServicesFinder.ReadAllAsync(e.Response.GetResponseStream())
                    : e.Message;

                Console.WriteLine(errorMessage);
            }
        }
Exemple #35
0
        /// <summary>
        /// Find by the id.
        /// </summary>
        /// <typeparam name="TEntity">The type of the entity.</typeparam>
        /// <param name="finder">The finder.</param>
        /// <param name="id">The entity id.</param>
        /// <returns>The entity with specified id.</returns>
        public static TEntity ById <TEntity>(this IFinder <TEntity> finder, int id) where TEntity : BaseEntity
        {
            Check.Require <ArgumentNullException>(
                finder != null, "Unable find entity by id because argument finder is null");

            TEntity entity = finder.One(CommonSpecifications.ById <TEntity>(id));

            return(entity);
        }
Exemple #36
0
 public Solver(Phrases phrases, IFinder finder, IOracle oracle, int bestSugessionsCount = 20, double metricEpsilon = 1)
 {
     this.phrases = phrases;
     Finder = finder;
     Oracle = oracle;
     this.bestSugessionsCount = bestSugessionsCount;
     this.metricEpsilon = metricEpsilon;
     Name = oracle.GetType().Name + "-" + finder.GetType().Name;
 }
        /// <summary>
        /// Finds a book by tag.
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns>Book</returns>
        public Book FindBookByTag(IFinder parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException();
            }

            return(parameter.FindBook());
        }
Exemple #38
0
 public InstallationManager(IHost host, IContentTypeManager contentTypeManager, Importer importer, IPersister persister,
     IFinder finder, ICredentialService credentialService, AdminSection adminConfig)
 {
     _host = host;
     _contentTypeManager = contentTypeManager;
     _importer = importer;
     _persister = persister;
     _finder = finder;
     _credentialService = credentialService;
     _adminConfig = adminConfig;
 }
Exemple #39
0
        /// <summary>
        /// Gets a reference to the generic "FindBy" method of the given finder
        /// for the given message type using a hashtable lookup rather than reflection.
        /// </summary>
        /// <param name="finder"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static MethodInfo GetFindByMethodForFinder(IFinder finder, IMessage message)
        {
            MethodInfo result = null;

            IDictionary<Type, MethodInfo> methods;
            FinderTypeToMessageToMethodInfoLookup.TryGetValue(finder.GetType(), out methods);

            if (methods != null)
            {
                methods.TryGetValue(message.GetType(), out result);

                if (result == null)
                    foreach (Type messageType in methods.Keys)
                        if (messageType.IsAssignableFrom(message.GetType()))
                            result = methods[messageType];
            }

            return result;
        }
Exemple #40
0
 public TagService(IFinder tagFinder, IContentTypeManager contentTypeManager, IPersister persister)
 {
     _tagFinder = tagFinder;
     _contentTypeManager = contentTypeManager;
     _persister = persister;
 }
Exemple #41
0
 /// <summary>
 /// Registers an IFinder.
 /// </summary>
 public static void AddFinder(IFinder finder)
 {
     LST_FINDERS.Add(finder);
 }
Exemple #42
0
        /// <summary>
        /// Gets the saga type to instantiate and invoke if an existing saga couldn't be found by
        /// the given finder using the given message.
        /// </summary>
        /// <param name="message"></param>
        /// <param name="finder"></param>
        /// <returns></returns>
        public static Type GetSagaTypeToStartIfMessageNotFoundByFinder(IMessage message, IFinder finder)
        {
            Type sagaEntityType;
            FinderTypeToSagaEntityTypeLookup.TryGetValue(finder.GetType(), out sagaEntityType);

            if (sagaEntityType == null)
                return null;

            Type sagaType;
            SagaEntityTypeToSagaTypeLookup.TryGetValue(sagaEntityType, out sagaType);

            if (sagaType == null)
                return null;

            List<Type> messageTypes;
            SagaTypeToMessagTypesRequiringSagaStartLookup.TryGetValue(sagaType, out messageTypes);

            if (messageTypes == null)
                return null;

            if (messageTypes.Contains(message.GetType()))
                return sagaType;

            foreach (Type msgTypeHandleBySaga in messageTypes)
                if (msgTypeHandleBySaga.IsAssignableFrom(message.GetType()))
                    return sagaType;

            return null;
        }
Exemple #43
0
 public MephalaOracle(IFinder finder, List<WeightedMetric> metrics)
 {
     this.metrics = metrics;
     this.finder = finder;
 }
Exemple #44
0
        private void Setup()
        {
            world = CreateWorld(new SystemA(), new SystemBC());
            finder = world.EntityFinder;

            Entity entity = world.CreateEntity();
            entity.Add(new ComponentA());
            entity.Add(new ComponentB());

            entity = world.CreateEntity();
            entity.Add(new ComponentA());

            entity = world.CreateEntity();
            entity.Add(new ComponentA());

            entity = world.CreateEntity();
            entity.Add(new ComponentB());

            entity = world.CreateEntity();
            entity.Add(new ComponentB());

            entity = world.CreateEntity();
            entity.Add(new ComponentA());
            entity.Add(new ComponentB());

            entity = world.CreateEntity();
            entity.Add(new ComponentA());
            entity.Add(new ComponentB());
        }
Exemple #45
0
 public void RecursivePath()
 {
     _finder = new Finder("..\\..\\..\\Modules\\Debug", true);
     Assert.AreEqual("..\\..\\..\\Modules\\Debug", _finder.Paths[0], "Path comparison failed : \r\n Tested : {0} \r\n Finder : {1}\r\n", "..\\..\\..\\Modules\\Debug", _finder.Paths[0]);
 }
        static IContainSagaData UseFinderToFindSaga(IFinder finder, object message)
        {
            MethodInfo method = Features.Sagas.GetFindByMethodForFinder(finder, message);

            if (method != null)
                return method.Invoke(finder, new [] { message }) as IContainSagaData;

            return null;
        }
Exemple #47
0
 public EventProcessor(IFinder<IHandleEvent, Type> finder)
 {
     _finder = finder;
 }
        static ISagaEntity UseFinderToFindSaga(IFinder finder, object message)
        {
            MethodInfo method = Configure.GetFindByMethodForFinder(finder, message);

            if (method != null)
                return method.Invoke(finder, new object[] { message }) as ISagaEntity;

            return null;
        }
Exemple #49
0
 public VersionManager(IRepository<int, ContentItem> itemRepository, IFinder finder)
 {
     _itemRepository = itemRepository;
     _finder = finder;
 }
Exemple #50
0
 public FindOptions()
 {
     Text = string.Empty;
     CustomFinders = new IFinder[0];
 }
 public ParkingSessionReadModel(IFinder finder, IMappingEngine mappingEngine)
 {
     _finder = finder;
     _mappingEngine = mappingEngine;
 }
 public ShoppingBasketService(IPersister persister, IWebContext webContext, IFinder finder)
 {
     _persister = persister;
     _webContext = webContext;
     _finder = finder;
 }
Exemple #53
0
 public Finder(ITextBuffer document, IFinder impl)
 {
     this.document = document;
     this.impl = impl;
 }