本文整理汇总了C#中Data.List类的典型用法代码示例。如果您正苦于以下问题:C# List类的具体用法?C# List怎么用?C# List使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
List类属于Data命名空间,在下文中一共展示了List类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RanksSort
public List<Ranks> RanksSort(List<Ranks> ranks)
{
long count = ranks.Count;
for (int i = 0; i < count - 1; i++)
for (int j = 0; j < count - 1 - i; j++)
{
if (ranks[j].Solved < ranks[j + 1].Solved)
{
long t = ranks[j].Position;
ranks[j].Position = ranks[j + 1].Position;
ranks[j + 1].Position = t;
Ranks rk = ranks[j];
ranks[j] = ranks[j + 1];
ranks[j + 1] = rk;
}
else if (ranks[j].Solved != 0 && ranks[j + 1].Solved != 0 && ranks[j].Solved == ranks[j + 1].Solved)
if(ranks[j].LastTimeOfAc > ranks[j + 1].LastTimeOfAc)
{
long t = ranks[j].Position;
ranks[j].Position = ranks[j + 1].Position;
ranks[j + 1].Position = t;
Ranks rk = ranks[j];
ranks[j] = ranks[j + 1];
ranks[j + 1] = rk;
}
}
return ranks;
}
示例2: ReadIFeedItems
public List<IFeedItem> ReadIFeedItems(Uri uri)
{
var feedItems = new List<Data.IFeedItem>();
SyndicationFeed syndicationFeed;
using (var xmlReader = XmlReader.Create(uri.AbsoluteUri))
{
syndicationFeed = SyndicationFeed.Load(xmlReader);
xmlReader.Close();
}
foreach (var item in syndicationFeed.Items)
{
var feedItem = new FeedItem();
var id = Guid.NewGuid();
feedItem.Id = Guid.TryParse(item.Id, out id) ? new Guid(item.Id) : id;
feedItem.Title = item.Title.Text;
feedItem.Mp3Url = item.Links[0].Uri;
feedItem.PublishDate = item.PublishDate.DateTime;
feedItems.Add(feedItem);
}
var ret = new List<IFeedItem>();
feedItems.ForEach(x => ret.Add(new FeedItem() { Id = x.Id, Mp3Url = x.Mp3Url, PublishDate = x.PublishDate, Title = x.Title }));
return ret;
}
示例3: actualizarSectoresEdificio
public static void actualizarSectoresEdificio(edificio edificio, List<sector> sectores)
{
try {
admEntities db = Datos.getDB();
var s = db.edificios_sectores.Where(x => x.dir_edificio == edificio.direccion).ToList();
foreach (var sectB in s)
{
db.edificios_sectores.Remove(sectB);
}
foreach (sector sect in sectores)
{
edificios_sectores es = new edificios_sectores();
es.dir_edificio = edificio.direccion;
es.id_sector = sect.idsector;
db.edificios_sectores.Add(es);
}
db.SaveChanges();
}
catch (Exception e)
{
string str = e.InnerException == null ? e.Message : e.InnerException.Message;
Logger.Log.write(str);
throw e;
}
}
示例4: ValidateFields
/// <summary>
/// Validates the field values of this object. Override this method to enable
/// validation of field values.
/// </summary>
/// <param name="validationResults">The validation results, add additional results to this list.</param>
protected override void ValidateFields(List<IFieldValidationResult> validationResults)
{
if (string.IsNullOrWhiteSpace(Name))
{
validationResults.Add(FieldValidationResult.CreateError(NameProperty, "Name of room is required"));
}
}
示例5: StatC5CX
public void StatC5CX(List<DwNumber> numbers, string dbName)
{
string[] dmNames = new string[] { "Peroid", "He" };
string[] numberTypes = new string[] { "A2", "A3", "A4", "A6", "A7", "A8" };
DwC5CXSpanBiz spanBiz = new DwC5CXSpanBiz(dbName);
foreach (var numberType in numberTypes)
{
Dictionary<string, Dictionary<string, int>> lastSpanDict = new Dictionary<string, Dictionary<string, int>>(16);
List<DwC5CXSpan> c5cxSpans = new List<DwC5CXSpan>(numbers.Count * 20);
string newNumberType = numberType.Replace("A", "C");
string tableName = string.Format("{0}{1}", "C5", newNumberType);
spanBiz.DataAccessor.TableName = ConfigHelper.GetDwSpanTableName(tableName);
long lastP = spanBiz.DataAccessor.SelectLatestPeroid(string.Empty);
foreach (DwNumber number in numbers)
{
var cxNumbers = NumberCache.Instance.GetC5CXNumbers(number.C5, newNumberType);
var c5cxSpanList = this.GetC5CXSpanList(lastSpanDict, cxNumbers, number, dmNames);
if (number.P > lastP)
c5cxSpans.AddRange(c5cxSpanList);
}
spanBiz.DataAccessor.Insert(c5cxSpans, SqlInsertMethod.SqlBulkCopy);
Console.WriteLine("{0} {1} Finished", dbName, tableName);
}
Console.WriteLine("{0} {1} Finished", dbName, "ALL C5CX Span");
}
示例6: getAllStaff
public static List<Staff> getAllStaff()
{
List<Staff> StaffsList = new List<Staff>();
//Connect to SQL Server
SqlConnection conn = new SqlConnection("Data Source=(local); Database=WebDevelopmentDB; Integrated Security=SSPI");
//Select all columns for a given StaffID as well as their password hash
SqlCommand cmd = new SqlCommand("SELECT dbo.Staff.GivenName, dbo.Staff.Surname, dbo.Staff.Email, dbo.Staff.PhoneNumber1, dbo.Staff.PhoneNumber2, dbo.Staff.Role, dbo.Accounts.PassHash FROM dbo.Staff INNER JOIN dbo.Accounts ON dbo.Staff.StaffID = dbo.Accounts.AccID)", conn);
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read()) {
StaffsList.Add(new Staff{
GivenName = rdr[0].ToString(),
Surname = rdr[1].ToString(),
Address = rdr[2].ToString(),
Email = rdr[3].ToString(),
Phone1 = rdr[4].ToString(),
Phone2 = rdr[5].ToString(),
Role = rdr[6].ToString(),
PassHash = rdr[7].ToString()});
}
//Close the reader and the SQL connection
if (rdr != null) {
rdr.Close();
}
conn.Close();
return StaffsList;
}
示例7: ValidateFields
/// <summary>
/// Validates the field values of this object. Override this method to enable
/// validation of field values.
/// </summary>
/// <param name="validationResults">The validation results, add additional results to this list.</param>
protected override void ValidateFields(List<IFieldValidationResult> validationResults)
{
if (string.IsNullOrWhiteSpace(ApiKey))
{
validationResults.Add(FieldValidationResult.CreateError(ApiKeyProperty, "Api key is required"));
}
}
示例8: GetFarFromOneRelations
public static List<UserProfile> GetFarFromOneRelations(Guid userId)
{
// On cherche nos relations. On cherche les relations de nos relations => récursif
List<UserProfile> listUserRelations = GetRelations(userId);
List<UserProfile> listLoggedUserRelation = GetRelations((Guid)(Membership.GetUser(System.Web.HttpContext.Current.User.Identity.Name, false).ProviderUserKey));
List<UserProfile> listFarFromOneRelations = new List<UserProfile>();
// We search all the directly connected users to the actual logged user relations
foreach (UserProfile userRelation in listUserRelations)
{
listFarFromOneRelations.AddRange(GetRelations((Guid)(Membership.GetUser(userRelation.UserName, false).ProviderUserKey)));
}
UserProfile actualUser = UserProfile.GetUserProfile(System.Web.HttpContext.Current.User.Identity.Name);
while(listFarFromOneRelations.Contains(actualUser))
{
// We delete all the occurences of the actual user
listFarFromOneRelations.Remove(actualUser);
}
// On supprime les utilisateurs qui sont déjà directement connectés avec l'utilisateur
foreach (UserProfile user in listLoggedUserRelation)
{
if (listFarFromOneRelations.Contains(user))
{
listFarFromOneRelations.Remove(user);
}
}
return listFarFromOneRelations;
}
示例9: Create
public static IRepository<Book> Create()
{
var listOfBooks = new List<Book>();
for (int i = 0; i < 20; i++)
{
listOfBooks.Add(new Book
{
Id = i,
Title = "Book " + i,
Description = "Description" + i,
Author = new Author
{
FirstName = "FirstName " + i,
LastName = "LastName " + i
}
});
}
var repository = new Mock<IRepository<Book>>();
repository.Setup(r => r.All()).Returns(listOfBooks.AsQueryable());
repository.Setup(r => r.Add(It.IsAny<Book>())).Callback<Book>(b =>
{
b.Id = 1;
});
repository.Setup(r => r.SaveChanges()).Verifiable();
return repository.Object;
}
示例10: btnCobrar_Click
private void btnCobrar_Click(object sender, EventArgs e)
{
List<CatalogoDeudores.DetalleDeuda> detalles = new List<CatalogoDeudores.DetalleDeuda>();
foreach (DataGridViewRow r in dgvLista.Rows)
{
if (r.Cells["Seleccion"].Value != null)
{
CatalogoDeudores.DetalleDeuda d = ((CatalogoDeudores.DetalleDeuda)r.DataBoundItem);
Business.ControladorExpensas.registrarPago(d);
detalles.Add(d);
}
}
if (detalles.Count > 0)
{
if (MessageBox.Show("Desea imprimir comprobante?", "Sistema", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
unidad u = (unidad)cmbUnidad.SelectedItem;
titular t = u.titular;
System.Diagnostics.Process.Start(Business.ControladorExpensas.emitirRecibo(Properties.Resources.qr, detalles, u, t));
}
}
cmbUnidad_SelectedIndexChanged(sender, e);
lblImporte.Text = lblRecargo.Text = lblTotalAPagar.Text = "0,00";
}
示例11: Deserialise
public void Deserialise(Reader In)
{
Bookings = new List<Booking>(In.ReadInt32());
for (int x = 0; x < Bookings.Capacity; x++)
Bookings.Add(DataModel.DeserialiseExternal<Booking>(In));
Departments = new List<Department>(In.ReadInt32());
for (int x = 0; x < Departments.Capacity; x++)
Departments.Add(DataModel.DeserialiseExternal<Department>(In));
Periods = new List<TimeSlot>(In.ReadInt32());
for (int x = 0; x < Periods.Capacity; x++)
Periods.Add(DataModel.DeserialiseExternal<TimeSlot>(In));
Rooms = new List<Room>(In.ReadInt32());
for (int x = 0; x < Rooms.Capacity; x++)
Rooms.Add(DataModel.DeserialiseExternal<Room>(In));
Users = new List<User>(In.ReadInt32());
for (int x = 0; x < Users.Capacity; x++)
Users.Add(DataModel.DeserialiseExternal<User>(In));
Subjects = new List<Subject>(In.ReadInt32());
for (int x = 0; x < Subjects.Capacity; x++)
Subjects.Add(DataModel.DeserialiseExternal<Subject>(In));
Classes = new List<Class>(In.ReadInt32());
for (int x = 0; x < Classes.Capacity; x++)
Classes.Add(DataModel.DeserialiseExternal<Class>(In));
}
示例12: C5CX
public static void C5CX(string name, string type, int length, string output)
{
List<DmDPC> srcNumbers = null;
if (length > 5)
{
srcNumbers = NumberCache.Instance.GetNumberList(type);
}
else
{
srcNumbers = NumberCache.Instance.GetNumberList("C5");
}
DmC5CXBiz biz = new DmC5CXBiz(name);
List<DmC5CX> entities = new List<DmC5CX>(srcNumbers.Count * 56);
foreach (var srcNumber in srcNumbers)
{
string number = srcNumber.Number.Replace(' ', ',');
var cxNumbers = new Combinations<int>(number.ToList(), length > 5 ? 5 : length);
foreach (var cxNumber in cxNumbers)
{
string cx = NumberCache.Instance.GetNumberId(length > 5 ? "C5" : type, cxNumber.Format("D2", ","));
DmC5CX entity = new DmC5CX();
entity.C5 = (length > 5) ? cx : srcNumber.Id;
entity.CX = (length > 5) ? srcNumber.Id : cx;
entity.C5Number = (length > 5) ? cx.ToString(2, " ") : srcNumber.Number;
entity.CXNumber = (length > 5) ? srcNumber.Number : cx.ToString(2, " ");
entity.NumberType = type;
entities.Add(entity);
}
}
//biz.DataAccessor.Truncate();
biz.DataAccessor.Insert(entities, SqlInsertMethod.SqlBulkCopy);
}
示例13: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
List<recommandation> listR = new List<recommandation>();
if (User.Identity.IsAuthenticated)
{
userName = User.Identity.Name;
//on recupere le parametre "del" pour voir si il y a un message à effacer
if (Request.Params["del"] != null && Convert.ToInt16(Request.Params["del"]) != 0)
{
//RecommandationService.deleteRecommandation(Convert.ToInt16(Request.Params["del"]),2);
not.Text = "Recommandation effacée";
}
listR = RecomendationService.getRecommandations((Guid)Membership.GetUser(userName, false).ProviderUserKey);
if (listR.Count > 0)
{
//o utilise le template pour les messages envoyés
rpt.DataSource = RecomendationService.RecommandationToRecommandationPlus(listR);
rpt.DataBind();
}
else
{
errorMessage("Aucune recommandation à afficher");
}
}
else
{
errorMessage("Erreur");
}
}
示例14: Span
private void Span(List<DwNumber> numbers)
{
string[] dxs = { "D1", "D2", "D3", "D4", "D5" };
var spanDict = new Dictionary<int, int>(11);
StreamWriter sw = new StreamWriter(@"d:\c1span.txt", false, Encoding.UTF8);
foreach (var number in numbers)
{
foreach (var dx in dxs)
{
int spans = number.Seq - 1;
int dxValue = ConvertHelper.GetInt32(number[dx].ToString());
if (spanDict.ContainsKey(dxValue))
{
spans = number.Seq - spanDict[dxValue] - 1;
spanDict[dxValue] = number.Seq;
}
else
{
spanDict.Add(dxValue, -1);
}
sw.WriteLine("{0},{1},{2}", number.P, dxValue, spans);
}
}
sw.Close();
}
示例15: getAllExpensas
public static List<ExpensasEdificio> getAllExpensas(List<edificio> edificios, DateTime periodo, DateTime vto1, DateTime vto2)
{
try
{
List<ExpensasEdificio> expensas = new List<ExpensasEdificio>();
admEntities db = Datos.getDB();
//var edificios = db.edificio.ToList();
int MaxNroFactura = 0;
List<string> nroFactura = db.Database.SqlQuery<String>(@"select nro_factura from expensas").ToList();
foreach (var s in nroFactura)
{
int temp = int.Parse(s);
if (temp > MaxNroFactura)
MaxNroFactura = temp;
}
int correlativo = MaxNroFactura + 1;
DateTime asd = DateTime.Parse("1 /" + periodo.Month + "/" + periodo.Year);
List<expensas> expensasExistentes = db.expensas.Where(x => x.fecha == asd).ToList();
foreach (var e in edificios)
{
expensas.Add(getExpensasEdificio(e, periodo, vto1, vto2, ref correlativo, db, expensasExistentes));
}
return expensas;
}
catch (Exception e)
{
Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
throw e;
}
}