本文整理汇总了C#中Common.List类的典型用法代码示例。如果您正苦于以下问题:C# List类的具体用法?C# List怎么用?C# List使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
List类属于Common命名空间,在下文中一共展示了List类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Search
public ActionResult Search(string query)
{
ViewData["Message"] = "query : " + query;
var searcher = new IndexSearcher(
new Lucene.Net.Store.SimpleFSDirectory(new DirectoryInfo(Configuration.IndexDirectory)),
readOnly: true);
var fieldsToSearchIn = new[] {Configuration.Fields.Name, Configuration.Fields.Description};
var queryanalizer = new MultiFieldQueryParser(Version.LUCENE_CURRENT,
fieldsToSearchIn,
new BrazilianAnalyzer());
var numberOfResults = 10;
var top10Results = searcher.Search(queryanalizer.Parse(query), numberOfResults);
var docs = new List<DocumentViewModel>();
foreach (var scoreDoc in top10Results.scoreDocs)
{
var document = searcher.Doc(scoreDoc.doc);
var name = document.GetField(Configuration.Fields.Name).StringValue();
var description = document.GetField(Configuration.Fields.Description).StringValue();
var link = document.GetField(Configuration.Fields.Link).StringValue();
docs.Add(new DocumentViewModel(name, description, link));
}
return View(new SearchViewModel(docs));
}
示例2: GetBindingContext
private object GetBindingContext(Type viewType)
{
var viewModelType = _viewsByType[viewType];
ConstructorInfo constructor = null;
var parameters = new object[] { };
constructor = viewModelType.Type.GetTypeInfo()
.DeclaredConstructors
.FirstOrDefault(c => !c.GetParameters().Any());
if (constructor == null)
{
constructor = viewModelType.Type.GetTypeInfo()
.DeclaredConstructors.First();
var parameterList = new List<object>();
foreach (var param in constructor.GetParameters())
parameterList.Add(_injection.Get(param.ParameterType));
parameters = parameterList.ToArray();
}
if (constructor == null)
throw new InvalidOperationException(
$"No suitable constructor found for ViewModel {viewModelType.ToString()}");
return constructor.Invoke(parameters);
}
示例3: GetState
public static SelectList GetState()
{
List<object> sl = new List<object>();
sl.Add(new { Id = "未审核", Text = "未审核" });
sl.Add(new { Id = "已审核", Text = "已审核" });
return new SelectList(sl, "Id", "Text");
}
示例4: ClearElements
public void ClearElements()
{
ElementRectangleSubPlans = new List<ElementRectangleSubPlan>();
ElementPolygonSubPlans = new List<ElementPolygonSubPlan>();
ElementRectangles = new List<ElementRectangle>();
ElementEllipses = new List<ElementEllipse>();
ElementTextBlocks = new List<ElementTextBlock>();
ElementTextBoxes = new List<ElementTextBox>();
ElementPolygons = new List<ElementPolygon>();
ElementPolylines = new List<ElementPolyline>();
ElementGKDevices = new List<ElementGKDevice>();
ElementRectangleGKZones = new List<ElementRectangleGKZone>();
ElementPolygonGKZones = new List<ElementPolygonGKZone>();
ElementRectangleGKGuardZones = new List<ElementRectangleGKGuardZone>();
ElementPolygonGKGuardZones = new List<ElementPolygonGKGuardZone>();
ElementRectangleGKSKDZones = new List<ElementRectangleGKSKDZone>();
ElementPolygonGKSKDZones = new List<ElementPolygonGKSKDZone>();
ElementRectangleGKDelays = new List<ElementRectangleGKDelay>();
ElementPolygonGKDelays = new List<ElementPolygonGKDelay>();
ElementRectangleGKPumpStations = new List<ElementRectangleGKPumpStation>();
ElementPolygonGKPumpStations = new List<ElementPolygonGKPumpStation>();
ElementRectangleGKDirections = new List<ElementRectangleGKDirection>();
ElementPolygonGKDirections = new List<ElementPolygonGKDirection>();
ElementRectangleGKMPTs = new List<ElementRectangleGKMPT>();
ElementPolygonGKMPTs = new List<ElementPolygonGKMPT>();
ElementGKDoors = new List<ElementGKDoor>();
ElementExtensions = new List<ElementBase>();
}
示例5: RetrieveList
/// <summary>
/// Retrieves master detail list.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <returns>
/// List of master details
/// </returns>
public IList<MasterDetail> RetrieveList(int userId)
{
var roleList = this.roleGroupRepository.RetrieveRoleGroupList(userId);
var masterList = new List<MasterDetail>();
roleList.ForEach(role => masterList.Add(MapToMasterDetails(role)));
return masterList;
}
示例6: Index
public ActionResult Index()
{
try
{
if (Session["accountID"] != null)
{
List<Order> orderList = new OrderClient().GetBoughtOrdersByAccountID((int)Session["accountID"]).ToList();
List<ProductOrder> allPO = new List<ProductOrder>();
foreach (Order o in orderList)
{
List<ProductOrder> productOrderlist = new OrderClient().GetWarrantyUnexpiredOrdersByOrderID(o.ID).ToList();
foreach (ProductOrder po in productOrderlist)
{
allPO.Add(po);
}
}
return View("Index", allPO);
}
else
{
return RedirectToAction("Login", "Login");
}
}
catch (Exception e)
{
ViewBag.Error = "An error has occured.";
return View("Index", new List<ProductOrder>());
}
}
示例7: addTLose
/**
* 添加变损信息
* @param ref List<TransformerLoseInfo> t_lose:变损信息
* @return int 值为Constant.OK:执行成功,值为Constant.ERROR为执行失败
* @author Rick
**/
public int addTLose(ref List<TransformerLose> t_lose)
{
//string strAdd = "insert into AreaInfo values (" + areaInfo.AreaNo + ",'" + areaInfo.AreaName + "'," + areaInfo.AreaFlag + ", getdate())";
int count = t_lose.Count;
int i = 0;
List<string> listSql = new List<string>();
while (count > 0)
{
string strAdd = "insert into TransformerLoseInfo values (" + t_lose[i].TransformerLoseNo + ", '" + t_lose[i].TransformerType + "'," + t_lose[i].StandarVolume + ", " + t_lose[i].MonthUsed + "," + t_lose[i].TranformerLose + "," + t_lose[i].LessOrMoreFlag + ")";
listSql.Add(strAdd);
count = count - 1;
i = i + 1;
}
try
{
SQLUtl.ExecuteSqlTran(listSql);
return Constant.OK;
}
catch (Exception)
{
return Constant.ERROR;
}
}
示例8: GetHistoryCards
public List<HistoryCardViewModel> GetHistoryCards()
{
var historyCards = _db.GetHistoryCards();
var historyCardsViewModel = new List<HistoryCardViewModel>();
foreach (var history in historyCards)
{
var model = new HistoryCardViewModel();
foreach (var subscriber in history.Subscribers.Take(3))
{
model.Users.Add(new Subscriber()
{
FirstName = subscriber.FirstName,
LastName = subscriber.LastName,
SmallPhoto = subscriber.SmallPhoto
});
}
model.Goal = history.Title;
model.Created = history.created.Value;
model.TotalPeopleCount = history.Subscribers.Count;
model.DisplayPeopleCount = 3;
historyCardsViewModel.Add(model);
}
return historyCardsViewModel;
}
示例9: GetCorrelogram
public static List<double> GetCorrelogram(List<double> excerpt, int k)
{
// sum of all elements
double sum = excerpt.Sum();
// init lsum (only left elements) and rsum (only right elements)
// theirs size will be decreased
double lsum = sum, rsum = sum;
List<double> crl = new List<double> { 1 };
for (int i = 1; i <= k; i++)
{
// subtract last left element from rsum
rsum -= excerpt[i - 1];
// subtract last right element from lsum
lsum -= excerpt[excerpt.Count - i];
// reduction of sum by dividing by N-K
double rusum = rsum / (excerpt.Count - i), lusum = lsum / (excerpt.Count - i);
// abv is expression in numerator
double abv = 0, lund = 0, rund = 0;
for (int j = 0; j < excerpt.Count - i; j++)
{
abv += (excerpt[j] - lusum) * (excerpt[j + i] - rusum);
lund += (excerpt[j] - lusum) * (excerpt[j] - lusum);
rund += (excerpt[j + i] - rusum) * (excerpt[j + i] - rusum);
}
double und = Math.Sqrt(rund * lund);
double val = abv == und ? 1.0 : abv / und;
crl.Add(val);
}
return crl;
}
示例10: ReceiveAndCheckAsync
private static async Task ReceiveAndCheckAsync(UdpClient client, string expectedMessage)
{
var incomingBytes = new List<byte>();
var connectionReset=false;
try
{
do
{
var udpReceiveResult = await client.ReceiveAsync();
incomingBytes.AddRange(udpReceiveResult.Buffer);
} while (TcpMessenger.IsReadingShouldContinue(incomingBytes));
}
catch (SocketException ex)
{
if (ex.SocketErrorCode == SocketError.ConnectionReset)
{
connectionReset = true;
}
}
var actual = Encoding.UTF8.GetString(incomingBytes.ToArray());
if (connectionReset)
{
TcpMessenger.ErrorConnectionReset(actual);
}
else if (actual != expectedMessage)
{
TcpMessenger.ErrorWrongMessage(actual);
}
}
示例11: Index
public ActionResult Index(Guid? customerId, string keywords, bool? finish, int pageIndex = 1, int pageSize = 10)
{
var model = _iProjectInfoService.GetAll(a => a.Public);
if (customerId.HasValue)
model = model.Where(a => a.CustomerId == customerId);
if (!string.IsNullOrEmpty(keywords))
{
model =
model.Where(
a =>
a.ProjectName.Contains(keywords) || a.ProjectObjective.Contains(keywords) ||
a.Tag.Contains(keywords) || a.ProjectUsers.Any(b => b.SysUser.UserName == keywords));
}
if (finish.HasValue)
{
model = model.Where(a => a.Finish == finish);
}
//子项目
var subModel = model.Where(a => a.LastProjectInfoId != null);
//主项目
var mainModel = model.Where(a => a.LastProjectInfoId == null).ToPagedList(pageIndex, pageSize);
var mainList = new List<ProjectInfo>() { };
foreach (var item in mainModel)
{
mainList.Add(item);
mainList.AddRange((subModel as IQueryable<ProjectInfo>).Where(a => a.LastProjectInfoId == item.Id));
}
var result = mainList.Select(
a => new
{
a.Id,
a.UserId,
Leader = a.ProjectUsers != null ? a.ProjectUsers.Where(b => b.Leader).Select(b => b.SysUser.DisplayName) : null,
ProjectInfoState = a.ProjectInfoState != null ? a.ProjectInfoState.ProjectInfoStateName : null,
Follow = a.Public && (a.ProjectUsers!=null ? a.ProjectUsers.Any(b => b.SysUserId == _iUserInfo.UserId && b.Follow): false),
a.LastProjectInfoId,
a.Raty,
a.Public,
PlanCount = a.Plans.Count(p => !p.Deleted),
TaskCount = a.ProjectTasks.Count(t => !t.Deleted),
ReplyCount = a.ProjectInfoReplys.Count(r => !r.Deleted),
MemberCount = a.ProjectUsers != null ? a.ProjectUsers.Count(b => !b.Follow) : 0,
a.CustomerId,
a.Tag,
a.StarTime,
a.EndTime,
a.Finish,
a.ProjectName,
a.ProjectObjective,
a.CreatedDate
});
return Content(JsonConvert.SerializeObject(result), "text/json");
}
示例12: RetrieveList
/// <summary>
/// Retrieves master detail list.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <returns>
/// List of master details
/// </returns>
public IList<MasterDetail> RetrieveList(int userId)
{
////var artifactList = this.artifactRepository.RetrieveArtifactList(projectId, releaseCalendarId, artifactType, userId);
var masterList = new List<MasterDetail>();
////artifactList.ForEach(artifact => masterList.Add(MapArtifactFillListItemToMasterDetails(artifact)));
return masterList;
}
示例13: GetLongestChain
static int GetLongestChain(int d1, int d2, int d3, int d4)
{
bool[] numbers = new bool[10000];
for (int op1 = 0; op1 < 4; op1++)
{
for (int op2 = 0; op2 < 4; op2++)
{
for (int op3 = 0; op3 < 4; op3++)
{
var list = new List<object>() { Operands[op1], Operands[op2], Operands[op3], d1, d2, d3, d4 };
foreach (var permutation in Permutator.Permutate(list.Count))
{
var list2 = new List<object>(list.Count) {null, null, null, null, null, null, null};
int count = 0;
foreach (int i in permutation)
list2[i] = list[count++];
var result = CalculatePolishNotatation(list2);
if (double.IsNaN(result) || double.IsInfinity(result)|| result < 0 || Math.Abs(result - Math.Round(result))> 1e-8)
continue;
numbers[(int)result] = true;
}
}
}
}
for (int i = 1; i < numbers.Length; i++)
{
if (numbers[i] == false)
return i - 1;
}
return 0;
}
示例14: CalculatePolishNotatation
static double CalculatePolishNotatation(List<object> tags)
{
Stack<double> stack = new Stack<double>();
int index = tags.Count - 1;
while (index > -1)
{
var o = tags[index];
if (o is int)
{
stack.Push((int)o);
}
if (o is Func<double, double, double>)
{
var operation = (Func<double, double, double>)o;
if (stack.Count < 2)
return double.NaN;
var operand1 = stack.Pop();
var operand2 = stack.Pop();
stack.Push(operation(operand1, operand2));
}
index--;
}
if (stack.Count == 1)
return stack.Pop();
return double.NaN;
}
示例15: CreateDeviceDependentResources
protected override void CreateDeviceDependentResources()
{
base.CreateDeviceDependentResources();
RemoveAndDispose(ref vertexBuffer);
// Retrieve our SharpDX.Direct3D11.Device1 instance
var device = this.DeviceManager.Direct3DDevice;
List<Vertex> vertices = new List<Vertex>();
vertices.AddRange(new[] {
new Vertex(0, 0, -4, Vector3.UnitY, Color.Blue),
new Vertex(0, 0, 4,Vector3.UnitY, Color.Blue),
new Vertex(-4, 0, 0, Vector3.UnitY, Color.Red),
new Vertex(4, 0, 0,Vector3.UnitY, Color.Red),
});
for (var i = -4f; i < -0.09f; i += 0.2f)
{
vertices.Add(new Vertex(i, 0, -4, Color.Gray));
vertices.Add(new Vertex(i, 0, 4, Color.Gray));
vertices.Add(new Vertex(-i, 0, -4, Color.Gray));
vertices.Add(new Vertex(-i, 0, 4, Color.Gray));
vertices.Add(new Vertex(-4, 0, i, Color.Gray));
vertices.Add(new Vertex(4, 0, i, Color.Gray));
vertices.Add(new Vertex(-4, 0, -i, Color.Gray));
vertices.Add(new Vertex(4, 0, -i, Color.Gray));
}
vertexCount = vertices.Count;
vertexBuffer = ToDispose(Buffer.Create(device, BindFlags.VertexBuffer, vertices.ToArray()));
}