本文整理汇总了C#中System.Collections.ArrayList.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.ArrayList.AddRange方法的具体用法?C# System.Collections.ArrayList.AddRange怎么用?C# System.Collections.ArrayList.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了System.Collections.ArrayList.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyPatch
public static void ApplyPatch(FpuSegment seg)
{
Process p=new Process();
p.StartInfo.FileName="nasm.exe";
p.StartInfo.Arguments="out.txt";
p.StartInfo.UseShellExecute=false;
p.StartInfo.CreateNoWindow=true;
p.Start();
p.WaitForExit();
p.Close();
FileInfo fi=new FileInfo("out");
if(fi.Length==0) throw new OptimizationException("Patcher: Code generator produced uncompilable code");
ArrayList code=new ArrayList();
for(int i=0;i<seg.Pre.Length;i++) {
code.AddRange(HexToString(seg.Pre[i].code));
}
code.AddRange(Program.ReadFileBytes("out"));
for(int i=0;i<seg.Post.Length;i++) {
code.AddRange(HexToString(seg.Post[i].code));
}
if(code.Count>seg.End-seg.Start) throw new OptimizationException("Patcher: Patch to big to fit into code");
/*if(Program.TestPatches) {
TestPatch(seg); //TESTPATCH CALL
}*/
if(Program.Benchmark) {
Benchmark(seg); //BENCHMARK CALL!!!!!!!!!!!!!!!!!!!!!!!! <---------------- OVER HERE
}
byte[] Code=new byte[seg.End-seg.Start];
code.CopyTo(Code);
for(int i=code.Count;i<(seg.End-seg.Start);i++) {
Code[i]=144; //Fill the rest of the code up with nop's
}
long a=(seg.End-seg.Start)-code.Count;
if(a>255) {
throw new OptimizationException("Patcher: Patch end address out of range of a short jump");
} else if(a>2) {
Code[code.Count]=235;
Code[code.Count+1]=(byte)(a-2);
}
if(Program.Restrict) {
if(PatchCount<Program.FirstPatch||PatchCount>Program.LastPatch) {
PatchCount++;
throw new OptimizationException("Patcher: Patch restricted");
}
PatchCount++;
}
#if emitpatch
FileStream fs2=File.Create("emittedpatch.patch",4096);
BinaryWriter bw=new BinaryWriter(fs2);
bw.Write(seg.Start);
bw.Write(Code.Length);
bw.Write(Code,0,Code.Length);
bw.Close();
#endif
FileStream fs=File.Open("code",FileMode.Open);
fs.Position=seg.Start;
fs.Write(Code,0,Code.Length);
fs.Close();
}
示例2: GetFiles
/// <summary>
/// Anche nelle sottodirectory
/// </summary>
/// <param name="path"></param>
/// <param name="pattern"></param>
/// <returns></returns>
public static System.Collections.ArrayList GetFiles(string path, string pattern)
{
System.Collections.ArrayList list = new System.Collections.ArrayList();
try
{
list.AddRange(System.IO.Directory.GetFiles(path, pattern));
}
catch { }
string[] dirs = null;
try
{
dirs = System.IO.Directory.GetDirectories(path);
}
catch { }
if (dirs != null)
{
foreach (string dir in dirs)
{
list.AddRange(GetFiles(dir, pattern));
}
}
return list;
}
示例3: btnRandomize_Click
private void btnRandomize_Click(object sender, EventArgs e)
{
var random = new Random();
var splitArray = new string[1];
var list = new System.Collections.ArrayList();
splitArray[0] = Environment.NewLine; // Used to split the list of owners in the textbox
// Add contents of textbox to array
list.AddRange(txtList.Text.Split(splitArray, StringSplitOptions.RemoveEmptyEntries));
txtList.Clear();
var length = list.Count;
// Loop through list, randomly selecting an item, adding it to the output list,
// then removing it from the list
for (var x = 0; x < length; x++)
{
var index = random.Next(list.Count);
txtList.Text += list[index] + Environment.NewLine;
list.Remove(list[index].ToString());
}
// Add output to clipboard
if (!String.IsNullOrEmpty(txtList.Text))
Clipboard.SetText(txtList.Text);
}
示例4: CopyDirectory
public static void CopyDirectory(string sourcedirectory, string targetdirectory, string logname, string[] extensionesexcluidas, bool iferrorfinish)
{
DirectoryInfo source = new DirectoryInfo(sourcedirectory);
DirectoryInfo target = new DirectoryInfo(targetdirectory);
System.Collections.ArrayList extensiones = new System.Collections.ArrayList();
if (extensionesexcluidas != null)
{
extensiones.AddRange(extensionesexcluidas);
}
_CopyAll(source, target, logname, extensiones,iferrorfinish);
}
示例5: String_To_Bytes
public static byte[] String_To_Bytes(string[] S)
{
System.Collections.ArrayList BB = new System.Collections.ArrayList();
foreach (string s in S)
{
// check for empty strings
if (!(s.Equals("")))
BB.AddRange(String_To_Bytes(s));
BB.Add((byte) 10); // Adds the newline character at the end of each string.
}
return (byte[]) BB.ToArray(typeof (byte));
}
示例6: Array_To_Bytes
public static byte[] Array_To_Bytes(System.Array Arr)
{
System.Collections.ArrayList BB = new System.Collections.ArrayList();
foreach (var V in Arr)
{
string S = V.ToString();
// check for empty strings
if (!(S.Equals("")))
BB.AddRange(String_To_Bytes(S));
BB.Add((byte)10); // Adds the newline character at the end of each array item.
}
return (byte[]) BB.ToArray(typeof (byte));
}
示例7: Deserialize
private static object Deserialize(object obj1)
{
if (obj1 == null)
{
return null;
}
if (obj1.GetType() == typeof(string))
{
string str = obj1.ToString();
if ((((str.Length == 19) && (str[10] == 'T')) && (str[4] == '-')) && (str[13] == ':'))
{
obj1 = Convert.ToDateTime(obj1);
}
return obj1;
}
if (obj1 is Newtonsoft.Json.Linq.JObject)
{
Newtonsoft.Json.Linq.JObject obj2 = obj1 as Newtonsoft.Json.Linq.JObject;
System.Collections.Hashtable hashtable = new System.Collections.Hashtable();
foreach (System.Collections.Generic.KeyValuePair<string, Newtonsoft.Json.Linq.JToken> pair in obj2)
{
hashtable[pair.Key] = Deserialize(pair.Value);
}
obj1 = hashtable;
return obj1;
}
if (obj1 is System.Collections.IList)
{
System.Collections.ArrayList list = new System.Collections.ArrayList();
list.AddRange(obj1 as System.Collections.IList);
int num = 0;
int count = list.Count;
while (num < count)
{
list[num] = Deserialize(list[num]);
num++;
}
obj1 = list;
return obj1;
}
if (typeof(Newtonsoft.Json.Linq.JValue) == obj1.GetType())
{
Newtonsoft.Json.Linq.JValue value2 = (Newtonsoft.Json.Linq.JValue)obj1;
obj1 = Deserialize(value2.Value);
}
return obj1;
}
示例8: StringToCode128
/// <summary>
/// Transform the string into integers representing the Code128 codes
/// necessary to represent it
/// </summary>
/// <param name="AsciiData">String to be encoded</param>
/// <returns>Code128 representation</returns>
private int[] StringToCode128( string AsciiData )
{
// turn the string into ascii byte data
byte[] asciiBytes = Encoding.ASCII.GetBytes( AsciiData );
// decide which codeset to start with
Code128Code.CodeSetAllowed csa1 = asciiBytes.Length>0 ? Code128Code.CodesetAllowedForChar( asciiBytes[0] ) : Code128Code.CodeSetAllowed.CodeAorB;
Code128Code.CodeSetAllowed csa2 = asciiBytes.Length>0 ? Code128Code.CodesetAllowedForChar( asciiBytes[1] ) : Code128Code.CodeSetAllowed.CodeAorB;
CodeSet currcs = GetBestStartSet(csa1,csa2);
// set up the beginning of the barcode
System.Collections.ArrayList codes = new System.Collections.ArrayList(asciiBytes.Length + 3); // assume no codeset changes, account for start, checksum, and stop
codes.Add(Code128Code.StartCodeForCodeSet(currcs));
// add the codes for each character in the string
for (int i = 0; i < asciiBytes.Length; i++)
{
int thischar = asciiBytes[i];
int nextchar = asciiBytes.Length>(i+1) ? asciiBytes[i+1] : -1;
codes.AddRange( Code128Code.CodesForChar(thischar, nextchar, ref currcs) );
}
// calculate the check digit
int checksum = (int)(codes[0]);
for (int i = 1; i < codes.Count; i++)
{
checksum += i * (int)(codes[i]);
}
codes.Add( checksum % 103 );
codes.Add( Code128Code.StopCode() );
int[] result = codes.ToArray(typeof(int)) as int[];
return result;
}
示例9: Update
public void Update(GameTime gameTime)
{
if (es.EditMode)
{
if (es.EditType == EditorType.EntityMode)
{
if (Mouse.GetState().LeftButton == ButtonState.Pressed)
{
if (draggedEntity != null)
{
draggedEntity.getAs<Position>().EntityPosition = RenderingSystem.camera.RealCoordsFromScreen(Mouse.GetState().X, Mouse.GetState().Y) - MouseOffset;
draggedEntity.getAs<Position>().EntityPosition -= new Vector2(draggedEntity.getAs<Position>().EntityPosition.X % (int)es.GridType, draggedEntity.getAs<Position>().EntityPosition.Y % (int)es.GridType);
//draggedEntity.getAs<Position>().EntityPosition = RenderingSystem.camera.RealCoordsFromScreen(Mouse.GetState().X, Mouse.GetState().Y) - MouseOffset;
}
else
{
draggedEntity = TestForTargetedDrawable(Mouse.GetState().X, Mouse.GetState().Y);
if (draggedEntity != null)
{
MouseOffset = RenderingSystem.camera.RealCoordsFromScreen(Mouse.GetState().X, Mouse.GetState().Y) - draggedEntity.getAs<Position>().EntityPosition;
}
}
selectedEntity = TestForTargetedDrawable(Mouse.GetState().X, Mouse.GetState().Y);
}
else
{
draggedEntity = null;
}
}
else if (es.EditType == EditorType.WallMode)
{
if (Keyboard.GetState().IsKeyDown(Keys.Add))
{
System.Threading.Thread.Sleep(100);
if (selectedEntity == null)
{
selectedEntity = new Entity(es.CreateEntityID());
}
Wall entWall = selectedEntity.getAs<Wall>();
if (entWall == null)
{
entWall = new Wall();
es.RegisterComponent(selectedEntity, entWall);
}
System.Collections.ArrayList wallPoints = new System.Collections.ArrayList();
if (entWall.WallPoints != null)
{
wallPoints.AddRange(entWall.WallPoints);
}
if (wallPoints.Count == 0)
{
wallPoints.Add(new Vector2(0, 0));
}
Vector2 lastPoint = (Vector2)wallPoints[wallPoints.Count - 1];
wallPoints.Add(new Vector2(lastPoint.X + 30, lastPoint.Y + 30));
entWall.WallPoints = (Vector2[])wallPoints.ToArray(typeof(Vector2));
}
if (Keyboard.GetState().IsKeyDown(Keys.Subtract))
{
if (selectedEntity != null)
{
Wall entWall = selectedEntity.getAs<Wall>();
if (entWall != null)
{
if (entWall.WallPoints != null)
{
System.Collections.ArrayList wallPoints = new System.Collections.ArrayList();
wallPoints.AddRange(entWall.WallPoints);
for (int i = 0; i < wallPoints.Count; i++)
{
if (selectedVertex == i)
{
wallPoints.RemoveAt(i);
break;
}
}
entWall.WallPoints = (Vector2[])wallPoints.ToArray(typeof(Vector2));
}
}
}
}
if (Mouse.GetState().LeftButton == ButtonState.Pressed)
{
if (selectedEntity != null)
{
Wall entWall = selectedEntity.getAs<Wall>();
if (entWall != null)
//.........这里部分代码省略.........
示例10: GetTerms
public override System.Collections.ICollection GetTerms()
{
System.Collections.ArrayList terms = new System.Collections.ArrayList();
System.Collections.IEnumerator i = clauses.GetEnumerator();
while (i.MoveNext())
{
SpanQuery clause = (SpanQuery) i.Current;
//{{}}// _SupportClass.ICollectionSupport.AddAll(terms, clause.GetTerms()); // {{Aroush}}
terms.AddRange(clause.GetTerms());
}
return terms;
}
示例11: LoadParametersTable
private bool LoadParametersTable()
{
bool parametersExist=false;
// open report
if(_report.State==Report.StateEnum.Closed)
_report.Open();
System.Collections.ArrayList list=new System.Collections.ArrayList();
foreach(Hierarchy hier in _report.Schema.Hierarchies)
list.AddRange(hier.GetPromptCalcMembers());
foreach(CalculatedMember cmem in list)
{
parametersExist=true;
AddParameterInput(cmem);
}
return parametersExist;
}
示例12: Convert
private int[] Convert(string data)
{
byte[] asciiBytes = Encoding.ASCII.GetBytes(data);
CodeSetAllowed csa1 = asciiBytes.Length > 0 ? CodesetAllowedForChar(asciiBytes[0]) : CodeSetAllowed.CodeAorB;
CodeSetAllowed csa2 = asciiBytes.Length > 0 ? CodesetAllowedForChar(asciiBytes[1]) : CodeSetAllowed.CodeAorB;
CodeSet currcs = PickStartSet(csa1, csa2);
System.Collections.ArrayList codes = new System.Collections.ArrayList(asciiBytes.Length + 3);
codes.Add(StartCode(currcs));
for (int i = 0; i < asciiBytes.Length; i++)
{
int thischar = asciiBytes[i];
int nextchar = asciiBytes.Length > (i + 1) ? asciiBytes[i + 1] : -1;
codes.AddRange(CodesForChar(thischar, nextchar, ref currcs));
}
int checksum = (int)(codes[0]);
for (int i = 1; i < codes.Count; i++)
{
checksum += i * (int)(codes[i]);
}
codes.Add(checksum % 103);
codes.Add(StopCode());
int[] result = codes.ToArray(typeof(int)) as int[];
return result;
}
示例13: WriteClass
/// <summary> Write a Class XML Element from attributes in a type. </summary>
public virtual void WriteClass(System.Xml.XmlWriter writer, System.Type type)
{
object[] attributes = type.GetCustomAttributes(typeof(ClassAttribute), false);
if(attributes.Length == 0)
return;
ClassAttribute attribute = attributes[0] as ClassAttribute;
writer.WriteStartElement( "class" );
// Attribute: <entity-name>
if(attribute.EntityName != null)
writer.WriteAttributeString("entity-name", GetAttributeValue(attribute.EntityName, type));
// Attribute: <name>
if(attribute.Name != null)
writer.WriteAttributeString("name", GetAttributeValue(attribute.Name, type));
// Attribute: <proxy>
if(attribute.Proxy != null)
writer.WriteAttributeString("proxy", GetAttributeValue(attribute.Proxy, type));
// Attribute: <lazy>
if( attribute.LazySpecified )
writer.WriteAttributeString("lazy", attribute.Lazy ? "true" : "false");
// Attribute: <schema-action>
if(attribute.SchemaAction != null)
writer.WriteAttributeString("schema-action", GetAttributeValue(attribute.SchemaAction, type));
// Attribute: <table>
if(attribute.Table != null)
writer.WriteAttributeString("table", GetAttributeValue(attribute.Table, type));
// Attribute: <schema>
if(attribute.Schema != null)
writer.WriteAttributeString("schema", GetAttributeValue(attribute.Schema, type));
// Attribute: <catalog>
if(attribute.Catalog != null)
writer.WriteAttributeString("catalog", GetAttributeValue(attribute.Catalog, type));
// Attribute: <subselect>
if(attribute.Subselect != null)
writer.WriteAttributeString("subselect", GetAttributeValue(attribute.Subselect, type));
// Attribute: <discriminator-value>
if(attribute.DiscriminatorValue != null)
writer.WriteAttributeString("discriminator-value", GetAttributeValue(attribute.DiscriminatorValue, type));
// Attribute: <mutable>
if( attribute.MutableSpecified )
writer.WriteAttributeString("mutable", attribute.Mutable ? "true" : "false");
// Attribute: <abstract>
if( attribute.AbstractSpecified )
writer.WriteAttributeString("abstract", attribute.Abstract ? "true" : "false");
// Attribute: <polymorphism>
if(attribute.Polymorphism != PolymorphismType.Unspecified)
writer.WriteAttributeString("polymorphism", GetXmlEnumValue(typeof(PolymorphismType), attribute.Polymorphism));
// Attribute: <where>
if(attribute.Where != null)
writer.WriteAttributeString("where", GetAttributeValue(attribute.Where, type));
// Attribute: <persister>
if(attribute.Persister != null)
writer.WriteAttributeString("persister", GetAttributeValue(attribute.Persister, type));
// Attribute: <dynamic-update>
if( attribute.DynamicUpdateSpecified )
writer.WriteAttributeString("dynamic-update", attribute.DynamicUpdate ? "true" : "false");
// Attribute: <dynamic-insert>
if( attribute.DynamicInsertSpecified )
writer.WriteAttributeString("dynamic-insert", attribute.DynamicInsert ? "true" : "false");
// Attribute: <batch-size>
if(attribute.BatchSize != -9223372036854775808)
writer.WriteAttributeString("batch-size", attribute.BatchSize.ToString());
// Attribute: <select-before-update>
if( attribute.SelectBeforeUpdateSpecified )
writer.WriteAttributeString("select-before-update", attribute.SelectBeforeUpdate ? "true" : "false");
// Attribute: <optimistic-lock>
if(attribute.OptimisticLock != OptimisticLockMode.Unspecified)
writer.WriteAttributeString("optimistic-lock", GetXmlEnumValue(typeof(OptimisticLockMode), attribute.OptimisticLock));
// Attribute: <check>
if(attribute.Check != null)
writer.WriteAttributeString("check", GetAttributeValue(attribute.Check, type));
// Attribute: <rowid>
if(attribute.RowId != null)
writer.WriteAttributeString("rowid", GetAttributeValue(attribute.RowId, type));
// Attribute: <node>
if(attribute.Node != null)
writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, type));
WriteUserDefinedContent(writer, type, null, attribute);
// Element: <meta>
System.Collections.ArrayList MetaList = FindAttributedMembers( attribute, typeof(MetaAttribute), type );
foreach( System.Reflection.MemberInfo member in MetaList )
{
object[] objects = member.GetCustomAttributes(typeof(MetaAttribute), false);
System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
memberAttribs.AddRange(objects);
memberAttribs.Sort();
foreach(object memberAttrib in memberAttribs)
WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, type);
}
WriteUserDefinedContent(writer, type, typeof(MetaAttribute), attribute);
// Element: <subselect>
System.Collections.ArrayList SubselectList = FindAttributedMembers( attribute, typeof(SubselectAttribute), type );
foreach( System.Reflection.MemberInfo member in SubselectList )
{
object[] objects = member.GetCustomAttributes(typeof(SubselectAttribute), false);
System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
memberAttribs.AddRange(objects);
memberAttribs.Sort();
//.........这里部分代码省略.........
示例14: IndexSerial
public static void IndexSerial(System.Collections.IDictionary docs, Directory dir)
{
IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
// index all docs in a single thread
System.Collections.IEnumerator iter = docs.Values.GetEnumerator();
while (iter.MoveNext())
{
Document d = (Document) iter.Current;
System.Collections.ArrayList fields = new System.Collections.ArrayList();
fields.AddRange(d.GetFields());
// put fields in same order each time
//{{Lucene.Net-2.9.1}} No, don't change the order of the fields
//SupportClass.CollectionsHelper.Sort(fields, fieldNameComparator);
Document d1 = new Document();
d1.SetBoost(d.GetBoost());
for (int i = 0; i < fields.Count; i++)
{
d1.Add((Fieldable) fields[i]);
}
w.AddDocument(d1);
// System.out.println("indexing "+d1);
}
w.Close();
}
示例15: listBox2_SelectedIndexChanged
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
System.Collections.ArrayList counters = new System.Collections.ArrayList();
if (this.listBox2.SelectedIndex != -1)
{
System.Diagnostics.PerformanceCounterCategory selectedPerfCat = new System.Diagnostics.PerformanceCounterCategory(this.listBox1.SelectedItem.ToString());
string selectedInstance = this.listBox2.SelectedItem.ToString();
this.listBox3.Items.Clear();
try
{
counters.AddRange(selectedPerfCat.GetCounters(selectedInstance));
foreach (System.Diagnostics.PerformanceCounter counter in counters)
{
this.listBox3.Items.Add(counter.CounterName);
}
}
catch (System.Exception ex)
{
MessageBox.Show("Unable to list the counters for this category:\n" + ex.Message);
}
}
}