本文整理汇总了C#中IEnumerable.IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.IsEmpty方法的具体用法?C# IEnumerable.IsEmpty怎么用?C# IEnumerable.IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.IsEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArgumentNotEmpty
public static void ArgumentNotEmpty(IEnumerable source, [InvokerParameterName] String name, String message)
{
if (source.IsEmpty())
{
throw new ArgumentException(message, name);
}
}
示例2: Convert
public IDbCommandResult Convert(IEnumerable values)
{
if (values.IsEmpty())
{
return new QueryResult();
}
var type = values.GetTypeOfValues();
if (type.IsValueType || type == typeof(string))
{
return QueryResultOfValues(values, type);
}
if (type == typeof(DynamicRecord))
{
return QueryResultOfDynamicRecord(values.Cast<DynamicRecord>());
}
if (type == typeof(DynamicDataRow))
{
return QueryResultOfDynamicDataRow(values.Cast<DynamicDataRow>());
}
if (type.IsAssignableFrom(typeof(IDictionary)))
{
return QueryResultOfDictionary((IEnumerable<IDictionary>)values);
}
return QueryResultOfType(values, type);
}
示例3: AlignTokensOperation
internal AlignTokensOperation(SyntaxToken baseToken, IEnumerable<SyntaxToken> tokens, AlignTokensOption option)
{
Contract.ThrowIfNull(tokens);
Debug.Assert(!tokens.IsEmpty());
this.Option = option;
this.BaseToken = baseToken;
this.Tokens = tokens;
}
示例4: TextChangeEventArgs
/// <summary>
/// Initializes an instance of <see cref="TextChangeEventArgs"/>.
/// </summary>
/// <param name="oldText">The text before the change.</param>
/// <param name="newText">The text after the change.</param>
/// <param name="changes">A non-empty set of ranges for the change.</param>
public TextChangeEventArgs(SourceText oldText, SourceText newText, IEnumerable<TextChangeRange> changes)
{
if (changes == null || changes.IsEmpty())
{
throw new ArgumentException("changes");
}
this.OldText = oldText;
this.NewText = newText;
this.Changes = changes.ToImmutableArray();
}
示例5: ExecuteMultipartQuery
public string ExecuteMultipartQuery(ITwitterQuery twitterQuery, string contentId, IEnumerable<IMedia> medias)
{
if (medias == null || medias.IsEmpty())
{
return ExecuteQuery(twitterQuery);
}
var webRequest = _twitterRequestGenerator.GenerateMultipartWebRequest(twitterQuery, contentId, medias);
var result = _webRequestExecutor.ExecuteMultipartRequest(webRequest);
return result;
}
示例6: AddDependencies
public static void AddDependencies(this IFigure figure, IEnumerable<IFigure> dependencies)
{
if (figure == null || dependencies.IsEmpty())
{
return;
}
foreach (var dependency in dependencies)
{
dependency.Dependents.Add(figure);
}
}
示例7: Build
public static Directory Build(IEnumerable<WeaveHistoryItem> weaveHistoryItems)
{
if (weaveHistoryItems.IsEmpty())
{
return new Directory("All History", "history");
}
else
{
// Today
var todayQuery = from b in weaveHistoryItems
let dateTime = b.Visits!= null ? b.Visits.First().Date : DateTime.MinValue
where IsToday(dateTime)
orderby dateTime
select b;
Directory today = new Directory("Today", "today");
foreach (WeaveHistoryItem historyItem in todayQuery)
today.Bookmarks.Add(new Bookmark(historyItem.Title, historyItem.Uri));
// Yesterday
var yesterdayQuery = from b in weaveHistoryItems
let dateTime = b.Visits != null ? b.Visits.First().Date : DateTime.MinValue
where IsYesterday(dateTime)
orderby dateTime
select b;
Directory yesterday = new Directory("Yesterday", "yesterday");
foreach (WeaveHistoryItem historyItem in yesterdayQuery)
yesterday.Bookmarks.Add(new Bookmark(historyItem.Title, historyItem.Uri));
// This Month
var thisMonthQuery = from b in weaveHistoryItems
let dateTime = b.Visits != null ? b.Visits.First().Date : DateTime.MinValue
where IsThisMonth(dateTime)
orderby dateTime
select b;
Directory thisMonth = new Directory("This Month", "thismonth");
foreach (WeaveHistoryItem historyItem in thisMonthQuery)
thisMonth.Bookmarks.Add(new Bookmark(historyItem.Title, historyItem.Uri));
// History
Directory history = new Directory("All History", "history");
history.Directories.Add(today);
history.Directories.Add(yesterday);
history.Directories.Add(thisMonth);
return history;
}
}
示例8: Join
public IEnumerable<CorrelatedResult> Join(IEnumerable<RunResult> sourceResults,
IEnumerable<RunResult> targetResults)
{
var sourceArray = (sourceResults ?? Enumerable.Empty<RunResult>()).ToArray();
var targetArray = (targetResults ?? Enumerable.Empty<RunResult>()).ToArray();
if (targetArray.IsEmpty())
return Enumerable.Empty<CorrelatedResult>();
if (sourceResults.IsEmpty())
return targetArray.Select(x => new CorrelatedResult(new NullResult(), x));
return joinTwoNonEmptyCollections(sourceArray, targetArray);
}
示例9: StrategyReport
/// <summary>
/// Initialize <see cref="StrategyReport"/>.
/// </summary>
/// <param name="strategies">Strategies, requiring the report generation.</param>
/// <param name="fileName">The name of the file, in which the report is generated.</param>
protected StrategyReport(IEnumerable<Strategy> strategies, string fileName)
{
if (strategies == null)
throw new ArgumentNullException(nameof(strategies));
if (strategies.IsEmpty())
throw new ArgumentOutOfRangeException(nameof(strategies));
if (fileName.IsEmpty())
throw new ArgumentNullException(nameof(fileName));
Strategies = strategies;
FileName = fileName;
}
示例10: NewRow
public static LayoutElement NewRow(IEnumerable<LayoutElement> nodes,
LayoutElementType type = LayoutElementType.Row)
{
RectangleF dummyBounds = new RectangleF(0,0,1,1);
var e = new LayoutElement(type, dummyBounds, null, nodes);
// set bounds
if (!nodes.IsEmpty())
{
e.Text = nodes.Select(x => x.Text).Where(x => !String.IsNullOrEmpty(x)).ElementsToStringS(delim: " ");
e.SetBoundsFromNodes(false);
}
return e;
}
示例11: LoadItemsFromConfig
private IEnumerable<IScopeContext> LoadItemsFromConfig(Type type, IEnumerable<IScopeContext> items)
{
items = ConfigurationResolver.GetTypeBindingsFromConfig(type);
if (items.IsEmpty())
{
Optimizer.AddBaseTypeIfNonExisting(type);
}
else
{
foreach (var scopeContext in items)
{
Optimizer.SetImplementationType(type, scopeContext, scopeContext.ImplementationKey);
}
}
return items;
}
示例12: QueryResultOfDynamicDataRow
private IDbCommandResult QueryResultOfDynamicDataRow(IEnumerable<DynamicDataRow> values)
{
var result = new QueryResult();
if (values.IsEmpty())
{
return result;
}
var columns = values.First().Columns;
columns.Each(c => result.AddColumn(c, typeof(string)));
foreach (var record in values)
{
var theRecord = record;
result.AddRow(columns.Select(c => theRecord[c]));
}
return result;
}
示例13: ExtractTagRank
private IDictionary<string, double> ExtractTagRank(string text, IEnumerable<string> allowPos)
{
if (allowPos.IsEmpty())
{
allowPos = DefaultPosFilter;
}
var g = new UndirectWeightedGraph();
var cm = new Dictionary<string, int>();
var words = PosSegmenter.Cut(text).ToList();
for (var i = 0; i < words.Count(); i++)
{
var wp = words[i];
if (PairFilter(wp))
{
for (var j = i + 1; j < i + Span; j++)
{
if (j >= words.Count)
{
break;
}
if (!PairFilter(words[j]))
{
continue;
}
// TODO: better separator.
var key = wp.Word + "$" + words[j].Word;
if (!cm.ContainsKey(key))
{
cm[key] = 0;
}
cm[key] += 1;
}
}
}
foreach (var p in cm)
{
var terms = p.Key.Split('$');
g.AddEdge(terms[0], terms[1], p.Value);
}
return g.Rank();
}
示例14: InsertMethods
private static void InsertMethods(HtmlElement parent, string name, IEnumerable<MethodInfo> methods)
{
// Setup initial conditions.
if (methods.IsEmpty()) return;
// Create the method container.
var methodContainer = CreateElement(name);
parent.AppendChild(methodContainer);
// Insert each method.
foreach (var methodInfo in methods)
{
var htmMethod = CreateElement("method");
htmMethod.SetAttribute("name", methodInfo.Name);
htmMethod.SetAttribute("class", methodInfo.DeclaringType.FullName);
methodContainer.AppendChild(htmMethod);
}
}
示例15: Remove
/// <summary>
/// 删除文件资源。
/// </summary>
/// <param name="filePaths">文件路径</param>
public static void Remove(IEnumerable<string> filePaths)
{
if (filePaths.IsEmpty())
{
return;
}
foreach (var file in filePaths)
{
var fileInfo = new FileInfo(HttpContext.Current.Server.MapPath(file));
if (fileInfo.Exists)
{
fileInfo.Delete();
RemoveCompressionImage(fileInfo.FullName);
}
}
}