本文整理汇总了C#中SearchCondition.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# SearchCondition.ThrowIfNull方法的具体用法?C# SearchCondition.ThrowIfNull怎么用?C# SearchCondition.ThrowIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchCondition
的用法示例。
在下文中一共展示了SearchCondition.ThrowIfNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Search
public IEnumerable<uint> Search(SearchCondition criteria, string mailbox = null)
{
AssertValid();
criteria.ThrowIfNull("criteria");
lock (sequenceLock)
{
if (criteria != null)
{
PauseIdling();
SelectMailbox(mailbox);
criteria.ThrowIfNull("criteria");
string resptag = GetTag(), str = criteria.ToString();
StringReader reader = new StringReader(str);
bool useUTF8 = str.Contains("\r\n");
string line = reader.ReadLine();
string response = SendCommandGetResponse(resptag + "UID SEARCH " + (useUTF8 ? "CHARSET UTF-8 " : string.Empty) + line);
while ((line = reader.ReadLine()) != null)
{
if (!response.StartsWith("+"))
{
ResumeIdling();
throw new NotSupportedException("Please restrict your search " + "to ASCII-only characters.", new BadServerResponseException(response));
}
response = SendCommandGetResponse(line);
}
List<uint> result = new List<uint>();
while (response.StartsWith("*"))
{
Match m = Regex.Match(response, @"^\* SEARCH (.+)");
if (m.Success)
{
string[] v = m.Groups[1].Value.Trim().Split(' ');
foreach (string s in v)
{
try
{
result.Add(Convert.ToUInt32(s));
}
catch (FormatException)
{
}
}
}
response = GetResponse();
}
ResumeIdling();
if (!IsResponseOK(response, resptag))
{
throw new BadServerResponseException(response);
}
return result.ToArray();
}
else
{
throw new ArgumentNullException("criteria");
}
}
}