本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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++;
}
}
示例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;
}
示例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++;
}
}
示例9: GetRecentRequests
public virtual IList<IEnumerable<IndexerRequest>> GetRecentRequests()
{
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
pageableRequests.AddIfNotNull(GetPagedRequests("/feed/"));
return pageableRequests;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}