本文整理汇总了C#中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.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.Insert方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListRNDTest
public void ListRNDTest()
{
var controlList = new System.Collections.Generic.List<int>();
var testList = new MyList<int>();
var r = new System.Random();
for (int i = 0; i < 1000; i++)
{
var next = r.Next();
controlList.Add(next);
testList.Add(next);
Assert.AreEqual(controlList.Count, testList.Count);
}
for (int i = 0; i < 1000; i++)
{
Assert.IsTrue(testList.IndexOf(controlList[i]) == i);
}
for (int i = 0; i < controlList.Count; i++)
{
if (r.Next() < int.MaxValue / 2)
{
testList.RemoveAt(i);
controlList.RemoveAt(i);
}
else
{
var newItem = r.Next();
testList.Insert(i, newItem);
controlList.Insert(i, newItem);
}
}
Assert.AreEqual(controlList.Count, testList.Count);
foreach (var itm in controlList){
Assert.IsTrue(testList.Contains(itm));
}
for (int i = 0; i < controlList.Count / 2; i++ )
{
var e = controlList[i];
controlList.Remove(e);
testList.Remove(e);
}
int[] controllarray = new int[controlList.Count+1];
int[] testArray = new int[testList.Count+1];
controllarray[0] = r.Next();
testArray[0] = controllarray[0];
controlList.CopyTo(controllarray, 1);
testList.CopyTo(testArray, 1);
var q = from a in testArray
join b in controllarray on a equals b
select a;
Assert.IsTrue(testArray.Length == controllarray.Length && q.Count() == controllarray.Length);
controlList.Clear();
testList.Clear();
Assert.AreEqual(controlList.Count,testList.Count);
}
示例2: UpdateAssemblies
public bool UpdateAssemblies()
{
uint[] assemblies = null;
List<ManagedCallbacks.ManagedCallback> callbacks = new System.Collections.Generic.List<ManagedCallbacks.ManagedCallback>();
if(this.Process.Engine.Capabilities.AppDomains)
{
WireProtocol.Commands.Debugging_Resolve_AppDomain.Reply reply = this.Process.Engine.ResolveAppDomain( m_id );
if(reply != null)
{
m_name = reply.Name;
assemblies = reply.m_data;
}
if(assemblies == null)
{
//assembly is already unloaded
assemblies = new uint[0];
}
}
else
{
WireProtocol.Commands.Debugging_Resolve_Assembly[] reply = this.Process.Engine.ResolveAllAssemblies();
assemblies = new uint[reply.Length];
for(int iAssembly = 0; iAssembly < assemblies.Length; iAssembly++)
{
assemblies[iAssembly] = reply[iAssembly].m_idx;
}
}
//Convert Assembly Index to Idx.
for(uint iAssembly = 0; iAssembly < assemblies.Length; iAssembly++)
{
assemblies[iAssembly] = TinyCLR_TypeSystem.IdxAssemblyFromIndex( assemblies[iAssembly] );
}
//Unload dead assemblies
for(int iAssembly = m_assemblies.Count - 1; iAssembly >= 0; iAssembly--)
{
CorDebugAssembly assembly = (CorDebugAssembly)m_assemblies[iAssembly];
if(Array.IndexOf( assemblies, assembly.Idx ) < 0)
{
callbacks.Add(new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.UnloadModule));
callbacks.Add(new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.UnloadAssembly));
m_assemblies.RemoveAt( iAssembly );
}
}
//Load new assemblies
for(int i = 0; i < assemblies.Length; i++)
{
uint idx = assemblies[i];
CorDebugAssembly assembly = AssemblyFromIdx( idx );
if(assembly == null)
{
//Get the primary assembly from CorDebugProcess
assembly = this.Process.AssemblyFromIdx( idx );
Debug.Assert( assembly != null );
//create a new CorDebugAssemblyInstance
assembly = assembly.CreateAssemblyInstance( this );
Debug.Assert(assembly != null);
m_assemblies.Add( assembly );
//cpde expects mscorlib to be the first assembly it hears about
int index = (assembly.Name == "mscorlib") ? 0 : callbacks.Count;
callbacks.Insert(index, new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.LoadAssembly));
callbacks.Insert(index+1, new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.LoadModule));
}
}
this.Process.EnqueueEvents(callbacks);
return callbacks.Count > 0;
}
示例3: LoadMap
/// <summary>
/// reads info from the current open map file and
/// stores in it this map object
/// </summary>
/// <remarks></remarks>
private void LoadMap()
{
switch (HaloVersion)
{
case HaloVersionEnum.Halo2:
{
MapHeader = new MapHeaderInfo(ref BR, HaloVersion);
IndexHeader = new IndexHeaderInfo(ref BR, this);
MetaInfo = new ObjectIndexInfo(ref BR, this);
#region Added for loading of obfuscated maps
System.Collections.Generic.List<int> offsets = new System.Collections.Generic.List<int>();
System.Collections.Generic.List<int> indexes = new System.Collections.Generic.List<int>();
// Obfuscated maps set filename offset to 0 and change all listings to spaces.
// This point is back to the correct place for starters.
if (MapHeader.offsetTofileNames == 0)
{
MapHeader.offsetTofileNames = MapHeader.offsetTofileIndex - MapHeader.fileNamesSize;
MapHeader.offsetTofileNames = MapHeader.offsetTofileNames - (MapHeader.offsetTofileNames % 64);
// All sizes get set to maximum length
if (MetaInfo.Size[0] == Int32.MaxValue)
{
// Sort our meta by offset to start
for (int x = 0; x < MapHeader.fileCount; x++)
if (x == 0 || MetaInfo.Offset[x] >= offsets[x - 1])
{
offsets.Add(MetaInfo.Offset[x]);
indexes.Add(x);
}
else
{
for (int y = 0; y < x; y++)
if (MetaInfo.Offset[x] < offsets[y])
{
offsets.Insert(y, MetaInfo.Offset[x]);
indexes.Insert(y, x);
break;
}
}
for (int x = 0; x < MapHeader.fileCount; x++)
{
if (offsets[x] < 0)
continue;
if (indexes[x] < MapHeader.fileCount - 1)
MetaInfo.Size[indexes[x]] = offsets[x + 1] - offsets[x];
else
MetaInfo.Size[indexes[x]] = this.MapHeader.fileSize - offsets[x];
}
}
}
#endregion
FileNames = new FileNamesInfo(ref BR, this);
Strings = new StringsInfo(ref BR, this);
CloseMap();
Unicode = new UnicodeTableReader(this.filePath, this.MetaInfo.Offset[0]);
#region Attempt to detect and recover meta tag names from a known good base map
// If the first two entries both start with our default # sign and offsets has a count, map is probably obfuscated
if (FileNames.Name[0].StartsWith("#") && FileNames.Name[1].StartsWith("#") && offsets.Count > 0)
{
if (MessageBox.Show("This map may have been obfuscated. Would you like to try to recover names from a map(s)?", "Decode from map(s)?", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Map Files|*.map";
ofd.Multiselect = true;
ofd.Title = "Select the Clean Base Map for this Map (" + MapHeader.mapName.TrimEnd((char)0) + ")";
do
{
if (ofd.ShowDialog() == DialogResult.OK)
{
#region Information Form (f) Creation
Form f = new Form();
f.ControlBox = false;
f.MinimizeBox = false;
f.MaximizeBox = false;
f.FormBorderStyle = FormBorderStyle.FixedSingle;
f.Size = new System.Drawing.Size(700, 60);
f.StartPosition = FormStartPosition.CenterScreen;
Label lbl = new Label();
lbl.Dock = DockStyle.Fill;
lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
#endregion
f.Show();
f.Controls.Add(lbl);
foreach (string filename in ofd.FileNames)
{
f.Text = filename;
lbl.Text = "Unknowns remaining: " + indexes.Count.ToString();
//.........这里部分代码省略.........
示例4: scan_strings
}/* decode_strings */
/* scan_strings - build string address table */
internal static void scan_strings(ulong pc)
{
ulong old_pc;
int count = 1;
zword_t data;
strings_base = new System.Collections.Generic.List<tx_h.cref_item_t>();
pc = ROUND_DATA(pc);
old_pc = pc;
while (pc < (ulong)txio.file_size)
{
tx_h.cref_item_t cref_item = new tx_h.cref_item_t();
cref_item.address = pc;
cref_item.number = count++;
strings_base.Insert(0, cref_item);
old_pc = pc;
do
data = (zword_t)txio.read_data_word(ref pc);
while (pc < (ulong)txio.file_size && ((uint)data & 0x8000) == 0);
pc = ROUND_CODE(pc);
if ((uint)(data & 0x8000) > 0)
old_pc = pc;
}
txio.file_size = (int)old_pc;
}/* scan_strings */
示例5: InsertHandler
public static void InsertHandler(AddHandlerDataObject data)
{
ISnippetGenerator gene;
switch (EditorSettings.ScriptExtension)
{
//case ScriptExtensions.JAVASCRIPT:
default:
gene = new JavascriptSnippetGenerator(data);
break;
case ScriptExtensions.CSHARP:
gene = new CSharpSnippetGenerator(data);
break;
case ScriptExtensions.BOO:
gene = new BooSnippetGenerator(data);
break;
}
string origSnippet = data.Snippet;
if (string.IsNullOrEmpty(origSnippet))
{
Debug.LogError("Problem with file content");
return;
}
string handlerString = gene.CreateEventHandler();
string[] parts = origSnippet.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(parts);
int index = Math.Max(0, parts.Length - 2);
list.Insert(index, handlerString);
string snippet = String.Join(Environment.NewLine, list.ToArray());
if (data.OpenScript)
{
index = snippet.IndexOf(PersistedDataProcessor.CursorMarker);
if (index == -1)
{
Debug.LogError("Cannot find cursor marker");
return;
}
parts = snippet.Substring(0, index).Split(new[] { Environment.NewLine }, StringSplitOptions.None);
// set line number
data.SnippetLineNumber = parts.Length; // +1;
// remove marker
data.Snippet = snippet.Replace(PersistedDataProcessor.CursorMarker, string.Empty);
// set line number
data.SnippetLineNumber = index;
}
}
示例6: button1_Click
private void button1_Click(object sender, EventArgs e)
{
string errorLocation = "Processing Compare";
try
{
Cursor = Cursors.WaitCursor;
_selectedSchemas = schemaTreeView1.GetCheckedSchemas();
//if (optSQL2000.Checked) ProcesarSQL2000();
if (optSQL2005.Checked) ProcesarSQL2005();
//if (optMySQL.Checked) ProcesarMySQL();
//if (optSybase.Checked) ProcesarSybase();
schemaTreeView1.SetCheckedSchemas(_selectedSchemas);
errorLocation = "Saving Connections";
Project.SaveLastConfiguration(mySqlConnectFront1.ConnectionString, mySqlConnectFront2.ConnectionString);
}
catch (Exception ex)
{
var exceptionList = new System.Collections.Generic.List<Exception>();
exceptionList.Add(ex);
var innerException = ex.InnerException;
while (innerException != null)
{
exceptionList.Insert(0, innerException);
innerException = innerException.InnerException;
}
var exceptionMsg = new System.Text.StringBuilder();
var prevMessage = exceptionList[0].Message;
exceptionMsg.Append(this.Text);
for (int i = 1; i < exceptionList.Count; ++i)
{
if (exceptionList[i].Message != prevMessage)
{
exceptionMsg.AppendFormat("\r\n{0}", exceptionList[i].Message);
prevMessage = exceptionList[i].Message;
}
}
var ignoreSystem = new System.Text.RegularExpressions.Regex(@" at System\.[^\r\n]+\r\n|C:\\dev\\open-dbdiff\\");
exceptionMsg.AppendFormat("\r\n{0}: {1}\r\n{2}", exceptionList[0].GetType().Name, exceptionList[0].Message, ignoreSystem.Replace(exceptionList[0].StackTrace, String.Empty));
var ignoreChunks = new System.Text.RegularExpressions.Regex(@": \[[^\)]*\)|\.\.\.\)|\'[^\']*\'|\([^\)]*\)|\" + '"' + @"[^\" + '"' + @"]*\" + '"' + @"|Source|Destination");
var searchableError = ignoreChunks.Replace(exceptionMsg.ToString(), String.Empty);
var searchableErrorBytes = System.Text.Encoding.UTF8.GetBytes(searchableError);
searchableErrorBytes = new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(searchableErrorBytes);
var searchHash = BitConverter.ToString(searchableErrorBytes).Replace("-", String.Empty);
exceptionMsg.AppendFormat("\r\n\r\n{0}", searchHash);
if (DialogResult.OK == MessageBox.Show(Owner, @"An unexpected error has occured during processing.
Clicking 'OK' will result in the following:
1. The exception info below will be copied to the clipboard.
2. Your default browser will search CodePlex for more details.
• *Please* click 'Create New Work Item' and paste the error details
into the Description field if there are no work items for this issue!
(At least email the details to [email protected])
• Vote for existing work items; paste details into 'Add Comment'.
• If possible, please attach a SQL script creating two dbs with
the minimum necessary to reproduce the problem.
" + exceptionMsg.ToString(), "Error " + errorLocation, MessageBoxButtons.OKCancel, MessageBoxIcon.Error))
{
try
{
Clipboard.SetText(exceptionMsg.ToString());
System.Diagnostics.Process.Start("http://opendbiff.codeplex.com/workitem/list/basic?keywords=" + Uri.EscapeDataString(searchHash));
}
finally
{
}
}
}
finally
{
Cursor = Cursors.Default;
}
}