当前位置: 首页>>代码示例>>C#>>正文


C# IEnumerable.IsNullOrEmpty方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:justinconnell,项目名称:remi,代码行数:32,代码来源:GerritRequest.cs

示例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()));
            }
        }
开发者ID:dreikanter,项目名称:refrep,代码行数:31,代码来源:Reference.cs

示例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);
        }
开发者ID:xeno-by,项目名称:datavault,代码行数:8,代码来源:EventHelper.cs

示例4: Append

        public ISignatureBuilder Append(IEnumerable<byte> bytes)
        {
            if (bytes.IsNullOrEmpty()) throw new ArgumentNullException("bytes");

            _bytes = _bytes.Concat(bytes);

            return this;
        }
开发者ID:niraltmark,项目名称:PicturesApp,代码行数:8,代码来源:SignatureBuilder.cs

示例5: ExecuteMultipartQuery

        public string ExecuteMultipartQuery(ITwitterQuery twitterQuery, string contentId, IEnumerable<byte[]> binaries)
        {
            if (binaries.IsNullOrEmpty())
            {
                return ExecuteQuery(twitterQuery);
            }

            return _webRequestExecutor.ExecuteMultipartQuery(twitterQuery, contentId, binaries);
        }
开发者ID:SowaLabs,项目名称:Tweetinvi-obsolete,代码行数:9,代码来源:TwitterRequester.cs

示例6: IsNullOrEmpty_ThreeItemsCollection_ReturnsFalse

        public void IsNullOrEmpty_ThreeItemsCollection_ReturnsFalse(IEnumerable<object> threeItemsEnumerable)
        {
            // arrange

            // act

            // assert
            Assert.False(threeItemsEnumerable.IsNullOrEmpty());
        }
开发者ID:TrangHoang,项目名称:Scratchpad,代码行数:9,代码来源:EnumerableExtensionsTest.cs

示例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);
        }
开发者ID:SowaLabs,项目名称:TweetinviNew,代码行数:10,代码来源:TweetQueryGenerator.cs

示例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;
        }
开发者ID:dreikanter,项目名称:refrep,代码行数:54,代码来源:Params.cs

示例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();
		}
开发者ID:LBognanni,项目名称:fluent-command-line-parser,代码行数:18,代码来源:CommandLineParserErrorFormatter.cs

示例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;
        }
开发者ID:anilmujagic,项目名称:Insula,代码行数:13,代码来源:StringExtensions.cs

示例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);
        }
开发者ID:justinconnell,项目名称:remi,代码行数:14,代码来源:CheckListGateway.cs

示例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;
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:19,代码来源:Transformer.cs

示例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;
        }
开发者ID:kamukondiwa,项目名称:SimpleBlog,代码行数:26,代码来源:BlogUserPageViewModelMapper.cs

示例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();
            }
        }
开发者ID:JamesLinus,项目名称:scriptcs,代码行数:17,代码来源:ScriptPacksCommand.cs

示例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;
        }
开发者ID:kamukondiwa,项目名称:SimpleBlog,代码行数:26,代码来源:BlogPostArchivePageViewModelMapper.cs


注:本文中的IEnumerable.IsNullOrEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。