本文整理汇总了C#中ICollection.IsNullOrEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# ICollection.IsNullOrEmpty方法的具体用法?C# ICollection.IsNullOrEmpty怎么用?C# ICollection.IsNullOrEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollection
的用法示例。
在下文中一共展示了ICollection.IsNullOrEmpty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BatchGeocodeRequest
public BatchGeocodeRequest(string key, ICollection<string> addresses)
: base(key)
{
if (addresses.IsNullOrEmpty())
throw new ArgumentException("addresses can not be null or empty");
Locations = (from l in addresses select new LocationRequest(l)).ToArray();
}
示例2: SetRouteValues
private void SetRouteValues(ICollection<KeyValuePair<string, object>> values)
{
if (!values.IsNullOrEmpty())
{
siteMapNode.RouteValues.Clear();
siteMapNode.RouteValues.AddRange(values);
}
}
示例3: DeleteSnippetTags
public bool DeleteSnippetTags(long snippetID, ICollection<string> tagsToDelete)
{
if ((snippetID <= 0) || tagsToDelete.IsNullOrEmpty())
{
SetLastError(log, ErrorCodes.WRONG_INPUT,
string.Format("Input error: snippetID={0}, tags={1}", snippetID, tagsToDelete.Print<string>()));
return false;
}
//send the request and parse the response:
S2CSerializer ser = new S2CSerializer(m_serialFormat, snippetID);
string contentToSend = "content=" + HttpUtility.UrlEncode(ser.SerializeListObj<string>(tagsToDelete.ToArray()));
S2CResObj<object> resp = SendReqObj(DELETE_TAGS_URL, contentToSend, true);
//build the result:
return ParseBoolResponse(resp);
}
示例4: SetRouteValues
private void SetRouteValues(ICollection<KeyValuePair<string, object>> values)
{
if (!values.IsNullOrEmpty())
{
item.RouteValues.Clear();
item.RouteValues.Merge(values);
}
}
示例5: UnPublishSnippet
public bool UnPublishSnippet(long snippetID, ICollection<int> channelIDs)
{
// 1) check input validity:
if ((snippetID <= 0) || channelIDs.IsNullOrEmpty())
{
SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: snippetID={0}; channelIDs={1}", snippetID, channelIDs.PrintNull()));
return false;
}
// 2) remove the channels ID as a property of the snippet:
foreach (int channelID in channelIDs)
{
if (!DeleteSnippetProperty(new SnippetProperty(DefaultProperty.Channel, channelID + "", snippetID, false)))
return false;
}
return true;
}
示例6: PublishSnippet
public bool PublishSnippet(long snippetID, ICollection<int> channelIDs)
{
if ((snippetID <= 0) || channelIDs.IsNullOrEmpty())
{
SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: snippetID={0}; channelIDs={1}", snippetID, channelIDs.PrintNull()));
return false;
}
//send the request and parse the response:
string content = Utilities.MergeIntoCommaSeparatedString(channelIDs, true);
string contentToSend = string.Format("snippetID={0}&channelsIDs={1}", snippetID, content);
S2CResObj<object> resp = SendReqObj(PUBLISH_SNIPPET_URL, contentToSend, true);
//build the result:
return ParseBoolResponse(resp);
}
示例7: AddSnippetProperties
public bool AddSnippetProperties(long snippetID, ICollection<SnippetProperty> properties)
{
if ((snippetID <= 0) || properties.IsNullOrEmpty())
{
SetLastError(log, ErrorCodes.WRONG_INPUT,
string.Format("Input error: snippetID={0}, properties={1}", snippetID, properties.Print<SnippetProperty>()));
return false;
}
//check input properties and clean them if not valid:
List<SnippetProperty> cleanProperties = SnippetProperty.CleanPropertyList(properties, snippetID);
//fastly return if no properties are to be added:
if (cleanProperties.IsNullOrEmpty())
return true;
//send the request and parse the response:
S2CSerializer ser = new S2CSerializer(m_serialFormat, snippetID);
string contentToSend = "content=" + HttpUtility.UrlEncode(ser.SerializeBaseEntityList<SnippetProperty>(cleanProperties.ToArray(), null));
S2CResObj<object> resp = SendReqObj(ADD_PROPERTIES_URL, contentToSend, true);
//build the result:
return ParseBoolResponse(resp);
}
示例8: FindChannelsItems
public IList<Snippet> FindChannelsItems(int start, int count, ICollection<int> channelsIDs, out int totNum,
ItemSortField field = ItemSortField.Relevance, SortDirection direction = SortDirection.Descent,
bool findAllChannels = false)
{
//check for erroneous input:
totNum = 0;
if ((count <= 0) || (start < 0) || (channelsIDs.IsNullOrEmpty() && !findAllChannels))
{
SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}, count={1}, start={2}, channelsIDs={3}",
CurrentUserID, count, start, channelsIDs.Print()));
return new List<Snippet>();
}
//exec the SP:
string search = string.Format("{0}={1}", DefaultProperty.Channel,
(findAllChannels ? "*" : Utilities.MergeIntoCommaSeparatedString(channelsIDs, true)));
Dictionary<string, string[]> misSpellings = null;
int totNumWithNonDefOp = 0;
SortedDictionary<string, int> tagsOccurrences = null;
return GetSnippetsForSearch(search, out misSpellings, out totNum, out totNumWithNonDefOp, out tagsOccurrences,
count, start, false, 0, field, direction);
}
示例9: IsNullOrEmpty
public void IsNullOrEmpty(ICollection col, bool expectedResult)
{
Assert.That(col.IsNullOrEmpty(), Is.EqualTo(expectedResult));
}