本文整理汇总了C#中SearchMode类的典型用法代码示例。如果您正苦于以下问题:C# SearchMode类的具体用法?C# SearchMode怎么用?C# SearchMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchMode类属于命名空间,在下文中一共展示了SearchMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public override object Run(WorkFlowContext context, SearchMode mode, WorkFlow.Visitors.IVisitor visitor = null)
{
if (visitor == null)
visitor = new DefaultVisitor();
Queue<string> fila = new Queue<string>();
List<string> mark = new List<string>();
fila.Enqueue(context.SourceState);
mark.Add(context.SourceState);
while (fila.Count != 0)
{
string statusfila = fila.Dequeue();
context.SourceState = statusfila;
foreach (var item in this.GetActivities(context).OrderBy(x => x.Operation))
{
context.Operation = item.Operation;
string newstatus = this.GetNextStatus(context);
visitor.Visit(statusfila, new Activity { Operation = item.Operation, Description = item.Description }, newstatus);
if (!mark.Contains(newstatus))
{
fila.Enqueue(newstatus);
mark.Add(newstatus);
}
}
}
return visitor.EndVisit();
}
示例2: Resolve
/// <summary>
/// Resolves a dependency.
/// </summary>
/// <param name="typeToResolve">The type to be resolved.</param>
/// <param name="typeToCreate">The type to be created, if the type cannot be resolved
/// (and notPresent is set to <see cref="NotPresentBehavior.CreateNew"/>).</param>
/// <param name="id">The ID of the object to be resolved. Pass null for the unnamed object.</param>
/// <param name="notPresent">Flag to describe how to behave if the dependency is not found.</param>
/// <param name="searchMode">Flag to describe whether searches are local only, or local and up.</param>
/// <returns>The dependent object. If the object is not found, and notPresent
/// is set to <see cref="NotPresentBehavior.ReturnNull"/>, will return null.</returns>
public object Resolve(Type typeToResolve, Type typeToCreate, string id, NotPresentBehavior notPresent, SearchMode searchMode)
{
if (typeToResolve == null)
throw new ArgumentNullException("typeToResolve");
if (!Enum.IsDefined(typeof(NotPresentBehavior), notPresent))
throw new ArgumentException(Properties.Resources.InvalidEnumerationValue, "notPresent");
if (typeToCreate == null)
typeToCreate = typeToResolve;
DependencyResolutionLocatorKey key = new DependencyResolutionLocatorKey(typeToResolve, id);
if (context.Locator.Contains(key, searchMode))
return context.Locator.Get(key, searchMode);
switch (notPresent)
{
case NotPresentBehavior.CreateNew:
return context.HeadOfChain.BuildUp(context, typeToCreate, null, key.ID);
case NotPresentBehavior.ReturnNull:
return null;
default:
throw new DependencyMissingException(
string.Format(CultureInfo.CurrentCulture,
Properties.Resources.DependencyMissing, typeToResolve.ToString()));
}
}
示例3: SearchForm
public SearchForm(ConsoleNode console, SearchMode mode)
{
InitializeComponent();
//fill the data
SetData(console, mode);
}
示例4: Create
/// <summary>
/// Creates a default ISearchStrategy with the given parameters.
/// </summary>
public static ISearchStrategy Create(string searchPattern, bool ignoreCase, bool matchWholeWords, SearchMode mode)
{
if (searchPattern == null)
throw new ArgumentNullException("searchPattern");
RegexOptions options = RegexOptions.Compiled | RegexOptions.Multiline;
if (ignoreCase)
options |= RegexOptions.IgnoreCase;
switch (mode) {
case SearchMode.Normal:
searchPattern = Regex.Escape(searchPattern);
break;
case SearchMode.Wildcard:
searchPattern = ConvertWildcardsToRegex(searchPattern);
break;
}
if (matchWholeWords)
searchPattern = "\\b" + searchPattern + "\\b";
try {
Regex pattern = new Regex(searchPattern, options);
return new RegexSearchStrategy(pattern);
} catch (ArgumentException ex) {
throw new SearchPatternException(ex.Message, ex);
}
}
示例5: TrackingPointGetter
public TrackingPointGetter(string prompt, CurvesTopology crvTopology, int fromIndex, SearchMode mode)
{
_crvTopology = crvTopology;
_fromIndex = fromIndex;
if(!Enum.IsDefined(typeof(SearchMode), mode))
throw new ArgumentException("Enum is undefined.", "mode");
_sm = mode;
if (!string.IsNullOrEmpty(prompt))
_getPoint.SetCommandPrompt(prompt);
if (fromIndex != -1)
{
switch(mode)
{
case SearchMode.CurveLength:
_distances = crvTopology.MeasureAllEdgeLengths();
break;
case SearchMode.LinearDistance:
_distances = crvTopology.MeasureAllEdgeLinearDistances();
break;
case SearchMode.Links:
_distances = null;
break;
default:
throw new ApplicationException("Behaviour for this enum value is undefined.");
}
}
_getPoint.DynamicDraw += DynamicDraw;
_pathSearchMethod = PathMethod.FromMode(_sm, _crvTopology, _distances);
}
示例6: DependencyParameter
public DependencyParameter(Type parameterType, string name, Type createType, NotPresentBehavior notPresentBehavior, SearchMode searchMode) : base(parameterType)
{
this.name = name;
this.createType = createType;
this.notPresentBehavior = notPresentBehavior;
this.searchMode = searchMode;
}
示例7: ParseCommand_1
static void ParseCommand_1(string[] args, SearchMode ch)
{
switch (ch)
{
case SearchMode.a:
break;
case SearchMode.nm:
if (args.Length < 4)
throw new ArgumentException("Некорректная команда! Отсутствует <аргумент_3>.");
break;
case SearchMode.sz:
{
long size;
if (!Int64.TryParse(args[3], out size))
throw new ArgumentException("Некорректная команда! Проверьте <аргумент_3>.");
break;
}
case SearchMode.crt:
case SearchMode.lat:
case SearchMode.lwt:
{
DateTime date;
if (!DateTime.TryParse(args[3], out date))
throw new ArgumentException("Некорректная команда! Проверьте <аргумент_3>.");
break;
}
case SearchMode.ctn:
if (args.Length < 4)
throw new ArgumentException("Некорректная команда! Отсутствует <аргумент_3>.");
word_to_change = args[3];
break;
}
}
示例8: GetStudents
public IEnumerable<StudentViewModel> GetStudents(string name, SearchMode searchMode)
{
IEnumerable<Domain.Student> students;
if (String.IsNullOrWhiteSpace(name))
{
students = _session.Query<Domain.Student>().ToList();
}
else
{
switch (searchMode)
{
case SearchMode.BeginsWith:
students = _session.Advanced.LuceneQuery<Domain.Student>()
.WhereStartsWith("FirstName", name).Boost(3)
.WhereStartsWith("LastName", name)
.ToList();
break;
case SearchMode.Contains:
students = _session.Advanced.LuceneQuery<Domain.Student>()
.Where(String.Format("FirstName:*{0}*", name)).Boost(3)
.Where(String.Format("LastName:*{0}*", name))
.ToList();
break;
default:
students = _session.Query<Domain.Student>().ToList();
break;
}
}
return Mapper.Map<IEnumerable<Domain.Student>, IEnumerable<StudentViewModel>>(students);
}
示例9: Search
private TopDocs topDocs; //搜索到的doc。
#endregion Fields
#region Constructors
/// <summary>
/// Search构造函数
/// </summary>
/// <param name="_form">主窗</param>
/// <param name="_mode">搜索模式</param>
public Search(FileFinder _form, SearchMode _mode)
{
//修改maxCluseCount是为了用PrefixQuery时没有数量的限制,
//PrefixQuery会将找到的数据用TermQuery,然后用booleanQuery.add()方法。
BooleanQuery.SetMaxClauseCount(int.MaxValue);
this.oldBoolQuery = new BooleanQuery();
this.form = _form;
this.SetSearcher(_mode);
}
示例10: SearchForm
public SearchForm(ConsoleNode console, SearchMode mode)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//fill the data
SetData(console, mode);
}
示例11: Create
/// <summary>
/// Creates a default ISearchStrategy with the given parameters.
/// </summary>
public static ISearchStrategy Create(string searchPattern, bool ignoreCase, bool matchWholeWords, SearchMode mode)
{
if (searchPattern == null)
{
throw new ArgumentNullException("searchPattern");
}
var regexOptions = RegexOptions.Compiled;
if ((mode == SearchMode.Extended || mode == SearchMode.RegEx)
&& (searchPattern.IndexOf("\\r") > 0 || searchPattern.IndexOf("\\n") > 0))
{
// Don't change the Regex mode
}
else
{
regexOptions |= RegexOptions.Multiline;
}
if (ignoreCase)
{
regexOptions |= RegexOptions.IgnoreCase;
}
switch (mode)
{
case SearchMode.Normal:
searchPattern = Regex.Escape(searchPattern);
break;
case SearchMode.Extended:
try
{
searchPattern = Regex.Escape(StringHelper.StringFromCSharpLiteral(searchPattern));
}
catch (ArgumentException ex)
{
throw new SearchPatternException(ex.Message, ex);
}
break;
case SearchMode.Wildcard:
searchPattern = ConvertWildcardsToRegex(searchPattern);
break;
case SearchMode.XPath:
return new XPathSearchStrategy(searchPattern);
}
try
{
var searchPattern2 = new Regex(searchPattern, regexOptions);
return new RegexSearchStrategy(searchPattern2, matchWholeWords);
}
catch (ArgumentException ex)
{
throw new SearchPatternException(ex.Message, ex);
}
}
示例12: MinMax
//*********************************************************
//
/// <summary>
/// Minimum/maximum depth first search
/// </summary>
/// <param name="chessBoard"> Chess board</param>
/// <param name="searchMode"> Search mode</param>
/// <param name="ePlayerColor"> Color doing the move</param>
/// <param name="iDepth"> Actual search depth</param>
/// <param name="iWhiteMoveCount"> Number of moves white can do</param>
/// <param name="iBlackMoveCount"> Number of moves black can do</param>
/// <param name="iPermCount"> Total permutation evaluated</param>
/// <returns>
/// Points to give for this move
/// </returns>
//
//*********************************************************
private int MinMax(ChessBoard chessBoard, SearchMode searchMode, ChessBoard.PlayerColorE ePlayerColor, int iDepth, int iWhiteMoveCount, int iBlackMoveCount, ref int iPermCount) {
int iRetVal;
int iMoveCount;
int iPts;
List<ChessBoard.MovePosS> moveList;
ChessBoard.RepeatResultE eResult;
if (chessBoard.IsEnoughPieceForCheckMate()) {
if (iDepth == 0 || m_bCancelSearch) {
iRetVal = (ePlayerColor == ChessBoard.PlayerColorE.Black) ? -chessBoard.Points(searchMode, ePlayerColor, iWhiteMoveCount - iBlackMoveCount, 0, 0) :
chessBoard.Points(searchMode, ePlayerColor, iWhiteMoveCount - iBlackMoveCount, 0, 0);
iPermCount++;
} else {
moveList = chessBoard.EnumMoveList(ePlayerColor);
iMoveCount = moveList.Count;
if (ePlayerColor == ChessBoard.PlayerColorE.White) {
iWhiteMoveCount = iMoveCount;
} else {
iBlackMoveCount = iMoveCount;
}
if (iMoveCount == 0) {
if (chessBoard.IsCheck(ePlayerColor)) {
iRetVal = -1000000 - iDepth;
} else {
iRetVal = 0; // Draw
}
} else {
iRetVal = Int32.MinValue;
foreach (ChessBoard.MovePosS move in moveList) {
eResult = chessBoard.DoMoveNoLog(move);
if (eResult == ChessBoard.RepeatResultE.NoRepeat) {
iPts = -MinMax(chessBoard,
searchMode,
(ePlayerColor == ChessBoard.PlayerColorE.Black) ? ChessBoard.PlayerColorE.White : ChessBoard.PlayerColorE.Black,
iDepth - 1,
iWhiteMoveCount,
iBlackMoveCount,
ref iPermCount);
} else {
iPts = 0;
}
chessBoard.UndoMoveNoLog(move);
if (iPts > iRetVal) {
iRetVal = iPts;
}
}
}
}
} else {
iRetVal = 0;
}
return(iRetVal);
}
示例13: calculateListOfMethodsFromFiles
public static List<String> calculateListOfMethodsFromFiles(List<String> sFileList, SearchMode smSearchMode,
bool bOnlyAddFunctionsWithNoCustomRule)
{
bool bVerbose = false;
var lsResolvedMethodsSignature = new List<string>();
var lmiMethodsToResolve = new List<MethodInfo>();
foreach (string sFile in sFileList)
{
switch (smSearchMode)
{
case SearchMode.PublicMethods:
calculateListWithPublicMethods(sFile, lmiMethodsToResolve);
break;
case SearchMode.WebMethods:
calculateListWithWebMethods(sFile, lmiMethodsToResolve);
break;
}
}
foreach (MethodInfo miMethodInfo in lmiMethodsToResolve)
{
String sMethodSignature = OunceLabsScannerHacks.fixDotNetSignature(miMethodInfo);
// DC adding all methods (for the reason below)
lsResolvedMethodsSignature.Add(sMethodSignature);
// DC removing the code below since queries to the DB are now taking a long time:
// For example: Select vuln_id, 'signature', 'signature' from rec where signature = 'HacmeBank_v2_WS.WS_UserManagement.Login(string;string):string';
// [2:03 AM] DEBUG: sql query: in 2s:218
// [2:03 AM] DEBUG: sql query: in 2s:0
// [2:03 AM] DEBUG: sql query: in 1s:968
// [2:03 AM] DEBUG: sql query: in 1s:875
// [2:03 AM] DEBUG: sql query: in 1s:843
// [2:03 AM] DEBUG: sql query: in 1s:921
// [2:03 AM] DEBUG: sql query: in 1s:937
// [2:03 AM] DEBUG: sql query: in 1s:937
// [2:03 AM] DEBUG: sql query: in 1s:921
/*
if (false == bOnlyAddFunctionsWithNoCustomRule) // check if we want the full list of possible webmethods or only the list of methods that don't have a custom rule
lsResolvedMethodsSignature.Add(sMethodSignature);
else if (sMethodSignature.IndexOf("()") == -1) // remove methods with no parameters
if (0 == Lddb_OunceV6.action_getVulnIdThatMatchesSignature("", sMethodSignature, false))
lsResolvedMethodsSignature.Add(sMethodSignature);
else
if (bVerbose)
DI.log.info("Method {0} is already marked as a callback", sMethodSignature);
*/
}
return lsResolvedMethodsSignature;
}
示例14: SetData
private void SetData(ConsoleNode console, SearchMode mode)
{
try
{
lvMembers.Items.Clear();
if (mode == SearchMode.User)
{
lbMembers.Text = "&Users:";
this.Text = "Users";
UserStorageView[] users = console.Manager.Admon_GetUserList(console.Credentials);
foreach (UserStorageView user in users)
{
UserItem ui = new UserItem(user.Username);
ui.ImageIndex = 3;
ui.User = user;
lvMembers.Items.Add(ui);
}
}
else if (mode == SearchMode.Group)
{
lbMembers.Text = "&Groups:";
this.Text = "Groups";
GroupStorageView[] groups = console.Manager.Admon_GetGroups(console.Credentials);
foreach (GroupStorageView group in groups)
{
GroupItem gi = new GroupItem(group.GroupName);
gi.ImageIndex = 2;
gi.GroupView = group;
lvMembers.Items.Add(gi);
}
}
else if (mode == SearchMode.Permission)
{
lbMembers.Text = "&Permissions:";
this.Text = "Permissions";
PermissionStorageView[] permissions = console.Manager.Admon_GetPermissions(console.Credentials);
foreach (PermissionStorageView permission in permissions)
{
PermissionItem prm = new PermissionItem(permission.PermissionName);
prm.ImageIndex = 12;
prm.Permission = new PermissionStorageView(permission.PermissionId, permission.PermissionName);
lvMembers.Items.Add(prm);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error filling search list:" + ex.Message, "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例15: Contains
/// <summary>
/// See <see cref="IReadableLocator.Contains(object, SearchMode)"/> for more information.
/// </summary>
public override bool Contains(object key, SearchMode options)
{
if (key == null)
throw new ArgumentNullException("key");
if (!Enum.IsDefined(typeof(SearchMode), options))
throw new ArgumentException(Properties.Resources.InvalidEnumerationValue, "options");
if (references.ContainsKey(key))
return true;
if (options == SearchMode.Up && ParentLocator != null)
return ParentLocator.Contains(key, options);
return false;
}