本文整理汇总了C#中Library.List类的典型用法代码示例。如果您正苦于以下问题:C# List类的具体用法?C# List怎么用?C# List使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
List类属于Library命名空间,在下文中一共展示了List类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public Setup()
{
LoadPlugins();
AllTitlesProcessed = false;
CurrentTitle = null;
CurrentTitleIndex = 0;
current = this;
//_titleCollection.loadTitleCollection();
_ImporterSelection = new Choice();
List<string> _Importers = new List<string>();
foreach (OMLPlugin _plugin in availablePlugins) {
OMLApplication.DebugLine("[Setup] Adding " + _plugin.Name + " to the list of Importers");
_Importers.Add(_plugin.Description);
}
_ImporterSelection.Options = _Importers;
_ImporterSelection.ChosenChanged += delegate(object sender, EventArgs e)
{
OMLApplication.ExecuteSafe(delegate
{
Choice c = (Choice)sender;
ImporterDescription = @"Notice: " + GetPlugin().SetupDescription();
OMLApplication.DebugLine("Item Chosed: " + c.Options[c.ChosenIndex]);
});
};
}
示例2: GetAll
public static List<Copy> GetAll()
{
List<Copy> allcopies = new List<Copy>{};
SqlConnection conn = DB.Connection();
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM copies;", conn);
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
int copyId = rdr.GetInt32(0);
int copyBookId = rdr.GetInt32(1);
Copy newCopy = new Copy(copyBookId, copyId);
allcopies.Add(newCopy);
}
if (rdr != null)
{
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
return allcopies;
}
示例3: AddBytes
public static void AddBytes(List<byte> list, byte[] array)
{
foreach (byte b in array)
{
list.Add(b);
}
}
示例4: GetAll
public static List<Patron> GetAll()
{
List<Patron> allPatrons = new List<Patron> {};
SqlConnection conn = DB.Connection();
conn.Open();
SqlDataReader rdr = null;
SqlCommand cmd = new SqlCommand ("SELECT * FROM patrons;", conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
int patronId = rdr.GetInt32(0);
string patronFirstName = rdr.GetString(1);
string patronLastName = rdr.GetString(2);
string phoneNumber = rdr.GetString(3);
Patron newPatron = new Patron (patronFirstName, patronLastName, phoneNumber, patronId);
allPatrons.Add(newPatron);
}
if (rdr != null)
{
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
return allPatrons;
}
示例5: GetBooks
public static List<Book> GetBooks(bool useDB)
{
try
{
DataTable table;
List<Book> books = new List<Book>();
if (useDB)
{
table = DBLibrary.GetBooks(cs);
}
else
{
table = DBLibrary.GetTestData();
}
Book book;
foreach (DataRow row in table.Rows)
{
book = new Book((int)row[0]);
book.Name = row["name"].ToString();
book.Author = row["author"].ToString();
book.Country = row["country"].ToString();
book.Year = (int)row["year"];
books.Add(book);
}
return books;
}
catch (Exception)
{
throw;
}
}
示例6: GetAll
public static List<Copy> GetAll()
{
List<Copy> allCopies = new List<Copy> {};
SqlConnection conn = DB.Connection();
conn.Open();
SqlDataReader rdr = null;
SqlCommand cmd = new SqlCommand ("SELECT * FROM copies;", conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
int copyId = rdr.GetInt32(0);
DateTime copyCheckoutDate = rdr.GetDateTime(1);
string copyCondition = rdr.GetString(2);
int bookId = rdr.GetInt32(3);
DateTime copyDueDate = rdr.GetDateTime(4);
Copy newCopy = new Copy (copyCondition, bookId, copyCheckoutDate, copyDueDate, copyId);
allCopies.Add(newCopy);
}
if (rdr != null)
{
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
return allCopies;
}
示例7: ConvertBoolsToBytes
public static List<byte> ConvertBoolsToBytes(bool[] data)
{
List<byte> result = new List<byte>();
//wrap into 8 bit bunches of a byte
byte eightBits = 0;
int counter = 0;
foreach (bool b in data)
{
//write to next location on eightBits
if (b)
{
eightBits |= Writer.Masks[counter];
}
counter++;
if (counter > 7)
{
counter = 0;
result.Add(eightBits);
eightBits = 0;
}
}
if (counter > 0)
{
//pad out the eightBits with zeros then add
result.Add(eightBits);
}
return result;
}
示例8: DownloadAllVideos
public void DownloadAllVideos(PDownload pDownload)
{
Broadcasts broadcasts = GetBroadcasts(pDownload.User);
broadcasts.broadcasts = broadcasts.broadcasts.Where(b => b.available_for_replay || b.state == "RUNNING").ToList();
if (pDownload.IsReverseOrder) broadcasts.broadcasts.Reverse();
#region Selected Videos
List<int> selectedVideos = pDownload.SelectedVideos;
if (selectedVideos.Any())
{
List<Broadcast> selectedBroadcasts = new List<Broadcast>();
selectedBroadcasts.AddRange(selectedVideos.Select(selectedVideo => broadcasts.broadcasts[selectedVideo]));
broadcasts.broadcasts = selectedBroadcasts.ToList();
}
#endregion
#region Selected Broadcasts
List<string> selectedBroadcastsText = pDownload.SelectedBroadcasts;
if (selectedBroadcastsText.Any())
{
broadcasts.broadcasts =
selectedBroadcastsText.Select(
selectedBroadcast => broadcasts.broadcasts.First(b => b.id == selectedBroadcast)).ToList();
}
#endregion
Console.WriteLine(broadcasts.broadcasts.Count + " broadcasts found.");
foreach (var broadcast in broadcasts.broadcasts)
{
DownloadVideos(broadcast, pDownload.DownloadLiveStream);
}
}
示例9: LoadData
private void LoadData(DTO.HoaDon data)
{
listHoaDonDetail = HoaDonDetailBus.GetListByIdHoaDon(data.Id);
dataUser = data.User;
lbMaHD.Text = data.MaHoaDon;
lbNguoiNhap.Text = dataUser == null ? string.Empty : dataUser.UserName;
lbNgayGio.Text = data.CreateDate.ToString(Constant.DEFAULT_DATE_TIME_FORMAT);
lbGhiChu.Text = data.GhiChu;
foreach (DTO.HoaDonDetail detail in listHoaDonDetail)
{
ListViewItem lvi = new ListViewItem();
lvi.SubItems.Add(detail.SanPham.Id.ToString());
lvi.SubItems.Add((lvThongTin.Items.Count + 1).ToString());
lvi.SubItems.Add(detail.SanPham.MaSanPham + Constant.SYMBOL_LINK_STRING + detail.SanPham.Ten);
lvi.SubItems.Add(detail.SoLuong.ToString());
lvi.SubItems.Add(detail.SanPham.DonViTinh);
lvi.SubItems.Add(detail.SanPham.GiaMua.ToString(Constant.DEFAULT_FORMAT_MONEY));
lvi.SubItems.Add(detail.SanPham.GiaBan.ToString(Constant.DEFAULT_FORMAT_MONEY));
lvi.SubItems.Add(detail.ThanhTien.ToString(Constant.DEFAULT_FORMAT_MONEY));
lvThongTin.Items.Add(lvi);
}
lbTongHD.Text = data.ThanhTien.ToString(Constant.DEFAULT_FORMAT_MONEY);
}
示例10: btnBrowse_Click
private void btnBrowse_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
btnUpload.Enabled = true;
lblError.Text = "";
#region dataGridView stuff
List<String> files = openFileDialog1.SafeFileNames.ToList();
List<Library.File> myFiles = new List<Library.File>();
foreach (string f in files)
{
Library.File file = new Library.File(f, "", Project);
myFiles.Add(file);
}
dataGridView1.DataSource = myFiles;
dataGridView1.Columns.Remove("id");
dataGridView1.Columns.Remove("VersionNr");
dataGridView1.Columns.Remove("FileLock");
dataGridView1.Columns.Remove("FileLockTime");
dataGridView1.Columns.Remove("Project");
dataGridView1.AutoResizeColumns();
#endregion
foreach (string filepath in openFileDialog1.FileNames)
{
fullFilePathList.Add(filepath);
fileToUploadList.Add(Path.GetFileName(filepath));
}
}
}
示例11: buttonReserve_Click
private void buttonReserve_Click(object sender, EventArgs e)
{
LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();
List<int> books = new List<int>();
foreach (DataGridViewRow row in dataGridViewBooks.SelectedRows)
{
if (row.Cells[0].Value != null)
{
books.Add(Convert.ToInt32(row.Cells[0].Value));
}
}
if (books.Count > 0)
{
var client = (from c in context.Clients
where c.ClientID == id
select c).SingleOrDefault();
foreach (LibraryReader.ClientsBook cBook in client.ClientsBooks)
{
if (books.Contains(cBook.BookID))
{
cBook.Reservation = true;
MessageBox.Show("Резервирането е успешно!");
}
}
context.SaveChanges();
}
}
示例12: BackEnd
public BackEnd(string data)
{
words = new List<string>(data.Split(' ', '\r'));
content = new List<string>(data.Split(' ', '\r', '\n'));
frequency = BuildOccu(content);
length = BuildLeng(content);
}
示例13: ReadLine
public override string ReadLine()
{
if (stream.Position == stream.Length)
{
return null;
}
var byteList = new List<int>();
while (stream.Position != stream.Length)
{
int b = stream.ReadByte();
if (b == (int)'\n')
{
break;
}
else
{
byteList.Add(b);
}
}
while (byteList[byteList.Count - 1] == (int)'\r')
{
byteList.RemoveAt(byteList.Count - 1);
}
return Encoding.UTF8.GetString(byteList.Select(value => (byte)value).ToArray());
}
示例14: Install
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
var installdir = GetParameter("targetdir");
string msg = "";
foreach (var k in Context.Parameters.Keys)
msg += (k + "\n");
msg += "VALUES:\n";
foreach (var v in Context.Parameters.Values)
msg += (v + "\n");
//MessageBox.Show(msg);
List<string> writeableDirs = new List<string>();
string configDir = Path.Combine(Path.Combine(installdir, "Myro"), "config");
string storeDir = Path.Combine(Path.Combine(installdir, "Myro"), "store");
writeableDirs.Add(configDir);
writeableDirs.Add(storeDir);
writeableDirs.AddRange(Directory.GetDirectories(configDir, "*", SearchOption.AllDirectories));
writeableDirs.AddRange(Directory.GetDirectories(storeDir, "*", SearchOption.AllDirectories));
string dirs = "";
foreach (var d in writeableDirs)
{
dirs += (d + "\n");
if (GrantModifyAccessToFolder("Everyone", d) != true)
throw new Exception("Couldn't make " + d + " writeable");
}
//MessageBox.Show("Made writeable:\n" + dirs);
}
示例15: GetPortInfo
public List<PortInfo> GetPortInfo()
{
List<PortInfo> portInfo = new List<PortInfo>();
string ip = Convert.ToString(Net.GetExternalIpAddress(30000));
foreach (INetFwOpenPort port in GetAuthOpenPortsList())
{
portInfo.Add(new PortInfo()
{
IP = ip,
Port = port.Port,
Name = port.Name
});
//sb.AppendLine(ip + ":" + port.Port + " - " + port.Name + " - " + port.Enabled + " - " + port.IpVersion);
Console.WriteLine(port.Port + ", " + port.Name);
}
/*StringBuilder sb = new StringBuilder();
foreach (INetFwOpenPort port in GetAuthOpenPortsList())
{
sb.AppendLine(ip + ":" + port.Port + " - " + port.Name + " - " + port.Enabled + " - " + port.IpVersion);
Console.WriteLine(port.Port + ", " + port.Name);
}
System.Windows.Forms.MessageBox.Show(sb.ToString());*/
return portInfo;
}