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


C# List.AddIfNotNull方法代码示例

本文整理汇总了C#中List.AddIfNotNull方法的典型用法代码示例。如果您正苦于以下问题:C# List.AddIfNotNull方法的具体用法?C# List.AddIfNotNull怎么用?C# List.AddIfNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在List的用法示例。


在下文中一共展示了List.AddIfNotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSearchRequests

        public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequest = new List<IEnumerable<IndexerRequest>>();

            var parameters = new BroadcastheNetTorrentQuery();
            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                foreach (var episode in searchCriteria.Episodes)
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Episode";
                    parameters.Name = String.Format("S{0:00}E{1:00}", episode.SeasonNumber, episode.EpisodeNumber);

                    pageableRequest.AddIfNotNull(GetPagedRequests(MaxPages, parameters));
                }

                foreach (var seasonNumber in searchCriteria.Episodes.Select(v => v.SeasonNumber).Distinct())
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Season";
                    parameters.Name = String.Format("Season {0}", seasonNumber);

                    pageableRequest.AddIfNotNull(GetPagedRequests(MaxPages, parameters));
                }
            }

            return pageableRequest;
        }
开发者ID:nnic,项目名称:Sonarr,代码行数:30,代码来源:BroadcastheNetRequestGenerator.cs

示例2: GetSearchRequests

        public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequests = new List<IEnumerable<IndexerRequest>>();

            if (searchCriteria.Series.TvRageId > 0)
            {
                pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
                    String.Format("&rid={0}&season={1}&ep={2}",
                    searchCriteria.Series.TvRageId,
                    searchCriteria.SeasonNumber,
                    searchCriteria.EpisodeNumber)));
            }
            else
            {
                foreach (var queryTitle in searchCriteria.QueryTitles)
                {
                    pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
                        String.Format("&q={0}&season={1}&ep={2}",
                        NewsnabifyTitle(queryTitle),
                        searchCriteria.SeasonNumber,
                        searchCriteria.EpisodeNumber)));
                }
            }

            return pageableRequests;
        }
开发者ID:keep3r,项目名称:Sonarr,代码行数:26,代码来源:NewznabRequestGenerator.cs

示例3: CheckParameters

        internal static List<LicenseMessage> CheckParameters(this NavOrder order)
        {
            var returnMessageList = new List<LicenseMessage>();

            returnMessageList.AddIfNotNull(order.IsOrderNumberNullOrEmpty());
            returnMessageList.AddIfNotNull(order.IsOrderNumberGreaterThan20());
            returnMessageList.AddIfNotNull(order.IsActionValid());
            returnMessageList.AddIfNotNull(order.IsProductOrdersEmpty());

            return returnMessageList;
        }
开发者ID:MacarioTala,项目名称:LicenseService,代码行数:11,代码来源:NavOrderExtensions.cs

示例4: ExecuteXml

 public string ExecuteXml(string types = null, string routeIds = null, string stationIds = null)
 {
     var parameters = new List<Tuple<string, string>>();
     parameters.AddIfNotNull(types, new Tuple<string, string>("type", types));
     parameters.AddIfNotNull(routeIds, new Tuple<string, string>("routeid", routeIds));
     parameters.AddIfNotNull(stationIds, new Tuple<string, string>("stationid", stationIds));
     var formatter = new QueryStringFormatter();
     string queryString = formatter.Format(parameters);
     string requestUrl = _baseUrl + queryString;
     var requestExecutor = new HttpRequestor();
     string response = requestExecutor.ExecuteGet(requestUrl);
     return response;
 }
开发者ID:gartdan,项目名称:CTADotNet,代码行数:13,代码来源:RouteStatusApi.cs

示例5: GetActionDescriptors

        private static IEnumerable<ODataActionDescriptor> GetActionDescriptors(SwaggerRoute potentialSwaggerRoute, HttpConfiguration httpConfig)
        {
            Contract.Requires(potentialSwaggerRoute != null);
            Contract.Requires(httpConfig != null);

            var oDataActionDescriptors = new List<ODataActionDescriptor>();

            oDataActionDescriptors.AddIfNotNull(GetActionDescriptors(new HttpMethod("DELETE"), potentialSwaggerRoute.PathItem.delete, potentialSwaggerRoute, httpConfig));
            oDataActionDescriptors.AddIfNotNull(GetActionDescriptors(new HttpMethod("GET"), potentialSwaggerRoute.PathItem.get, potentialSwaggerRoute, httpConfig));
            oDataActionDescriptors.AddIfNotNull(GetActionDescriptors(new HttpMethod("POST"), potentialSwaggerRoute.PathItem.post, potentialSwaggerRoute, httpConfig));
            oDataActionDescriptors.AddIfNotNull(GetActionDescriptors(new HttpMethod("PUT"), potentialSwaggerRoute.PathItem.put, potentialSwaggerRoute, httpConfig));
            oDataActionDescriptors.AddIfNotNull(GetActionDescriptors(new HttpMethod("PATCH"), potentialSwaggerRoute.PathItem.patch, potentialSwaggerRoute, httpConfig));

            return oDataActionDescriptors;
        }
开发者ID:bigred8982,项目名称:Swashbuckle.OData,代码行数:15,代码来源:SwaggerRouteStrategy.cs

示例6: Print

 public override void Print(System.IO.StreamWriter writer)
 {
     Section.WriteTitle(writer, "Unique Hats");
     int cnt = 0;
     foreach (Item i in OrderedList)
     {
         double percent = Math.Round(((double)cnt) * 100 / ((double)Items.Keys.Count));
         Console.WriteLine("Progress: Item {0} of {1} (" + percent + "%)", cnt + 1, Items.Keys.Count);
         List<String> attribs = new List<string>();
         attribs.AddIfNotNull(i.PaintName);
         if (i.IsGifted)
             attribs.Add("Gifted");
         if (!i.IsCraftable)
             attribs.Add("Uncraftable");
         if (!i.IsTradable)
             attribs.Add("Untradable");
         //pretty print the item
         String item = TF2PricerMain.FormatItem(i, false, Items[i], attribs.ToArray());
         Price paint = null;
         if (i.PaintName != null)
             paint = TF2PricerMain.PriceSchema.GetPaintPrice(i[Item.Paint]);
         Price p = TF2PricerMain.PriceSchema.GetPrice(i);
         //so write the item, then follow up with the bp.tf prices
         Console.WriteLine(item + "\n");
         if (paint != null)
         {
             Console.WriteLine("Original: " + p.ToString());
             Console.WriteLine("Paint: " + paint.ToString());
             p += paint;
         }
         Console.WriteLine("Price: " + p.ToString());
         TF2PricerMain.GetInputPrice(item, writer, p.LowPrice, p.HighPrice);
         cnt++;
     }
 }
开发者ID:TheCommieDuck,项目名称:TF2TradePriceTool,代码行数:35,代码来源:UniqueHatSection.cs

示例7: ParseResponse

        public virtual IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
        {
            _indexerResponse = indexerResponse;

            var releases = new List<ReleaseInfo>();

            if (!PreProcess(indexerResponse))
            {
                return releases;
            }

            var document = LoadXmlDocument(indexerResponse);
            var items = GetItems(document);

            foreach (var item in items)
            {
                try
                {
                    var reportInfo = ProcessItem(item);

                    releases.AddIfNotNull(reportInfo);
                }
                catch (Exception itemEx)
                {
                    itemEx.Data.Add("Item", item.Title());
                    _logger.ErrorException("An error occurred while processing feed item from " + indexerResponse.Request.Url, itemEx);
                }
            }

            return releases;
        }
开发者ID:Djohnnie,项目名称:Sonarr,代码行数:31,代码来源:RssParser.cs

示例8: Print

 public override void Print(System.IO.StreamWriter writer)
 {
     Section.WriteTitle(writer, "Vintage Weapons");
     int cnt = 0;
     foreach (Item i in OrderedList)
     {
         double percent = Math.Round(((double)cnt) * 100 / ((double)Items.Keys.Count));
         Console.WriteLine("Progress: Item {0} of {1} (" + percent + "%)", cnt + 1, Items.Keys.Count);
         List<String> attribs = new List<string>();
         bool oddLevelled = false;
         attribs.AddIfNotNull(i.PaintName);
         if (i.IsGifted)
             attribs.Add("Gifted");
         //if the level is different to the default
         if (TF2PricerMain.Schema.DefaultVintageLevels[i.DefIndex] != i.Level)
         {
             attribs.Add("Level " + i.Level);
             oddLevelled = true;
         }
         //pretty print the item
         String item = TF2PricerMain.FormatItem(i, true, Items[i], attribs.ToArray());
         Price p = TF2PricerMain.PriceSchema.GetPrice(i);
         //so write the item, then follow up with the bp.tf prices
         Console.WriteLine(item + "\n");
         Console.WriteLine("Price: " + p.ToString());
         if (oddLevelled)
             Console.WriteLine("Note: Odd-levelled.");
         TF2PricerMain.GetInputPrice(item, writer, p.LowPrice, p.HighPrice);
         cnt++;
     }
 }
开发者ID:TheCommieDuck,项目名称:TF2TradePriceTool,代码行数:31,代码来源:VintageWeaponSection.cs

示例9: GetRecentRequests

        public virtual IList<IEnumerable<IndexerRequest>> GetRecentRequests()
        {
            var pageableRequests = new List<IEnumerable<IndexerRequest>>();

            pageableRequests.AddIfNotNull(GetPagedRequests("/feed/"));

            return pageableRequests;
        }
开发者ID:keep3r,项目名称:Sonarr,代码行数:8,代码来源:EztvRequestGenerator.cs

示例10: GetSearchRequests

        public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SeasonSearchCriteria searchCriteria)
        {
            var pageableRequests = new List<IEnumerable<IndexerRequest>>();

            pageableRequests.AddIfNotNull(GetPagedRequests("search", searchCriteria.Series.TvdbId, "S{0:00}", searchCriteria.SeasonNumber));

            return pageableRequests;
        }
开发者ID:nnic,项目名称:Sonarr,代码行数:8,代码来源:RarbgRequestGenerator.cs

示例11: GetRecentRequests

        public virtual IList<IEnumerable<IndexerRequest>> GetRecentRequests()
        {
            var pageableRequests = new List<IEnumerable<IndexerRequest>>();

            // We give kat a bit more pages to get to 100 total for recent, coz users have been missing releases.
            pageableRequests.AddIfNotNull(GetPagedRequests(4, "tv"));

            return pageableRequests;
        }
开发者ID:keep3r,项目名称:Sonarr,代码行数:9,代码来源:KickassTorrentsRequestGenerator.cs

示例12: GetRecentRequests

        public virtual IList<IEnumerable<IndexerRequest>> GetRecentRequests()
        {
            var pageableRequests = new List<IEnumerable<IndexerRequest>>();

            // TODO: We might consider getting multiple pages in the future, but atm we limit it to 1 page.
            pageableRequests.AddIfNotNull(GetPagedRequests(1, Settings.Categories.Concat(Settings.AnimeCategories), "tvsearch", ""));

            return pageableRequests;
        }
开发者ID:keep3r,项目名称:Sonarr,代码行数:9,代码来源:NewznabRequestGenerator.cs

示例13: GetSearchRequests

        public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequests = new List<IEnumerable<IndexerRequest>>();

            foreach (var queryTitle in searchCriteria.QueryTitles)
            {
                pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, "usearch",
                    PrepareQuery(queryTitle),
                    "category:tv",
                    String.Format("season:{0}", searchCriteria.SeasonNumber),
                    String.Format("episode:{0}", searchCriteria.EpisodeNumber)));

                pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, "usearch",
                    PrepareQuery(queryTitle),
                    String.Format("S{0:00}E{1:00}", searchCriteria.SeasonNumber, searchCriteria.EpisodeNumber),
                    "category:tv"));
            }

            return pageableRequests;
        }
开发者ID:keep3r,项目名称:Sonarr,代码行数:20,代码来源:KickassTorrentsRequestGenerator.cs

示例14: GetSearchRequests

        public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequests = new List<IEnumerable<IndexerRequest>>();

            foreach (var queryTitle in searchCriteria.QueryTitles)
            {
                pageableRequests.AddIfNotNull(GetPagedRequests(String.Format("{0}+{1:yyyy MM dd}",
                    queryTitle,
                    searchCriteria.AirDate)));
            }

            return pageableRequests;
        }
开发者ID:keep3r,项目名称:Sonarr,代码行数:13,代码来源:OmgwtfnzbsRequestGenerator.cs

示例15: GetSearchRequests

        public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SeasonSearchCriteria searchCriteria)
        {
            var pageableRequests = new List<IEnumerable<IndexerRequest>>();

            foreach (var queryTitle in searchCriteria.QueryTitles)
            {
                pageableRequests.AddIfNotNull(GetPagedRequests(String.Format("/search/index.php?show_name={0}&season={1}&mode=rss",
                    queryTitle,
                    searchCriteria.SeasonNumber)));
            }

            return pageableRequests;
        }
开发者ID:keep3r,项目名称:Sonarr,代码行数:13,代码来源:EztvRequestGenerator.cs


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