本文整理汇总了C#中SearchScope.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# SearchScope.HasFlag方法的具体用法?C# SearchScope.HasFlag怎么用?C# SearchScope.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchScope
的用法示例。
在下文中一共展示了SearchScope.HasFlag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindNotes
public List<ENSessionFindNotesResult> FindNotes(ENNoteSearch noteSearch, ENNotebook notebook, SearchScope scope, SortOrder order, int maxResults)
{
if (!IsAuthenticated)
{
throw new ENAuthExpiredException();
}
// App notebook scope is internally just an "all" search, because we don't a priori know where the app
// notebook is. There's some room for a fast path in this flow if we have a saved linked record to a
// linked app notebook, but that case is likely rare enough to prevent complexifying this code for.
if (scope.HasFlag(SearchScope.AppNotebook))
{
scope = SearchScope.All;
}
// Validate the scope and sort arguments.
if (notebook != null && scope != SearchScope.None)
{
ENSDKLogger.ENSDKLogError("No search scope necessary if notebook provided.");
scope = SearchScope.None;
}
else if (notebook == null && scope == SearchScope.None)
{
ENSDKLogger.ENSDKLogError("Search scope or notebook must be specified. Defaulting to personal scope.");
scope = SearchScope.DefaultScope;
}
bool requiresLocalMerge = false;
if (scope != SearchScope.None)
{
// Check for multiple scopes. Because linked scope can subsume multiple linked notebooks, that *always* triggers
// the multiple scopes. If not, then both personal and business must be set together.
if ((scope.HasFlag(SearchScope.Personal) && scope.HasFlag(SearchScope.Business)) || scope.HasFlag(SearchScope.PersonalLinked))
{
// If we're asked for multiple scopes, relevance is not longer supportable (since we
// don't know how to combine relevance on the client), so default to updated date,
// which is probably the closest proxy to relevance.
if (order.HasFlag(SortOrder.Relevance))
{
ENSDKLogger.ENSDKLogError("Cannot sort by relevance across multiple search scopes. Using update date.");
order = (EvernoteSDK.ENSession.SortOrder)EN_FLAG_CLEAR(order, SortOrder.Relevance);
order = (EvernoteSDK.ENSession.SortOrder)EN_FLAG_SET(order, SortOrder.RecentlyUpdated);
}
requiresLocalMerge = true;
}
}
NotesMetadataResultSpec resultSpec = new NotesMetadataResultSpec();
resultSpec.IncludeNotebookGuid = true;
resultSpec.IncludeTitle = true;
resultSpec.IncludeCreated = true;
resultSpec.IncludeUpdated = true;
resultSpec.IncludeUpdateSequenceNum = true;
NoteFilter noteFilter = new NoteFilter();
noteFilter.Words = noteSearch.SearchString;
if (order.HasFlag(SortOrder.Title))
{
noteFilter.Order = (System.Int32)NoteSortOrder.TITLE;
}
else if (order.HasFlag(SortOrder.RecentlyCreated))
{
noteFilter.Order = (System.Int32)NoteSortOrder.CREATED;
}
else if (order.HasFlag(SortOrder.RecentlyUpdated))
{
noteFilter.Order = (System.Int32)NoteSortOrder.UPDATED;
}
else if (order.HasFlag(SortOrder.Relevance))
{
noteFilter.Order = (System.Int32)NoteSortOrder.RELEVANCE;
}
// "Normal" sort is ascending for titles, and descending for dates and relevance.
bool sortAscending = order.HasFlag(SortOrder.Title) ? true : false;
if (order.HasFlag(SortOrder.Reverse))
{
sortAscending = !sortAscending;
}
noteFilter.Ascending = sortAscending;
if (notebook != null)
{
noteFilter.NotebookGuid = notebook.Guid;
}
// Set up context
ENSessionFindNotesContext context = new ENSessionFindNotesContext();
context.scopeNotebook = notebook;
context.scope = scope;
context.order = order;
context.noteFilter = noteFilter;
context.resultSpec = resultSpec;
context.maxResults = maxResults;
context.findMetadataResults = new List<NoteMetadata>();
context.requiresLocalMerge = requiresLocalMerge;
context.sortAscending = sortAscending;
// If we have a scope notebook, we already know what notebook the results will appear in.
//.........这里部分代码省略.........