public static List<DirectoryEntry> Search(string rootDistinguishedName, string filter, SearchScope scope, LDAPSupportSettings settings) { DirectoryEntry de; var type = AuthenticationTypes.ReadonlyServer | AuthenticationTypes.Secure; if (settings.PortNumber == Constants.SSL_LDAP_PORT) { type |= AuthenticationTypes.SecureSocketsLayer; } string password; try { password = new UnicodeEncoding().GetString(InstanceCrypto.Decrypt(settings.PasswordBytes)); } catch (Exception) { password = string.Empty; } de = settings.Authentication ? CreateDirectoryEntry(rootDistinguishedName, settings.Login, password, type) : CreateDirectoryEntry(rootDistinguishedName); if (de != null) { return Search(de, filter, scope); } else { return null; } }
public IEnumerable<IDirectory> Directories(string filter, SearchScope scope) { Contract.Requires(filter != null); Contract.Ensures(Contract.Result<IEnumerable<IDirectory>>() != null); throw new NotImplementedException(); }
public void Replace(string textToFind, string textToReplace, Document doc, SearchFlags flags, SearchScope scope, int startPosition, int endPosition) { var ed = App.Editor(doc.GetType()) as ITextEditor; if (lastSettings != null && (lastSettings.LastDocument != doc || ed.SelectionStart != lastSettings.LastStartPosition || ed.SelectionEnd != lastSettings.LastEndPosition)) lastSettings = null; if (lastSettings != null) { ed.ReplaceText(lastSettings.LastStartPosition, lastSettings.LastEndPosition, lastSettings.TextToReplace); lastSettings.LastEndPosition = lastSettings.LastStartPosition + lastSettings.TextToReplace.Length; } var res = Search(textToFind, doc, flags, scope, (d,r) => { var editor = (ITextEditor)App.GetService<IEditorService>().GetEditor(d.GetType()).Instance; var docServ = App.GetService<IDocumentService>(); if (docServ.GetActiveDocument() != d) docServ.SetActiveDocument(d); editor.SelectText(r.StartPosition, r.EndPosition - r.StartPosition); lastSettings.LastStartPosition = r.StartPosition; lastSettings.TextToReplace = textToReplace; var sci = editor.Control as ScintillaControl; if (sci != null) sci.PutArrow(sci.GetLineFromPosition(r.StartPosition)); return true; }, false, lastSettings != null ? lastSettings.LastEndPosition : startPosition, endPosition, null); IsFinished(res); }
//-------------------------------------------------------------------------------------------------- // メインウィンドウ左側描画領域. // 検索条件などを指定する領域. private void drawMainLeftElem() { EditorGUILayout.BeginVertical( GUI.skin.box, GUILayout.Width( MAIN_LEFT_ELEM_WIDTH ) ); this.searchType = ( SearchType )EditorGUILayout.EnumPopup( "検索タイプ", this.searchType ); this.searchScope = ( SearchScope )EditorGUILayout.EnumPopup( "検索範囲", this.searchScope ); this.wholeWord = EditorGUILayout.Toggle( "完全一致か否か.", this.wholeWord ); if ( !this.wholeWord ) this.caseSencitive = EditorGUILayout.Toggle( "大小文字一致比較.", this.caseSencitive ); switch ( this.searchType ){ case SearchType.Name: EditorGUILayout.LabelField( "Input ObjectName" ); break; case SearchType.Component: EditorGUILayout.LabelField( "Input ComponentName" ); break; default: break; } this.searchText = EditorGUILayout.TextField( this.searchText, GUI.skin.textField ); if ( GUILayout.Button( "Search" ) ){ Debug.Log( "捜索します." ); this.search(); } MyEditorLayout.space( 3 ); MyEditorLayout.separatorLine( MAIN_LEFT_ELEM_WIDTH ); this.dumpFoldout = EditorGUILayout.Foldout( this.dumpFoldout, "Show Dump Palameter" ); if ( this.dumpFoldout ) this.drawDumpPalameter(); EditorGUILayout.EndVertical(); }
public SearchRequest() { this.directoryAttributes = new StringCollection(); this.directoryScope = SearchScope.Subtree; this.directoryTimeLimit = new TimeSpan(0L); this.directoryAttributes = new StringCollection(); }
public ADSearcher(DirectoryEntry searchRoot, string filter, string[] propertiesToLoad, SearchScope scope) { this.searcher = new DirectorySearcher(searchRoot, filter, propertiesToLoad, scope); this.searcher.CacheResults = false; this.searcher.ClientTimeout = defaultTimeSpan; this.searcher.ServerPageTimeLimit = defaultTimeSpan; this.searcher.PageSize = 0x200; }
public virtual IDirectorySearcher CreateSearcher(IEntry entry, SearchScope searchScope, IEntryConfig entryConfig) { var searcher = CreateSearcher(entry, searchScope, entryConfig.RdnAttribute); searcher.PropertiesToLoad.Add(entryConfig.RdnAttribute); foreach(var attribute in entryConfig.Attributes) { searcher.PropertiesToLoad.Add(attribute.Name); } return searcher; }
public static void Run(SearchScope scope) { // Allow the menu to close Application.DoEvents(); using(AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:Hornung.ResourceToolkit.FindMissingResourceKeys}")) { FindReferencesAndRenameHelper.ShowAsSearchResults(StringParser.Parse("${res:Hornung.ResourceToolkit.ReferencesToMissingKeys}"), ResourceRefactoringService.FindReferencesToMissingKeys(monitor, scope)); } }
private IDirectorySearcher CreateSearcher(IEntry entry, SearchScope searchScope, string rdnAttribute) { var searcher = CreateSearcher(entry, searchScope); if(serverConfig.PropertySortingSupport || serverConfig.VirtualListViewSupport) { searcher.Sort.PropertyName = rdnAttribute; searcher.Sort.Direction = SortDirection.Ascending; } return searcher; }
/// <summary> /// Specifies the scope to use when searching for files. /// </summary> /// <param name="settings">The sync settings.</param> /// <param name="scope">The scope.</param> /// <returns>The same <see cref="SyncSettings"/> instance so that multiple calls can be chained.</returns> public static SyncSettings SetSearchScope(this SyncSettings settings, SearchScope scope = SearchScope.Current) { if (settings == null) { throw new ArgumentNullException("settings"); } settings.SearchScope = scope; return settings; }
public virtual IDirectorySearcher CreateSearcher(IEntry entry, SearchScope searchScope) { var searcher = new DirectorySearcherAdapter(entry, filterBuilder); searcher.SearchRoot = entry.GetDirectoryEntry(); searcher.SearchScope = searchScope; searcher.ServerTimeLimit = serverConfig.TimeLimit; SetPageSizeIfNotDefault(searcher); SetSizeLimitIfNotDefault(searcher); searcher.PropertiesToLoad.Clear(); return searcher; }
/// <summary> /// See <see cref="DirectoryInfoUtility.GetDirectories(string, SearchScope)"/> /// </summary> /// <param name="dirSpec"></param> /// <param name="scope"></param> /// <returns></returns> public static IList<ParsedPath> GetDirectories(ParsedPath dirSpec, SearchScope scope) { IList<DirectoryInfo> dirInfos = DirectoryInfoUtility.GetDirectories(dirSpec, scope); ParsedPath[] dirs = new ParsedPath[dirInfos.Count]; for (int i = 0; i < dirInfos.Count; i++) dirs[i] = new ParsedPath(dirInfos[i].FullName, PathType.Directory); return dirs; }
/// <summary> /// See <see cref="DirectoryInfoUtility.GetFiles(string, SearchScope)"/>. /// </summary> /// <param name="fileSpec"></param> /// <param name="scope"></param> /// <returns></returns> public static IList<ParsedPath> GetFiles(ParsedPath fileSpec, SearchScope scope) { IList<FileInfo> fileInfos = DirectoryInfoUtility.GetFiles(fileSpec, scope); ParsedPath[] files = new ParsedPath[fileInfos.Count]; for (int i = 0; i < fileInfos.Count; i++) files[i] = new ParsedPath(fileInfos[i].FullName, PathType.File); return files; }
public void Replace(string textToFind, string textToReplace, Document doc, SearchFlags flags, SearchScope scope) { if (lastSettings != null) Replace(textToFind, textToReplace, doc, flags, scope, lastSettings.LastEndPosition, lastSettings.MaxPosition); else { var rootEditor = (ITextEditor)App.GetService<IEditorService>().GetEditor(doc.GetType()).Instance; var sp = scope == SearchScope.Selection ? rootEditor.SelectionStart : scope == SearchScope.Current ? rootEditor.CaretPosition : 0; var ep = scope == SearchScope.Selection ? rootEditor.SelectionEnd : 0; Replace(textToFind, textToReplace, doc, flags, scope, sp, ep); } }
public SearchRequest(string distinguishedName, XmlDocument filter, SearchScope searchScope, params string[] attributeList) : this() { this.dn = distinguishedName; if (attributeList != null) { for (int i = 0; i < attributeList.Length; i++) { this.directoryAttributes.Add(attributeList[i]); } } this.Scope = searchScope; this.Filter = filter; }
public IEnumerable<IFile> GetFiles(string filter, SearchScope scope) { var result = new List<IFile>(); var children = _fileSystem.Files.Where(x => x.Key.FullPath.StartsWith(_path.FullPath + "/", StringComparison.OrdinalIgnoreCase)); foreach (var child in children.Where(c => c.Value.Exists)) { var relative = child.Key.FullPath.Substring(_path.FullPath.Length + 1); if (!relative.Contains("/")) { result.Add(child.Value); } } return result; }
public ADSearcher(DirectoryEntry searchRoot, string filter, string[] propertiesToLoad, SearchScope scope) { _searcher = new DirectorySearcher(searchRoot, filter, propertiesToLoad, scope); // set all search preferences // don't cache the results on the client _searcher.CacheResults = false; // set the timeout to 2 minutes _searcher.ClientTimeout = s_defaultTimeSpan; _searcher.ServerPageTimeLimit = s_defaultTimeSpan; // Page Size needs to be set so that we // can get all the results even when the number of results // is greater than the server set limit (1000 in Win2000 and 1500 in Win2003) _searcher.PageSize = 512; }
public ADSearcher(DirectoryEntry searchRoot, string filter, string[] propertiesToLoad, SearchScope scope, bool pagedSearch, bool cacheResults) { this.searcher = new DirectorySearcher(searchRoot, filter, propertiesToLoad, scope); this.searcher.ClientTimeout = defaultTimeSpan; if (pagedSearch) { this.searcher.PageSize = 0x200; this.searcher.ServerPageTimeLimit = defaultTimeSpan; } if (cacheResults) { this.searcher.CacheResults = true; } else { this.searcher.CacheResults = false; } }
public ProxyResponse<SearchResponse> Search(string keywords, SearchScope scope, int pageNumber, int pageSize, string entityType = "", string includeSearchTermHighlights = "false") { OperationMethod = HttpMethod.Get; var queryArgs = new StringBuilder(); AppendQueryArg(queryArgs, ApiConstants.FilterKeywords, keywords); AppendQueryArg(queryArgs, ApiConstants.FilterSearchScope, scope.ToString("G")); AppendQueryArg(queryArgs, ApiConstants.FilterSearchTransactionType, entityType); AppendQueryArg(queryArgs, ApiConstants.FilterExampleIncludeSearchTermHighlights, includeSearchTermHighlights); bool inclPageNumber; bool inclPageSize; base.GetPaging(queryArgs, pageNumber, pageSize, out inclPageNumber, out inclPageSize); var uri = base.GetRequestUri(queryArgs.ToString(), inclDefaultPageNumber: inclPageNumber, inclDefaultPageSize: inclPageSize); return base.GetResponse<SearchResponse>(uri); }
/// <summary> /// Returns a list of files given a file search pattern. Will also search sub-directories. /// </summary> /// <param name="searchPattern">Search pattern. Can include a full or partial path and standard wildcards for the file name.</param> /// <param name="scope">The scope of the search.</param> /// <param name="baseDir">Base directory to use for partially qualified paths</param> /// <returns>An array of <c>FileInfo</c> objects for files matching the search pattern. </returns> public static IList<FileInfo> GetFiles(ParsedPath fileSpec, SearchScope scope) { ParsedPath rootPath = fileSpec.MakeFullPath(); if (scope != SearchScope.DirectoryOnly) { List<FileInfo> files = new List<FileInfo>(); if (scope == SearchScope.RecurseParentDirectories) RecursiveGetParentFiles(rootPath, ref files); else RecursiveGetSubFiles(rootPath, (scope == SearchScope.RecurseSubDirectoriesBreadthFirst), ref files); return files.ToArray(); } else { return NonRecursiveGetFiles(rootPath); } }
public List<string> FNSearch(string sql) { List<string> result = new List<string>(); SearchSQL searchSql = new SearchSQL(sql); SearchScope searchScope = new SearchScope(this._ceConn.objectStore); IRepositoryRowSet rowSet = searchScope.FetchRows(searchSql, null, null, null); if (rowSet.IsEmpty()) return null; System.Collections.IEnumerator enumerator = rowSet.GetEnumerator(); while (enumerator.MoveNext()) { IRepositoryRow row = (IRepositoryRow)enumerator.Current; Id id = row.Properties.GetProperty("Id").GetIdValue(); result.Add(id.ToString()); } return result; }
public static void Configure(NameValueCollection sections) { LdapFilter = sections["LdapFilter"]; FolderCreatePath= sections["FolderCreatePath"]; SearchBase = sections["SearchBase"]; switch (sections["SearchScope"]) { case "Base": SearchScope = SearchScope.Base; break; case "OneLevel": SearchScope = SearchScope.OneLevel; break; case "Subtree": SearchScope = SearchScope.Subtree; break; default: throw new ArgumentOutOfRangeException(); } DirectoryEntry= new DirectoryEntry(SearchBase); DomainSid= WindowsIdentity.GetCurrent().User.AccountDomainSid; }
/// <summary> /// Returns a list of directories given a file search pattern. Will also search sub-directories and /// parent directories. /// </summary> /// <param name="dirSpec">Search specification with with optional directory and wildcards</param> /// <param name="scope">The scope of the search. <see cref="SearchScope"/></param> /// <returns>An array of <c>DirectoryInfo</c> objects for files matching the search pattern. </returns> public static IList<DirectoryInfo> GetDirectories(ParsedPath dirSpec, SearchScope scope) { if (!dirSpec.HasFilename) throw new ArgumentException("Path does not have a filename"); ParsedPath rootPath = dirSpec.MakeFullPath(); if (scope != SearchScope.DirectoryOnly) { List<DirectoryInfo> dirs = new List<DirectoryInfo>(); if (scope == SearchScope.RecurseParentDirectories) RecursiveGetParentDirectories(rootPath, ref dirs); else RecursiveGetSubDirectories(rootPath, (scope == SearchScope.RecurseSubDirectoriesBreadthFirst), ref dirs); return dirs.ToArray(); } else { return NonRecursiveGetDirectories(rootPath); } }
public void Click(string value) { SearchScope.Select(value).From(Locator); }
public override bool IsAllowedScope(SearchScope scope) { return(scope == SearchScope.Forest || scope == SearchScope.Organization || scope == SearchScope.World); }
public async Task <IResultList <IContentEntity> > DoAsync(IAppEntity app, ISchemaEntity schema, ClrQuery query, SearchScope scope) { Guard.NotNull(app, nameof(app)); Guard.NotNull(schema, nameof(schema)); Guard.NotNull(query, nameof(query)); try { query = query.AdjustToModel(schema.SchemaDef); List <DomainId>?fullTextIds = null; if (!string.IsNullOrWhiteSpace(query.FullText)) { var searchFilter = SearchFilter.ShouldHaveSchemas(schema.Id); fullTextIds = await indexer.SearchAsync(query.FullText, app, searchFilter, scope); if (fullTextIds?.Count == 0) { return(ResultList.CreateFrom <IContentEntity>(0)); } } var filter = CreateFilter(schema.AppId.Id, schema.Id, fullTextIds, query); var contentCount = Collection.Find(filter).CountDocumentsAsync(); var contentItems = FindContentsAsync(query, filter); var(items, total) = await AsyncHelper.WhenAll(contentItems, contentCount); foreach (var entity in items) { entity.ParseData(schema.SchemaDef, converter); } return(ResultList.Create <IContentEntity>(total, items)); } catch (MongoCommandException ex) when(ex.Code == 96) { throw new DomainException(T.Get("common.resultTooLarge")); } catch (MongoQueryException ex) when(ex.Message.Contains("17406")) { throw new DomainException(T.Get("common.resultTooLarge")); } }
public async Task <List <DomainId>?> SearchAsync(string?queryText, IAppEntity app, SearchFilter?filter, SearchScope scope) { var serveField = GetServeField(scope); var query = new { query = new { @bool = new { must = new List <object> { new { term = new Dictionary <string, object> { ["appId.keyword"] = app.Id } }, new { term = new Dictionary <string, string> { [serveField] = "true" } }, new { multi_match = new { fields = new[] { "texts.*" }, query = queryText } } }, should = new List <object>() } }, _source = new[] { "contentId" }, size = 2000 }; if (filter?.SchemaIds.Count > 0) { var bySchema = new { terms = new Dictionary <string, object> { ["schemaId.keyword"] = filter.SchemaIds } }; if (filter.Must) { [email protected](bySchema); } else { [email protected](bySchema); } } var result = await client.SearchAsync <DynamicResponse>(indexName, CreatePost(query)); if (!result.Success) { throw result.OriginalException; } var ids = new List <DomainId>(); foreach (var item in result.Body.hits.hits) { if (item != null) { ids.Add(item["_source"]["contentId"]); } } return(ids); }
public ADSearcher(DirectoryEntry searchRoot, string filter, string[] propertiesToLoad, SearchScope scope, bool pagedSearch, bool cacheResults) { this.searcher = new DirectorySearcher(searchRoot, filter, propertiesToLoad, scope); this.searcher.ClientTimeout = ADSearcher.defaultTimeSpan; if (pagedSearch) { this.searcher.PageSize = 0x200; this.searcher.ServerPageTimeLimit = ADSearcher.defaultTimeSpan; } if (!cacheResults) { this.searcher.CacheResults = false; return; } else { this.searcher.CacheResults = true; return; } }
public IEnumerable<Directory> Directories(string filter, SearchScope scope) { return UnderlyingDirectory.Directories(filter, scope); }
public GroupGatewayRule(string path, Condition c, string addTo, string filter, SearchScope scope) : base(path, c, filter, scope) { m_localGroup = addTo; }
SearchScope FindTypeDefinitionReferences(ITypeDefinition typeDefinition, bool findTypeReferencesEvenIfAliased, out SearchScope additionalScope) { string searchTerm = null; additionalScope = null; if (!findTypeReferencesEvenIfAliased && KnownTypeReference.GetCSharpNameByTypeCode(typeDefinition.KnownTypeCode) == null) { // We can optimize the search by looking only for the type references with the right identifier, // but only if it's not a primitive type and we're not looking for indirect references (through an alias) searchTerm = typeDefinition.Name; if (searchTerm.Length > 9 && searchTerm.EndsWith("Attribute", StringComparison.Ordinal)) { // The type might be an attribute, so we also need to look for the short form: string shortForm = searchTerm.Substring(0, searchTerm.Length - 9); additionalScope = FindTypeDefinitionReferences(typeDefinition, shortForm); } } return FindTypeDefinitionReferences(typeDefinition, searchTerm); }
public async Task Should_return_content_by_id(int isFrontend, int unpublished, SearchScope scope) { var requestContext = CreateContext(isFrontend, isUnpublished: unpublished); var content = CreateContent(DomainId.NewGuid()); A.CallTo(() => contentRepository.FindContentAsync(requestContext.App, schema, content.Id, scope, A <CancellationToken> ._)) .Returns(content); var result = await sut.FindAsync(requestContext, schemaId.Name, content.Id); AssertContent(content, result); }
public Task <IContentEntity?> FindContentAsync(IAppEntity app, ISchemaEntity schema, DomainId id, SearchScope scope, CancellationToken ct = default) { if (scope == SearchScope.All) { return(collectionAll.FindContentAsync(schema, id, ct)); } else { return(collectionPublished.FindContentAsync(schema, id, ct)); } }
private static string GetServeField(SearchScope scope) { return(scope == SearchScope.Published ? "servePublished" : "serveAll"); }
public Task <IResultList <IContentEntity> > QueryAsync(IAppEntity app, ISchemaEntity schema, Q q, SearchScope scope, CancellationToken ct = default) { if (scope == SearchScope.All) { return(collectionAll.QueryAsync(app, schema, q, ct)); } else { return(collectionPublished.QueryAsync(app, schema, q, ct)); } }
/// <summary> /// Find a shortcut in the shortcut lists by modifiers and key. /// </summary> /// <param name="shortcutModifiers">The modifier of the shortcut</param> /// <param name="shortcutKey">The key of the shortcut</param> /// <param name="where">A flag to tell where the shortcut should be searched</param> /// <returns>The matching shortcut data or <c>null</c> if it is not found</returns> /// <seealso cref="findAllShortcuts"/> public ShortcutData findShortcut(ShortcutData.Modifiers shortcutModifiers, ShortcutData.Keys shortcutKey, SearchScope where = SearchScope.All) { if (mCurrentShortcutsList == mDefaultShortcutsList) return findShortcut(shortcutModifiers, shortcutKey, mCurrentShortcutsList); switch (where) { case SearchScope.AllCurrentFirst: return findShortcut(shortcutModifiers, shortcutKey, mCurrentShortcutsList.Concat(mDefaultShortcutsList).ToList()); case SearchScope.AllDefaultFirst: return findShortcut(shortcutModifiers, shortcutKey, mDefaultShortcutsList.Concat(mCurrentShortcutsList).ToList()); case SearchScope.Current: return findShortcut(shortcutModifiers, shortcutKey, mCurrentShortcutsList); case SearchScope.Default: return findShortcut(shortcutModifiers, shortcutKey, mDefaultShortcutsList); default: throw new ArgumentException("Bad value for search scope: " + where); } }
public GroupAuthzRule(string path, Condition c, bool allow, string filter, SearchScope scope) : base(path, c, filter, scope) { m_allowOnMatch = allow; }
public ADSearcher(DirectoryEntry searchRoot, string filter, string[] propertiesToLoad, SearchScope scope) { this.searcher = new DirectorySearcher(searchRoot, filter, propertiesToLoad, scope); this.searcher.CacheResults = false; this.searcher.ClientTimeout = ADSearcher.defaultTimeSpan; this.searcher.ServerPageTimeLimit = ADSearcher.defaultTimeSpan; this.searcher.PageSize = 0x200; }
public QueryFilter Execute(string searchString, bool isContentIndexingEnabled, Folder folder, SearchScope searchScope) { this.searchScope = searchScope; this.folderClass = folder.ClassName; if (searchString != null) { this.queryFilter = AqsParser.ParseAndBuildQuery(searchString, SearchFilterGenerator.GetAqsParseOption(folder, isContentIndexingEnabled), this.userCultureInfo, RescopedAll.Default, null, this.policyTagProvider); } if (this.advancedQueryFilter != null) { if (this.queryFilter == null) { this.queryFilter = this.advancedQueryFilter; } else { this.queryFilter = new AndFilter(new QueryFilter[] { this.queryFilter, this.advancedQueryFilter }); } } if (this.queryFilter == null) { return(null); } this.AddItemTypeFilter(); return(this.queryFilter); }
public SearchRequest(string distinguishedName, string ldapFilter, SearchScope searchScope, params string[] attributelist) { }
public Task <IContentEntity?> FindContentAsync(IAppEntity app, ISchemaEntity schema, DomainId id, SearchScope scope) { if (scope == SearchScope.All) { return(collectionAll.FindContentAsync(schema, id)); } else { return(collectionPublished.FindContentAsync(schema, id)); } }
public static QueryFilter Execute(string searchString, bool isContentIndexingEnabled, CultureInfo userCultureInfo, IPolicyTagProvider policyTagProvider, Folder folder, SearchScope searchScope, QueryFilter advancedQueryFilter) { SearchFilterGenerator searchFilterGenerator = new SearchFilterGenerator(advancedQueryFilter, userCultureInfo, policyTagProvider); return(searchFilterGenerator.Execute(searchString, isContentIndexingEnabled, folder, searchScope)); }
private List <DirectoryEntry> Search(string rootDistinguishedName, string filter, SearchScope scope, LDAPSupportSettings settings) { DirectoryEntry de; var type = AuthenticationTypes.ReadonlyServer | AuthenticationTypes.Secure; if (settings.PortNumber == Constants.SSL_LDAP_PORT) { type |= AuthenticationTypes.SecureSocketsLayer; } string password; try { password = new UnicodeEncoding().GetString(InstanceCrypto.Decrypt(settings.PasswordBytes)); } catch (Exception) { password = string.Empty; } de = settings.Authentication ? CreateDirectoryEntry(rootDistinguishedName, settings.Login, password, type) : CreateDirectoryEntry(rootDistinguishedName); if (de != null) { return(Search(de, filter, scope)); } else { return(null); } }
/// <summary> /// Searches for extension methods exactly called 'GetAwaiter'. Returns /// <see cref="SymbolReference"/>s to the <see cref="INamespaceSymbol"/>s that contain /// the static classes that those extension methods are contained in. /// </summary> private async Task <ImmutableArray <SymbolReference> > GetReferencesForGetAwaiterAsync(SearchScope searchScope) { searchScope.CancellationToken.ThrowIfCancellationRequested(); if (_owner.CanAddImportForGetAwaiter(_diagnosticId, _syntaxFacts, _node)) { var type = _owner.GetAwaitInfo(_semanticModel, _syntaxFacts, _node, searchScope.CancellationToken); if (type != null) { return(await GetReferencesForExtensionMethodAsync(searchScope, WellKnownMemberNames.GetAwaiter, type, m => m.IsValidGetAwaiter()).ConfigureAwait(false)); } } return(ImmutableArray <SymbolReference> .Empty); }
/// <summary> /// Searches for extension methods exactly called 'Deconstruct'. Returns /// <see cref="SymbolReference"/>s to the <see cref="INamespaceSymbol"/>s that contain /// the static classes that those extension methods are contained in. /// </summary> private async Task <ImmutableArray <SymbolReference> > GetReferencesForDeconstructAsync(SearchScope searchScope) { searchScope.CancellationToken.ThrowIfCancellationRequested(); if (_owner.CanAddImportForDeconstruct(_diagnosticId, _node)) { var type = _owner.GetDeconstructInfo(_semanticModel, _node, searchScope.CancellationToken); if (type != null) { // Note: we could check that the extension methods have the right number of out-params. // But that would involve figuring out what we're trying to deconstruct into. For now // we'll just be permissive, with the assumption that there won't be that many matching // 'Deconstruct' extension methods for the type of node that we're on. return(await GetReferencesForExtensionMethodAsync( searchScope, "Deconstruct", type, m => m.ReturnsVoid).ConfigureAwait(false)); } } return(ImmutableArray <SymbolReference> .Empty); }
protected internal virtual SearchRequest CreateSearchRequest(string identity, string filter, SearchScope searchScope, IEnumerable <string> attributes) { var searchRequest = new SearchRequest(identity, filter, searchScope, attributes != null ? attributes.ToArray() : null); if (this.DirectorySettings.SizeLimit != null) { searchRequest.SizeLimit = this.DirectorySettings.SizeLimit.Value; } return(searchRequest); }
public SearchRequest(string distinguishedName, System.Xml.XmlDocument filter, SearchScope searchScope, params string[] attributeList) { }
protected internal virtual IEnumerable <SearchResultEntry> GetSearchResult(string identity, ISearchOptions searchOptions, SearchScope searchScope, int?pageSize) { if (searchOptions == null) { throw new ArgumentNullException("searchOptions"); } using (var ldapConnection = this.LdapConnectionFactory.Create(this.LdapConnectionSettings)) { var searchRequest = this.CreateSearchRequest(identity, this.ConcatenateFilters(this.DirectorySettings.Filter, searchOptions.Filter), searchScope, this.GetAttributes(searchOptions)); if (pageSize != null) { var pageResultRequestControl = new PageResultRequestControl(pageSize.Value); searchRequest.Controls.Add(pageResultRequestControl); var searchOptionsControl = new SearchOptionsControl(SearchOption.DomainScope); searchRequest.Controls.Add(searchOptionsControl); var searchResult = new List <SearchResultEntry>(); while (true) { var searchResponse = this.GetSearchResponse(ldapConnection, searchRequest); if (searchResponse.Controls.Length != 1 || !(searchResponse.Controls[0] is PageResultResponseControl)) { throw new InvalidOperationException("The server cannot page the result."); } var pageResultResponseControl = (PageResultResponseControl)searchResponse.Controls[0]; searchResult.AddRange(searchResponse.Entries.Cast <SearchResultEntry>()); if (pageResultResponseControl.Cookie.Length == 0) { break; } pageResultRequestControl.Cookie = pageResultResponseControl.Cookie; } } return(this.GetSearchResponse(ldapConnection, searchRequest).Entries.Cast <SearchResultEntry>()); } }
public static DirectorySource <T> AsQueryable <T>(this DirectoryEntry entry, SearchScope scope) { return(new DirectorySource <T>(entry, scope)); }
public Task <IReadOnlyList <(DomainId SchemaId, DomainId Id, Status Status)> > QueryIdsAsync(DomainId appId, HashSet <DomainId> ids, SearchScope scope, CancellationToken ct = default) { if (scope == SearchScope.All) { return(collectionAll.QueryIdsAsync(appId, ids, ct)); } else { return(collectionPublished.QueryIdsAsync(appId, ids, ct)); } }
public async Task Should_query_contents_by_ids(int isFrontend, int unpublished, SearchScope scope) { var requestContext = CreateContext(isFrontend, isUnpublished: unpublished); var ids = Enumerable.Range(0, 5).Select(x => DomainId.NewGuid()).ToList(); var contents = ids.Select(CreateContent).ToList(); var q = Q.Empty.WithIds(ids); A.CallTo(() => contentRepository.QueryAsync(requestContext.App, A <List <ISchemaEntity> > .That.Matches(x => x.Count == 1), q, scope, A <CancellationToken> ._)) .Returns(ResultList.Create(5, contents)); var result = await sut.QueryAsync(requestContext, q, default); Assert.Equal(5, result.Total); for (var i = 0; i < contents.Count; i++) { AssertContent(contents[i], result[i]); } }
protected async Task SearchGeo(List <DomainId>?expected, string field, double latitude, double longitude, SearchScope target = SearchScope.All) { var query = new GeoQuery(schemaId.Id, field, latitude, longitude, 1000, 1000); var result = await Sut.TextIndex.SearchAsync(app, query, target); if (expected != null) { result.Should().BeEquivalentTo(expected.ToHashSet()); } else { result.Should().BeEmpty(); } }
SearchScope FindChainedConstructorReferences(IMethod ctor) { SearchScope searchScope = new SearchScope( delegate (ICompilation compilation) { IMethod imported = compilation.Import(ctor); if (imported != null) return new FindChainedConstructorReferencesNavigator(imported); else return null; }); if (ctor.DeclaringTypeDefinition.IsSealed) searchScope.accessibility = Accessibility.Private; else searchScope.accessibility = Accessibility.Protected; searchScope.accessibility = MergeAccessibility(GetEffectiveAccessibility(ctor), searchScope.accessibility); return searchScope; }
/// <summary> /// Searches for types that match the name the user has written. Returns <see cref="SymbolReference"/>s /// to the <see cref="INamespaceSymbol"/>s or <see cref="INamedTypeSymbol"/>s those types are /// contained in. /// </summary> private async Task <ImmutableArray <SymbolReference> > GetReferencesForMatchingTypesAsync(SearchScope searchScope) { searchScope.CancellationToken.ThrowIfCancellationRequested(); if (!_owner.CanAddImportForType(_diagnosticId, _node, out var nameNode)) { return(ImmutableArray <SymbolReference> .Empty); } CalculateContext( nameNode, _syntaxFacts, out var name, out var arity, out var inAttributeContext, out var hasIncompleteParentMember, out var looksGeneric); if (ExpressionBinds(nameNode, checkForExtensionMethods: false, cancellationToken: searchScope.CancellationToken)) { // If the expression bound, there's nothing to do. return(ImmutableArray <SymbolReference> .Empty); } var symbols = await searchScope.FindDeclarationsAsync(name, nameNode, SymbolFilter.Type).ConfigureAwait(false); // also lookup type symbols with the "Attribute" suffix if necessary. if (inAttributeContext) { var attributeSymbols = await searchScope.FindDeclarationsAsync(name + AttributeSuffix, nameNode, SymbolFilter.Type).ConfigureAwait(false); symbols = symbols.AddRange( attributeSymbols.Select(r => r.WithDesiredName(r.DesiredName.GetWithoutAttributeSuffix(isCaseSensitive: false)))); } var typeSymbols = OfType <ITypeSymbol>(symbols); // Only keep symbols which are accessible from the current location. var accessibleTypeSymbols = typeSymbols.WhereAsArray( s => ArityAccessibilityAndAttributeContextAreCorrect( s.Symbol, arity, inAttributeContext, hasIncompleteParentMember, looksGeneric)); // These types may be contained within namespaces, or they may be nested // inside generic types. Record these namespaces/types if it would be // legal to add imports for them. var typesContainedDirectlyInNamespaces = accessibleTypeSymbols.WhereAsArray(s => s.Symbol.ContainingSymbol is INamespaceSymbol); var typesContainedDirectlyInTypes = accessibleTypeSymbols.WhereAsArray(s => s.Symbol.ContainingType != null); var namespaceReferences = GetNamespaceSymbolReferences(searchScope, typesContainedDirectlyInNamespaces.SelectAsArray(r => r.WithSymbol(r.Symbol.ContainingNamespace))); var typeReferences = typesContainedDirectlyInTypes.SelectAsArray( r => searchScope.CreateReference(r.WithSymbol(r.Symbol.ContainingType))); return(namespaceReferences.Concat(typeReferences)); }
SearchScope GetSearchScopeForDestructor(IMethod dtor) { var scope = new SearchScope ( delegate (ICompilation compilation) { IMethod imported = compilation.Import(dtor); if (imported != null) { return new FindDestructorReferencesNavigator (imported); } else { return null; } }); scope.accessibility = Accessibility.Private; return scope; }
/// <summary> /// Searches for extension methods that match the name the user has written. Returns /// <see cref="SymbolReference"/>s to the <see cref="INamespaceSymbol"/>s that contain /// the static classes that those extension methods are contained in. /// </summary> private async Task <ImmutableArray <SymbolReference> > GetReferencesForMatchingExtensionMethodsAsync(SearchScope searchScope) { searchScope.CancellationToken.ThrowIfCancellationRequested(); if (_owner.CanAddImportForMethod(_diagnosticId, _syntaxFacts, _node, out var nameNode) && nameNode != null) { searchScope.CancellationToken.ThrowIfCancellationRequested(); // See if the name binds. If it does, there's nothing further we need to do. if (!ExpressionBinds(nameNode, checkForExtensionMethods: true, cancellationToken: searchScope.CancellationToken)) { _syntaxFacts.GetNameAndArityOfSimpleName(nameNode, out var name, out var arity); if (name != null) { var symbols = await searchScope.FindDeclarationsAsync(name, nameNode, SymbolFilter.Member).ConfigureAwait(false); var methodSymbols = OfType <IMethodSymbol>(symbols); var extensionMethodSymbols = GetViableExtensionMethods( methodSymbols, nameNode.Parent, searchScope.CancellationToken); var namespaceSymbols = extensionMethodSymbols.SelectAsArray(s => s.WithSymbol(s.Symbol.ContainingNamespace)); return(GetNamespaceSymbolReferences(searchScope, namespaceSymbols)); } } } return(ImmutableArray <SymbolReference> .Empty); }
public IEnumerable<File> Files(string filter, SearchScope scope) { return UnderlyingDirectory.Files(filter, scope); }
/// <summary> /// Searches for extension methods exactly called 'Add'. Returns /// <see cref="SymbolReference"/>s to the <see cref="INamespaceSymbol"/>s that contain /// the static classes that those extension methods are contained in. /// </summary> private async Task <ImmutableArray <SymbolReference> > GetReferencesForCollectionInitializerMethodsAsync(SearchScope searchScope) { searchScope.CancellationToken.ThrowIfCancellationRequested(); if (!_owner.CanAddImportForMethod(_diagnosticId, _syntaxFacts, _node, out var nameNode)) { return(ImmutableArray <SymbolReference> .Empty); } _syntaxFacts.GetNameAndArityOfSimpleName(_node, out var name, out var arity); if (name != null || !_owner.IsAddMethodContext(_node, _semanticModel)) { return(ImmutableArray <SymbolReference> .Empty); } var symbols = await searchScope.FindDeclarationsAsync( nameof(IList.Add), nameNode : null, filter : SymbolFilter.Member).ConfigureAwait(false); // Note: there is no desiredName for these search results. We're searching for // extension methods called "Add", but we have no intention of renaming any // of the existing user code to that name. var methodSymbols = OfType <IMethodSymbol>(symbols).SelectAsArray(s => s.WithDesiredName(null)); var viableMethods = GetViableExtensionMethods( methodSymbols, _node.Parent, searchScope.CancellationToken); return(GetNamespaceSymbolReferences(searchScope, viableMethods.SelectAsArray(m => m.WithSymbol(m.Symbol.ContainingNamespace)))); }
/// <summary> /// Find all shortcuts in the shortcut lists matching the given class and method. /// </summary> /// <param name="shortcutClass">The class of the shortcut</param> /// <param name="shortcutMethod">The method of the shortcut</param> /// <param name="where">A flag to tell where the shortcut should be searched</param> /// <returns>A list of matching shortcut data</returns> /// <seealso cref="findShortcut"/> public List<ShortcutData> findAllShortcuts(string shortcutClass, string shortcutMethod, SearchScope where = SearchScope.All) { if (mCurrentShortcutsList == mDefaultShortcutsList) return findAllShortcuts(shortcutClass, shortcutMethod, mCurrentShortcutsList); switch (where) { case SearchScope.AllCurrentFirst: return findAllShortcuts(shortcutClass, shortcutMethod, mCurrentShortcutsList.Concat(mDefaultShortcutsList).ToList()); case SearchScope.AllDefaultFirst: return findAllShortcuts(shortcutClass, shortcutMethod, mDefaultShortcutsList.Concat(mCurrentShortcutsList).ToList()); case SearchScope.Current: return findAllShortcuts(shortcutClass, shortcutMethod, mCurrentShortcutsList); case SearchScope.Default: return findAllShortcuts(shortcutClass, shortcutMethod, mDefaultShortcutsList); default: throw new ArgumentException("Bad value for search scope: " + where); } }
/// <summary> /// Searches for extension methods exactly called 'Select'. Returns /// <see cref="SymbolReference"/>s to the <see cref="INamespaceSymbol"/>s that contain /// the static classes that those extension methods are contained in. /// </summary> private async Task <ImmutableArray <SymbolReference> > GetReferencesForQueryPatternsAsync(SearchScope searchScope) { searchScope.CancellationToken.ThrowIfCancellationRequested(); if (_owner.CanAddImportForQuery(_diagnosticId, _node)) { var type = _owner.GetQueryClauseInfo(_semanticModel, _node, searchScope.CancellationToken); if (type != null) { // find extension methods named "Select" return(await GetReferencesForExtensionMethodAsync( searchScope, nameof(Enumerable.Select), type).ConfigureAwait(false)); } } return(ImmutableArray <SymbolReference> .Empty); }