本文整理汇总了C#中Model.List.Add方法的典型用法代码示例。如果您正苦于以下问题:C# List.Add方法的具体用法?C# List.Add怎么用?C# List.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SortTest
public void SortTest()
{
var episodes = new List<TvdbEpisode>();
episodes.Add(new TvdbEpisode { SeasonNumber = 2, EpisodeNumber = 1 });
episodes.Add(new TvdbEpisode { SeasonNumber = 1, EpisodeNumber = 1 });
episodes.Add(new TvdbEpisode { SeasonNumber = 1, EpisodeNumber = 5 });
episodes.Add(new TvdbEpisode { SeasonNumber = 3, EpisodeNumber = 12 });
episodes.Add(new TvdbEpisode { SeasonNumber = 2, EpisodeNumber = 12 });
episodes.Sort(new TvEpisodeComparer());
Assert.Equal(1, episodes[0].SeasonNumber);
Assert.Equal(1, episodes[0].EpisodeNumber);
Assert.Equal(1, episodes[1].SeasonNumber);
Assert.Equal(5, episodes[1].EpisodeNumber);
Assert.Equal(2, episodes[2].SeasonNumber);
Assert.Equal(1, episodes[2].EpisodeNumber);
Assert.Equal(2, episodes[3].SeasonNumber);
Assert.Equal(12, episodes[3].EpisodeNumber);
Assert.Equal(3, episodes[4].SeasonNumber);
Assert.Equal(12, episodes[4].EpisodeNumber);
}
示例2: UCSalePlanView_SaveEvent
void UCSalePlanView_SaveEvent(object sender, EventArgs e)
{
try
{
gvPurchasePlanList.EndEdit();
List<SysSQLString> listSql = new List<SysSQLString>();
SysSQLString sysStringSql = new SysSQLString();
sysStringSql.cmdType = CommandType.Text;
Dictionary<string, string> dic = new Dictionary<string, string>();//参数
string sql1 = string.Format(@" Update tb_parts_sale_plan Set [email protected]_suspend,[email protected]_reason,[email protected]_by,
[email protected]_name,[email protected]_time,[email protected],[email protected]_name where [email protected]_plan_id;");
dic.Add("is_suspend", chkis_suspend.Checked ? "0" : "1");//选中(中止):0,未选中(不中止):1
dic.Add("suspend_reason", txtsuspend_reason.Caption.Trim());
dic.Add("update_by", GlobalStaticObj.UserID);
dic.Add("update_name", GlobalStaticObj.UserName);
dic.Add("update_time", Common.LocalDateTimeToUtcLong(DateTime.Now).ToString());
dic.Add("operators", GlobalStaticObj.UserID);
dic.Add("operator_name", GlobalStaticObj.UserName);
dic.Add("sale_plan_id", planId);
sysStringSql.sqlString = sql1;
sysStringSql.Param = dic;
listSql.Add(sysStringSql);
foreach (DataGridViewRow dr in gvPurchasePlanList.Rows)
{
string is_suspend = "1";
if (dr.Cells["is_suspend"].Value == null)
{ is_suspend = "1"; }
if ((bool)dr.Cells["is_suspend"].EditedFormattedValue)
{ is_suspend = "0"; }
else
{ is_suspend = "1"; }
sysStringSql = new SysSQLString();
sysStringSql.cmdType = CommandType.Text;
dic = new Dictionary<string, string>();
dic.Add("is_suspend", is_suspend);
dic.Add("sale_plan_id", planId);
dic.Add("parts_code", dr.Cells["parts_code"].Value.ToString());
string sql2 = "Update tb_parts_sale_plan_p set [email protected]_suspend where [email protected]_plan_id and [email protected]_code;";
sysStringSql.sqlString = sql2;
sysStringSql.Param = dic;
listSql.Add(sysStringSql);
}
if (DBHelper.BatchExeSQLStringMultiByTrans("修改采购计划单", listSql))
{
MessageBoxEx.Show("保存成功!");
uc.BindgvSalePlanList();
deleteMenuByTag(this.Tag.ToString(), uc.Name);
}
else
{
MessageBoxEx.Show("保存失败!");
}
}
catch (Exception ex)
{
MessageBoxEx.Show("操作失败!");
}
}
示例3: GetPlistCatalogAccountTrs
public List<DicReader> GetPlistCatalogAccountTrs(string key, string catalogCode
, bool includeDescendants, PagingInput paging)
{
paging.Valid();
if (string.IsNullOrEmpty(catalogCode))
{
throw new ArgumentNullException("catalogCode");
}
Func<SqlFilter> filter = () =>
{
var parameters = new List<DbParameter>();
var filterString = " where (a.Name like @key or a.Code like @key or a.LoginName like @key)";
parameters.Add(CreateParameter("key", "%" + key + "%", DbType.String));
if (!includeDescendants)
{
parameters.Add(CreateParameter("CatalogCode", catalogCode, DbType.String));
filterString += " and [email protected]";
}
else
{
parameters.Add(CreateParameter("CatalogCode", catalogCode + "%", DbType.String));
filterString += " and a.CatalogCode like @CatalogCode";
}
return new SqlFilter(filterString, parameters.ToArray());
};
return base.GetPlist("CatalogAccountTr", filter, paging);
}
示例4: Find
public async Task<ContentResponse> Find(string query, int maxItems = 25, bool getArtists = true,
bool getAlbums = true, bool getTracks = true)
{
if (string.IsNullOrWhiteSpace(query))
throw new ArgumentNullException("query");
if (maxItems > 25)
throw new ArgumentOutOfRangeException("maxItems");
await Authenticate();
RestRequest request = GetPopulatedRequest("1/content/{namespace}/search");
request.AddQueryString("q", query);
if (maxItems != 25)
{
request.AddQueryString("maxItems", maxItems);
}
if (!(getArtists && getAlbums && getTracks))
{
var filter = new List<string>();
if (getArtists) filter.Add("artists");
if (getAlbums) filter.Add("albums");
if (getTracks) filter.Add("tracks");
request.AddQueryString("filters", filter.Aggregate("", (c, n) => c.Length == 0 ? c + n : c + ("+" + n)));
}
request.AddQueryString("accessToken", "Bearer " + Token.AccessToken);
return await _client.ExecuteAsync<ContentResponse>(request);
}
示例5: GetChapters
public List<ChapterInfo> GetChapters()
{
var chapters = new List<ChapterInfo>();
Regex regex = new Regex(@"<dt>(.*?)<\/dt>|<dd><a\s*href=""(.*?)"">(.*?)<\/a><\/dd>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
var matches = regex.Matches(_html);
if (matches.Count > 0)
{
foreach (Match match in matches)
{
DateTime latestUpdateDate;
DateTime.TryParse("20"+match.Groups[6].Value, out latestUpdateDate);
if (string.IsNullOrEmpty(match.Groups[1].Value))
{
chapters.Add(new ChapterInfo
{
IsSubTitle = false,
ChapterUrl = match.Groups[2].Value,
ChapterName = match.Groups[3].Value,
});
}
else
{
chapters.Add(new ChapterInfo
{
IsSubTitle = true,
ChapterName = match.Groups[1].Value,
});
}
}
}
return chapters;
}
示例6: UCYTManager
/// <summary>
/// 初始化窗体
/// </summary>
public UCYTManager()
{
InitializeComponent();
base.AddEvent += new ClickHandler(UCYTManager_AddEvent);
base.CopyEvent += new ClickHandler(UCYTManager_CopyEvent);
base.EditEvent += new ClickHandler(UCYTManager_EditEvent);
base.DeleteEvent += new ClickHandler(UCYTManager_DeleteEvent);
base.VerifyEvent += new ClickHandler(UCYTManager_VerifyEvent);
base.SubmitEvent += new ClickHandler(UCYTManager_SubmitEvent);
base.ExportEvent += new ClickHandler(UCYTManager_ExportEvent);
base.ViewEvent += new ClickHandler(UCYTManager_ViewEvent);
base.PrintEvent += new ClickHandler(UCYTManager_PrintEvent);
base.SetEvent += new ClickHandler(UCYTManager_SetEvent);
#region 预览、打印设置
string printObject = "tb_parts_purchase_order_ytcg";
string printTitle = "宇通采购订单";
List<string> listNotPrint = new List<string>();
listNotPrint.Add(purchase_order_yt_id.Name);
listNotPrint.Add(viewfile.Name);
PaperSize paperSize = new PaperSize();
paperSize.Width = 297;
paperSize.Height = 210;
businessPrint = new BusinessPrint(gvYTPurchaseOrderList, printObject, printTitle, paperSize, listNotPrint);
#endregion
}
示例7: DelSubject
public static void DelSubject(List<Priority> SP, List<String> SubjectID)
{
List<String> SB = new List<String>();
if (SubjectID != null)
{
foreach (var r in SP)
if (!SubjectID.Contains(r.SubjectID.ToString()))
SB.Add(r.SubjectID);
}
else
{
foreach (var r in SP)
SB.Add(r.SubjectID);
}
for (int i = 0; i < SB.Count(); i++)
{
var a = SB[i];
var nhom = (from m in InputHelper.db.nhoms
where m.MaMonHoc.Equals(a)
select m.Nhom1).ToList();
foreach (var r in nhom)
{
byte aByte = Convert.ToByte(r);
InputHelper.Groups.FirstOrDefault(m => m.Value.MaMonHoc == SB[i] && m.Value.Nhom == aByte).Value.IsIgnored = false;
}
OutputHelper.SaveOBJ("Groups", InputHelper.Groups);
}
}
示例8: InitializeDishOptionsChoicesList
public void InitializeDishOptionsChoicesList()
{
MyDishOptionsChoices = new List<DishOptionsChoice>();
var threeSideOptionalChoices = new FakeOptionalSideThreeOptionChoices().MyDishOptionsChoices;
var fourSideOptionalChoices = new FakeOptionalSideFourOptionChoices().MyDishOptionsChoices;
var threeSideRequiredChoices = new FakeRequiredSideThreeOptionChoices().MyDishOptionsChoices;
var twelveSideRequiredChoices = new FakeRequiredSideOptionChoices().MyDishOptionsChoices;
foreach (var dishOptionsChoice in threeSideOptionalChoices)
{
MyDishOptionsChoices.Add(dishOptionsChoice);
}
foreach (var dishOptionsChoice in fourSideOptionalChoices)
{
MyDishOptionsChoices.Add(dishOptionsChoice);
}
foreach (var dishOptionsChoice in threeSideRequiredChoices)
{
MyDishOptionsChoices.Add(dishOptionsChoice);
}
foreach (var dishOptionsChoice in twelveSideRequiredChoices)
{
MyDishOptionsChoices.Add(dishOptionsChoice);
}
}
示例9: GetPlistVisitingLogTrs
public List<DicReader> GetPlistVisitingLogTrs(string key, DateTime? leftVisitOn, DateTime? rightVisitOn, PagingInput paging)
{
paging.Valid();
if (key != null)
{
key = key.Trim();
}
Func<SqlFilter> filter = () =>
{
var parameters = new List<DbParameter>();
var filterString = @" where a.LoginName like @key ";
parameters.Add(CreateParameter("key", "%" + key + "%", DbType.String));
if (leftVisitOn.HasValue)
{
parameters.Add(CreateParameter("leftVisitOn", leftVisitOn.Value, DbType.DateTime));
filterString += " and a.VisitOn>[email protected]";
}
if (rightVisitOn.HasValue)
{
parameters.Add(CreateParameter("rightVisitOn", rightVisitOn.Value, DbType.DateTime));
filterString += " and a.VisitOn<@rightVisitOn";
}
return new SqlFilter(filterString, parameters.ToArray());
};
return base.GetPlist("VisitingLog", filter, paging);
}
示例10: GetUsers
public IList<User> GetUsers()
{
List<User> returnList = new List<User>();
returnList.Add(new User() { Id = Guid.NewGuid(), Name = "Tester0" });
returnList.Add(new User() { Id = Guid.NewGuid(), Name = "Tester1" });
returnList.Add(new User() { Id = Guid.NewGuid(), Name = "Tester2" });
returnList.Add(new User() { Id = Guid.NewGuid(), Name = "Tester3" });
returnList.Add(new User() { Id = Guid.NewGuid(), Name = "Tester4" });
return returnList;
}
示例11: PrepareMapping
protected override IList<MappingConfiguration> PrepareMapping()
{
List<MappingConfiguration> mappingConfigurations = new List<MappingConfiguration>();
mappingConfigurations.Add(this.PrepareGroupMappingConfig());
mappingConfigurations.Add(this.PrepareUserMappingConfig());
if (this.shouldHaveDeletesTable)
{
mappingConfigurations.Add(this.PrepareEntityDeleteConfig());
}
return mappingConfigurations;
}
示例12: GetPlistGroupAccountTrs
public List<DicReader> GetPlistGroupAccountTrs(string key, Guid groupId, PagingInput paging)
{
paging.Valid();
Func<SqlFilter> filter = () =>
{
var parameters = new List<DbParameter>();
const string filterString = @" where (a.Name like @key
or a.Code like @key
or a.LoginName like @key) and [email protected]";
parameters.Add(CreateParameter("key", "%" + key + "%", DbType.String));
parameters.Add(CreateParameter("GroupId", groupId, DbType.Guid));
return new SqlFilter(filterString, parameters.ToArray());
};
return base.GetPlist("GroupAccountTr", filter, paging);
}
示例13: Send_Click
protected void Send_Click(object sender, EventArgs e)
{
string exception = "";
string mSenderID = (string)Session["username"];
string mMessage = Message.Text;
int mRead = 0;
DateTime mSendTime = DateTime.Now;
string mTitle = Title.Text;
List<Message> msgList = new List<Message>();
if (Receive.Text == "0")
{
List<string> names = new List<string>();
foreach (ListItem item in Receive.Items)
{
if (item.Value == "0")
continue;
Message msg = new Message();
msg.MSenderID = mSenderID;
msg.MReceiveID = item.Value;
msg.MMessage = mMessage;
msg.MRead = mRead;
msg.MSendTime = mSendTime;
msg.MTitle = mTitle;
msgList.Add(msg);
}
}
else
{
string mReceiveID = Receive.Text;
Message msg = new Message();
msg.MSenderID = mSenderID;
msg.MReceiveID = mReceiveID;
msg.MMessage = mMessage;
msg.MRead = mRead;
msg.MSendTime = mSendTime;
msg.MTitle = mTitle;
msgList.Add(msg);
}
if (MessageBLL.Insert(msgList, ref exception))
{
Response.Write("<script>alert('发送成功!')</script>");
}
else
{
Response.Write("<script>alert('发送失败!')</script>");
}
}
示例14: GetProductList
public IList<ProductInfo> GetProductList(int pageIndex, int pageSize, out int Total)
{
using (MyContext db = new MyContext())
{
Total = (from c in db.Product
orderby c.ID
select c).Count();
var items = (from c in db.Product
orderby c.ID
select c).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
IList<ProductInfo> ProductInfos = new List<ProductInfo>();
foreach (var item in items)
{
ProductInfo info = new ProductInfo();
info.ID = item.ID;
info.ProductTypeID = item.ProductTypeID;
info.ProductTypeName = item.ProductType.ProductTypeName;//导航属性的特点
info.Image = item.Image;
info.ProductName = item.ProductName;
info.MarketPrice = item.MarketPrice;
info.NewPrice = item.NewPrice;
info.GetDate = item.GetDate.ToShortDateString();
info.Enable = item.Enable;
ProductInfos.Add(info);
}
return ProductInfos;
}
}
示例15: Filter_Get_Yarn_Head_Count
public void Filter_Get_Yarn_Head_Count(int iDisplayLength, int iDisplayStart, int iSortCol_0, string sSortDir_0, string sSearch)
{
int filteredCount = 0;
List<Yarn_Head_Count> Yarn_Head_Count_List = new List<Yarn_Head_Count>();
DataTable dt = Yarn_Head_Count_DA.Filter_Get_Yarn_Head_Count(iDisplayLength, iDisplayStart, iSortCol_0, sSortDir_0, sSearch);
foreach (DataRow row in dt.Rows)
{
filteredCount = int.Parse(row["TotalCount"].ToString());
Yarn_Head_Count_List.Add(new Yarn_Head_Count
{
ID = int.Parse(row["ID"].ToString()),
Head_Count = int.Parse(row["Head_Count"].ToString()),
ForEdit = row["ID"].ToString(),
ForDelete = row["ID"].ToString()
});
}
var result = new
{
iTotalRecords = GetTotal_Yarn_Head_Count_Count(),
iTotalDisplayRecords = filteredCount,
aaData = Yarn_Head_Count_List
};
JavaScriptSerializer js = new JavaScriptSerializer();
Context.Response.Write(js.Serialize(result));
}