本文整理汇总了C#中IEnumerable.IsNullOrEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.IsNullOrEmpty方法的具体用法?C# IEnumerable.IsNullOrEmpty怎么用?C# IEnumerable.IsNullOrEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.IsNullOrEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGitLog
public IDictionary<ReleaseRepository, IEnumerable<GitLogEntity>> GetGitLog(IEnumerable<ReleaseRepository> repositories)
{
if (repositories.IsNullOrEmpty())
return null;
Log.DebugFormat("Starting connecting to Gerrit throught SSH");
using (var sshClient = SshClientFactory())
{
sshClient.Connect();
Log.DebugFormat("Connection to Gerrit established, starting executing command");
var results = new ConcurrentDictionary<ReleaseRepository, IEnumerable<GitLogEntity>>();
Parallel.ForEach(repositories, repository =>
{
if (sshClient == null) return;
var command = string.Format(GitLogCommandTemplate, repository.Repository,
repository.ChangesFrom, repository.ChangesTo);
Log.DebugFormat("Executing command [{0}]", command);
var result = sshClient.ExecuteCommand(command);
if (!string.IsNullOrWhiteSpace(result)
&& !results.TryAdd(repository, GitLogParser.Parse(result)
.Where(x => x.CommitType == CommitType.Typical).ToArray())) { }
Log.DebugFormat("Finished executing command [{0}]", command);
});
return results;
}
}
示例2: Reference
public Reference(int rowNum, IEnumerable<ReferenceFields> order, IEnumerable<string> values)
{
if (values.IsNullOrEmpty()) throw new ArgumentException("values");
if (order.IsNullOrEmpty()) throw new ArgumentException("order");
RowNum = rowNum;
var vs = values.ToArray();
var fs = order.ToArray();
if (vs.Length != fs.Length) throw new InvalidOperationException();
var fillErrors = new List<ReferenceFields>();
for (var i = 0; i < vs.Length; i++)
{
try
{
SetValue(fs[i], vs[i]);
}
catch
{
fillErrors.Add(fs[i]);
}
}
if (fillErrors.Any())
{
throw new Exception("Error reading following fields: {0}".
Fill(fillErrors.Cast<String>().CommaSeparated()));
}
}
示例3: SetInvocationList
public static void SetInvocationList(this EventInfo evt, Object host, IEnumerable<Delegate> chain)
{
var combo = chain.IsNullOrEmpty() ? null :
chain.Aggregate((agg, curr) => agg == null ? curr : Delegate.Combine(agg, curr));
var f = evt.GetUnderlyingField().AssertNotNull();
f.SetValue(host, combo);
}
示例4: Append
public ISignatureBuilder Append(IEnumerable<byte> bytes)
{
if (bytes.IsNullOrEmpty()) throw new ArgumentNullException("bytes");
_bytes = _bytes.Concat(bytes);
return this;
}
示例5: ExecuteMultipartQuery
public string ExecuteMultipartQuery(ITwitterQuery twitterQuery, string contentId, IEnumerable<byte[]> binaries)
{
if (binaries.IsNullOrEmpty())
{
return ExecuteQuery(twitterQuery);
}
return _webRequestExecutor.ExecuteMultipartQuery(twitterQuery, contentId, binaries);
}
示例6: IsNullOrEmpty_ThreeItemsCollection_ReturnsFalse
public void IsNullOrEmpty_ThreeItemsCollection_ReturnsFalse(IEnumerable<object> threeItemsEnumerable)
{
// arrange
// act
// assert
Assert.False(threeItemsEnumerable.IsNullOrEmpty());
}
示例7: GetTweetsQuery
public string GetTweetsQuery(IEnumerable<long> tweetIds)
{
if (tweetIds.IsNullOrEmpty())
{
return null;
}
var idsParameter = string.Join("%2C", tweetIds);
return string.Format(Resources.Tweet_Lookup, idsParameter);
}
示例8: Params
public Params(IEnumerable<string> args, TextWriter outputWriter)
{
_outputWriter = outputWriter;
var showHelp = false;
var p = new OptionSet
{
{ "s|source=", "Source Word document (*.doc[x] file)", v => SourceFile = v },
{ "d|destination=", "Processed document name", v => DestFile = v },
{ "r|references=", "References spreadsheet (*.xls[x] file)", v => RefFile = v },
{ "o|order=", "Sort order for references (alpha|mention)", v => Order = v.GetEnumValueOrDefault<ReferenceOrder>() },
{ "h|help", "Show this message and exit", v => showHelp = (v != null) }
};
if (args.IsNullOrEmpty())
{
showHelp = true;
}
else
{
try
{
p.Parse(args);
}
catch (OptionException e)
{
WriteMessage(e.Message);
Ready = false;
return;
}
}
if (showHelp)
{
ShowHelp(p);
Ready = false;
return;
}
var noSource = SourceFile.IsNullOrBlank();
var noRef = RefFile.IsNullOrBlank();
if (noSource || noRef)
{
if (noSource) WriteMessage("Source file not specified");
if (noRef) WriteMessage("Reference file not specified");
Ready = false;
return;
}
if (DestFile.IsNullOrBlank()) DestFile = GetDestinationFileName(SourceFile);
Ready = true;
}
示例9: Format
/// <summary>
/// Formats the specified list of <see cref="ICommandLineParserError"/> to a <see cref="System.String"/> suitable for the end user.
/// </summary>
/// <param name="parserErrors">The errors to format.</param>
/// <returns>A <see cref="System.String"/> describing the specified errors.</returns>
public string Format(IEnumerable<ICommandLineParserError> parserErrors)
{
if (parserErrors.IsNullOrEmpty()) return null;
var builder = new StringBuilder();
foreach (var error in parserErrors)
{
builder.AppendLine(Format(error));
}
return builder.ToString();
}
示例10: ContainsAny
public static bool ContainsAny(this string target, IEnumerable<string> strings)
{
if (target.IsNullOrEmpty() || strings.IsNullOrEmpty())
return false;
foreach (var s in strings)
{
if (target.Contains(s))
return true;
}
return false;
}
示例11: AddCheckListQuestions
public void AddCheckListQuestions(IEnumerable<BusinessCheckListQuestion> questions, Guid releaseWindowId)
{
if (questions.IsNullOrEmpty())
return;
CheckListQuestionRepository.Insert(questions
.Select(x => new CheckListQuestion
{
Content = x.Question,
ExternalId = x.ExternalId
}));
AssociateCheckListQuestionWithPackage(questions, releaseWindowId);
}
示例12: MergeLinkCategoriesIntoSingleLinkCategory
/// <summary>
/// Converts a LinkCategoryCollection into a single LinkCategory with its own LinkCollection.
/// </summary>
public static LinkCategory MergeLinkCategoriesIntoSingleLinkCategory(string title, CategoryType catType,
IEnumerable<LinkCategory> links,
BlogUrlHelper urlHelper, Blog blog)
{
if (!links.IsNullOrEmpty())
{
var mergedLinkCategory = new LinkCategory { Title = title };
var merged = from linkCategory in links
select GetLinkFromLinkCategory(linkCategory, catType, urlHelper, blog);
mergedLinkCategory.Links.AddRange(merged);
return mergedLinkCategory;
}
return null;
}
示例13: MapFrom
/// <summary>
/// The map from.
/// </summary>
/// <param name="userBlogs">
/// The userBlogs.
/// </param>
/// <returns>
/// The mapped blog user page view model.
/// </returns>
public BlogUserPageViewModel MapFrom(IEnumerable<Blog> userBlogs)
{
var model = new BlogUserPageViewModel
{
Blogs = userBlogs
.ToList()
.MapAllUsing(this.blogSummaryViewModelMapper)
.OrderByDescending(x => x.CreationDate, new StringDateComparer())
};
if (!userBlogs.IsNullOrEmpty())
{
model.Author = userBlogs.First().Author.Username;
}
return model;
}
示例14: PrintMethods
private void PrintMethods(IEnumerable<MethodInfo> methods, string[] importedNamespaces)
{
if (!methods.IsNullOrEmpty())
{
_console.WriteLine("** Methods **");
foreach (var method in methods)
{
var methodParams = method.GetParametersWithoutExtensions()
.Select(p => string.Format("{0} {1}", GetPrintableType(p.ParameterType, importedNamespaces), p.Name));
var methodSignature = string.Format(" - {0} {1}({2})", GetPrintableType(method.ReturnType, importedNamespaces), method.Name,
string.Join(", ", methodParams));
_console.WriteLine(methodSignature);
}
_console.WriteLine();
}
}
示例15: MapFrom
/// <summary>
/// The map from.
/// </summary>
/// <param name="blogPosts">
/// The input.
/// </param>
/// <returns>
/// The mapped blog post archive page view model.
/// </returns>
public BlogPostArchivePageViewModel MapFrom(IEnumerable<BlogPost> blogPosts)
{
var model = new BlogPostArchivePageViewModel
{
Results = blogPosts
.MapAllUsing(this.blogPostSummaryPageViewModelMapper)
.OrderByDescending(x => x.PostDate, new StringDateComparer()).ToList()
};
if (!blogPosts.IsNullOrEmpty())
{
var blog = blogPosts.First().Blog;
model.ArchiveSectionViewModel = this.archiveSectionViewModelMapper.MapFrom(blog);
}
return model;
}