本文整理汇总了C#中System.Collections.Generic.System.Collections.Generic.List.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.Insert方法的具体用法?C# System.Collections.Generic.List.Insert怎么用?C# System.Collections.Generic.List.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.System.Collections.Generic.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.Insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGroupHierarchyStackString
/** <summary>Walk up group hierarchy and show top down to this group</summary> */
public virtual string GetGroupHierarchyStackString()
{
System.Collections.Generic.List<string> groupNames = new System.Collections.Generic.List<string>();
StringTemplateGroup p = this;
while ( p != null )
{
groupNames.Insert( 0, p._name );
p = p._superGroup;
}
return "[" + string.Join( " ", groupNames.ToArray() ) + "]";
}
示例2: AddNewRecords
protected virtual void AddNewRecords()
{
ArrayList newRecordList = new ArrayList();
System.Collections.Generic.List<Hashtable> newUIDataList = new System.Collections.Generic.List<Hashtable>();
// Loop though all the record controls and if the record control
// does not have a unique record id set, then create a record
// and add to the list.
if (!this.ResetData)
{
System.Web.UI.WebControls.Repeater rep = (System.Web.UI.WebControls.Repeater)(BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "UOMTableControlRepeater"));
if (rep == null){return;}
foreach (System.Web.UI.WebControls.RepeaterItem repItem in rep.Items)
{
// Loop through all rows in the table, set its DataSource and call DataBind().
UOMTableControlRow recControl = (UOMTableControlRow)(repItem.FindControl("UOMTableControlRow"));
if (recControl.Visible && recControl.IsNewRecord) {
UOMRecord rec = new UOMRecord();
if (recControl.Status.Text != "") {
rec.Parse(recControl.Status.Text, UOMTable.Status);
}
if (recControl.UOMDescription.Text != "") {
rec.Parse(recControl.UOMDescription.Text, UOMTable.UOMDescription);
}
if (recControl.UOMName.Text != "") {
rec.Parse(recControl.UOMName.Text, UOMTable.UOMName);
}
newUIDataList.Add(recControl.PreservedUIData());
newRecordList.Add(rec);
}
}
}
// Add any new record to the list.
for (int count = 1; count <= this.AddNewRecord; count++) {
newRecordList.Insert(0, new UOMRecord());
newUIDataList.Insert(0, new Hashtable());
}
this.AddNewRecord = 0;
// Finally, add any new records to the DataSource.
if (newRecordList.Count > 0) {
ArrayList finalList = new ArrayList(this.DataSource);
finalList.InsertRange(0, newRecordList);
Type myrec = typeof(FPCEstimate.Business.UOMRecord);
this.DataSource = (UOMRecord[])(finalList.ToArray(myrec));
}
// Add the existing UI data to this hash table
if (newUIDataList.Count > 0)
this.UIData.InsertRange(0, newUIDataList);
}
示例3: PopulatePhysicalDrives
private void PopulatePhysicalDrives()
{
cbDriveInfos.Items.Clear();
System.Collections.Generic.IList<MyDrive> physicalDrives =
new System.Collections.Generic.List<MyDrive>();
ManagementClass devices = new ManagementClass(@"Win32_DiskDrive");
ManagementObjectCollection objects = devices.GetInstances();
foreach (ManagementObject obj in objects)
{
MyDrive myDrive = new MyDrive();
// fields refer to https://msdn.microsoft.com/en-us/library/aa394132%28v=vs.85%29.aspx
myDrive.DeviceID = (string)obj["DeviceID"];
myDrive.Caption = (string)obj["Caption"];
myDrive.Name = (string)obj["Name"];
foreach (ManagementObject b in obj.GetRelated("Win32_DiskPartition"))
{
foreach (ManagementBaseObject c in b.GetRelated("Win32_LogicalDisk"))
{
myDrive.DriveLetter = (string)c["Name"];
myDrive.Caption += "(" +myDrive.DriveLetter+ ")";
}
}
physicalDrives.Add(myDrive);
}
MyDrive myDrive1 = new MyDrive();
myDrive1.Caption = "Please select one...";
myDrive1.DeviceID = "-1";
physicalDrives.Insert(0, myDrive1);
cbDriveInfos.DataSource = physicalDrives;
cbDriveInfos.DisplayMember = "Caption";
}
示例4: AddNewRecords
protected virtual void AddNewRecords()
{
ArrayList newRecordList = new ArrayList();
System.Collections.Generic.List<Hashtable> newUIDataList = new System.Collections.Generic.List<Hashtable>();
// Loop though all the record controls and if the record control
// does not have a unique record id set, then create a record
// and add to the list.
if (!this.ResetData)
{
System.Web.UI.WebControls.Repeater rep = (System.Web.UI.WebControls.Repeater)(BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "EstLineAdjTableControlRepeater"));
if (rep == null){return;}
foreach (System.Web.UI.WebControls.RepeaterItem repItem in rep.Items)
{
// Loop through all rows in the table, set its DataSource and call DataBind().
EstLineAdjTableControlRow recControl = (EstLineAdjTableControlRow)(repItem.FindControl("EstLineAdjTableControlRow"));
if (recControl.Visible && recControl.IsNewRecord) {
EstLineAdjRecord rec = new EstLineAdjRecord();
if (MiscUtils.IsValueSelected(recControl.CatID)) {
rec.Parse(recControl.CatID.SelectedItem.Value, EstLineAdjTable.CatID);
}
if (recControl.CreatedBy1.Text != "") {
rec.Parse(recControl.CreatedBy1.Text, EstLineAdjTable.CreatedBy);
}
if (recControl.CreatedByID1.Text != "") {
rec.Parse(recControl.CreatedByID1.Text, EstLineAdjTable.CreatedByID);
}
if (recControl.CreatedDate1.Text != "") {
rec.Parse(recControl.CreatedDate1.Text, EstLineAdjTable.CreatedDate);
}
if (MiscUtils.IsValueSelected(recControl.EstimateAdjID)) {
rec.Parse(recControl.EstimateAdjID.SelectedItem.Value, EstLineAdjTable.EstimateAdjID);
}
if (MiscUtils.IsValueSelected(recControl.EstimateID)) {
rec.Parse(recControl.EstimateID.SelectedItem.Value, EstLineAdjTable.EstimateID);
}
if (MiscUtils.IsValueSelected(recControl.EstimateLineID)) {
rec.Parse(recControl.EstimateLineID.SelectedItem.Value, EstLineAdjTable.EstimateLineID);
}
if (recControl.EstLineAdjAmount.Text != "") {
rec.Parse(recControl.EstLineAdjAmount.Text, EstLineAdjTable.EstLineAdjAmount);
}
if (recControl.EstLineAdjID.Text != "") {
rec.Parse(recControl.EstLineAdjID.Text, EstLineAdjTable.EstLineAdjID);
}
if (recControl.EstLineAdjName.Text != "") {
rec.Parse(recControl.EstLineAdjName.Text, EstLineAdjTable.EstLineAdjName);
}
if (recControl.LastEditBy1.Text != "") {
rec.Parse(recControl.LastEditBy1.Text, EstLineAdjTable.LastEditBy);
}
if (recControl.LastEditByID1.Text != "") {
rec.Parse(recControl.LastEditByID1.Text, EstLineAdjTable.LastEditByID);
}
if (recControl.LastEditDate1.Text != "") {
rec.Parse(recControl.LastEditDate1.Text, EstLineAdjTable.LastEditDate);
}
if (MiscUtils.IsValueSelected(recControl.SiteID)) {
rec.Parse(recControl.SiteID.SelectedItem.Value, EstLineAdjTable.SiteID);
}
rec.Status = recControl.Status1.Checked;
newUIDataList.Add(recControl.PreservedUIData());
newRecordList.Add(rec);
}
}
}
// Add any new record to the list.
for (int count = 1; count <= this.AddNewRecord; count++) {
newRecordList.Insert(0, new EstLineAdjRecord());
newUIDataList.Insert(0, new Hashtable());
}
this.AddNewRecord = 0;
// Finally, add any new records to the DataSource.
if (newRecordList.Count > 0) {
ArrayList finalList = new ArrayList(this.DataSource);
finalList.InsertRange(0, newRecordList);
Type myrec = typeof(FPCEstimate.Business.EstLineAdjRecord);
this.DataSource = (EstLineAdjRecord[])(finalList.ToArray(myrec));
}
//.........这里部分代码省略.........
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
int nextColor = 0 ;
int nrOfEvents = 0 ;
EventColor bc ;
System.Collections.Generic.List<Ektron.Cms.Common.Calendar.WebEventData> eventList =
new System.Collections.Generic.List<Ektron.Cms.Common.Calendar.WebEventData>();
System.Collections.Generic.List<MyWebEventData> MyEventList =
new System.Collections.Generic.List<MyWebEventData>();
Ektron.Cms.Framework.Calendar.WebEvent weAPI =
new Ektron.Cms.Framework.Calendar.WebEvent();
System.DateTime st = DateTime.Now.AddDays( 0 - _daysBehind);
System.DateTime et = DateTime.Now.AddDays(_daysAhead);
System.DateTime firstEvent = et ;
System.DateTime lastEvent = st ;
foreach (CalendarDataSource cds in _calendarsource)
{
if( cds.backColor == EventColor.AutoSelect )
{
bc = (EventColor) ((nextColor % 7 /* 11 */) +1) ;
nextColor ++ ;
}
else
bc = cds.backColor ;
eventList = weAPI.GetEventOccurrenceList( cds.defaultId, st, et) ;
foreach( Ektron.Cms.Common.Calendar.WebEventData wed in eventList )
{
MyEventList.Insert( 0, new MyWebEventData( wed, bc ) );
}
}
MyEventList.Sort(delegate(MyWebEventData we1, MyWebEventData we2){ return we1.EventStartUtc.CompareTo(we2.EventStartUtc);});
StringBuilder sb = new StringBuilder();
StringBuilder ss = new StringBuilder();
string eventTime = "";
string tooltip = "" ;
string header = "" ;
string eventTitle = "" ;
if( !_suppressWrapperTags )
ss.Append( "\n<SCRIPT type=\"text/javascript\">\n" ) ;
foreach (MyWebEventData webEventData in MyEventList)
{
if( (DateTime.Compare(webEventData.EventStartUtc, System.DateTime.Now)) > 0 )
{
if( lastEvent < webEventData.EventStart )
lastEvent = webEventData.EventStart ;
if( firstEvent > webEventData.EventStart )
firstEvent = webEventData.EventStart ;
eventTime = ((DateTime.Compare(webEventData.EventStart.AddDays(1), webEventData.EventEnd)) == 0) ? "All Day Event" : webEventData.EventStart.ToShortTimeString() + " to " + webEventData.EventEnd.ToShortTimeString();
string strDescription = (webEventData.Description.Length <= 30) ? webEventData.Description : webEventData.Description.Substring(0, 30) + "... ";
eventTitle = String.Format( _eventFormat,
webEventData.Title,
webEventData.Description,
webEventData.Location,
webEventData.EventStart,
webEventData.EventEnd,
eventTime,
webEventData.Quicklink.ToString(),
backColorCategories[ ((int) webEventData.backColor) -1 ]
) ;
if( _suppressWrapperTags )
{
sb.Append( eventTitle ) ;
}
else
{
sb.Append(
" <tr class=\"rsAllDayRow\">\n" +
" <td class=\"rsLastCell\">\n" +
" <div class=\"rsWrap\" style=\"z-index:20;\">\n" +
" <div class=\"rsApt rsCategory" +backColorCategories[ ((int) webEventData.backColor) -1 ] + "\" style=\"width:100%;position:relative; z-index:25;\">\n" +
" <div class=\"rsAptOut\">\n" +
" <div class=\"rsAptMid\">\n" +
" <div class=\"rsAptIn\">\n" +
" <div ID=\"" +this.ClientID +"_Event_" +nrOfEvents.ToString() +"_AptContent\" class=\"rsAptContent\" >\n" +
" <span id=\"" + this.ClientID +"_Event_" +nrOfEvents.ToString() +"_title\" class=\'UpcomingEventsDesc\'>" +eventTitle +"</span>\n" +
" <div id=\"" + this.ClientID +"_Event_" +nrOfEvents.ToString() +"_description\" style=\"display:none;\">\n" +
" <input id=\"" + this.ClientID +"_Event_" +nrOfEvents.ToString() +"_description_ClientState\" name=\"" + this.ClientID +"_Event_" +nrOfEvents.ToString() +"_description_ClientState\" type=\"hidden\" />\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" </td>\n" +
//.........这里部分代码省略.........