/// <summary> /// Reads byte[] line from stream. /// </summary> /// <returns>Return null if end of stream reached.</returns> public byte[] ReadLine() { ArrayList lineBuf = new ArrayList(); byte prevByte = 0; int currByteInt = m_StrmSource.ReadByte(); while(currByteInt > -1){ lineBuf.Add((byte)currByteInt); // Line found if((prevByte == (byte)'\r' && (byte)currByteInt == (byte)'\n')){ byte[] retVal = new byte[lineBuf.Count-2]; // Remove <CRLF> lineBuf.CopyTo(0,retVal,0,lineBuf.Count-2); return retVal; } // Store byte prevByte = (byte)currByteInt; // Read next byte currByteInt = m_StrmSource.ReadByte(); } // Line isn't terminated with <CRLF> and has some chars left, return them. if(lineBuf.Count > 0){ byte[] retVal = new byte[lineBuf.Count]; lineBuf.CopyTo(0,retVal,0,lineBuf.Count); return retVal; } return null; }
public void CopyTo(Array array, int index) { ArrayList arrayList = new ArrayList(); foreach (BrokerPosition brokerPosition in this) arrayList.Add((object)brokerPosition); arrayList.CopyTo(array, index); }
public static AvailablePlugin[] FindPlugins(string strPath, string strInterface) { ArrayList Plugins = new ArrayList(); string[] strDLLs = null; int intIndex = default(int); Assembly objDLL = default(Assembly); //Go through all DLLs in the directory, attempting to load them strDLLs = Directory.GetFileSystemEntries(strPath, "*.dll"); for (intIndex = 0; intIndex <= strDLLs.Length - 1; intIndex++) { try { objDLL = Assembly.LoadFrom(strDLLs[intIndex]); ExamineAssembly(objDLL, strInterface, Plugins); } catch (Exception) { //Error loading DLL, we don't need to do anything special } } //Return all plugins found AvailablePlugin[] Results = new AvailablePlugin[Plugins.Count - 1 + 1]; if (Plugins.Count != 0) { Plugins.CopyTo(Results); return Results; } else { return null; } }
/* BytePPToArray * Converts a C-style string array into a .NET managed string array * Parameters * C-style string array pointer returned from PhysFS * Returns * .NET managed string array * Exceptions * none */ public static unsafe string[] BytePPToArray(byte **bytearray) { byte** ptr; byte* c; string tempstr; ArrayList MyArrayList = new ArrayList(); string[] RetArray; for(ptr = bytearray; *ptr != null; ptr++) { tempstr = ""; for(c = *ptr; *c != 0; c++) { tempstr += (char)*c; } // Add string to our list MyArrayList.Add(tempstr); } // Return a normal array of the list RetArray = new string[MyArrayList.Count]; MyArrayList.CopyTo(RetArray, 0); return RetArray; }
/// <summary> /// Gets all thread status. /// </summary> /// <returns></returns> public string[] getAllThreadStatus() { ArrayList responses = new ArrayList(); foreach (IThreadedSystem item in this._threadedObjects) { string status = item.GetType() + ": "; try { foreach (string i in item.getThreadStatus()) { responses.Add(status + i); } } catch (NotImplementedException) { status += "Not available."; responses.Add(status); } } string[] responseArray = new string[responses.Count]; responses.CopyTo(responseArray); return responseArray; }
public static TreeNode[] ToPlainArray( TreeNodeCollection nodes ) { TreeNode[] arrayOut; if( nodes.Count > 0 ) { ArrayList array = new ArrayList(); TreeNode next = null, start = nodes[0]; array.Add( start ); while( null != ( next = FindNextNode( nodes, start ) ) ) { if( next == start ) break; array.Add( start = next ); } arrayOut = new TreeNode[ array.Count ]; array.CopyTo( arrayOut, 0 ); return arrayOut; } return null; }
/// <summary> /// Gets MX records from answer collection and ORDERS them by preference. /// NOTE: Duplicate preference records are appended to end. /// </summary> /// <returns></returns> internal MX_Record[] GetMxRecordsFromAnswers() { MX_Record[] retVal = null; try { SortedList mx = new SortedList(); ArrayList duplicateList = new ArrayList(); foreach(Dns_Answer answer in m_Answers){ if(answer.QTYPE == QTYPE.MX){ MX_Record mxRec = (MX_Record)answer.RecordObj; if(!mx.Contains(mxRec.Preference)){ mx.Add(mxRec.Preference,mxRec); } else{ duplicateList.Add(mxRec); } } } MX_Record[] mxBuff = new MX_Record[mx.Count + duplicateList.Count]; mx.Values.CopyTo(mxBuff,0); duplicateList.CopyTo(mxBuff,mx.Count); retVal = mxBuff; } catch{ } return retVal; }
/// <summary> /// Diese Funktion gibt alle EtbEintraege zurueck, die nicht Systemereignisse sind. /// </summary> /// <returns>Menge aller EtbZusatzeintraege</returns> public Cdv_EtbEintrag[] LadeEtbEintraege() { // hole alle EtbEintraege pELS.DV.Server.Interfaces.IPelsObject[] ipoa = _ObjektManager.EtbEintraege.HolenAlle(); if(!(ipoa == null) || (ipoa.Length == 0)) { Cdv_EtbEintrag[] tmpEtbEintraege = new Cdv_EtbEintrag[ipoa.Length]; ipoa.CopyTo(tmpEtbEintraege,0); //Schmeiße alle Systemereignisse raus ArrayList _tmpAL = new ArrayList(); for (int pos = 0; pos < tmpEtbEintraege.Length; pos++) { if (tmpEtbEintraege[pos].GetType().ToString() != "pELS.DV.Cdv_Systemereignis") _tmpAL.Add(tmpEtbEintraege[pos]); } // kopiere Einträge aus ArrayList nach Array Cdv_EtbEintrag[] pout_EtbEintraege = new Cdv_EtbEintrag[_tmpAL.Count]; _tmpAL.CopyTo(pout_EtbEintraege); //nach Datum sortieren pout_EtbEintraege = this.SortiereNachDatum(pout_EtbEintraege); return pout_EtbEintraege; } else return null; }
/// <summary> /// Gets iSC's available _AMMediaTypes, without freeing pbFormat /// Caller should call MediaType.Free(_AMMediaType[]) when done /// </summary> public static _AMMediaType[] GetMediaTypes(IPin pin) { IEnumMediaTypes iEnum; pin.EnumMediaTypes(out iEnum); ArrayList alMTs = new ArrayList(); IntPtr[] ptrs = new IntPtr[1]; uint fetched; iEnum.Next(1, ptrs, out fetched); while(fetched == 1) { _AMMediaType mt = (_AMMediaType)Marshal.PtrToStructure(ptrs[0], typeof(_AMMediaType)); alMTs.Add(mt); Marshal.FreeCoTaskMem(ptrs[0]); ptrs[0] = IntPtr.Zero; iEnum.Next(1, ptrs, out fetched); } _AMMediaType[] mts = new _AMMediaType[alMTs.Count]; alMTs.CopyTo(mts); return mts; }
public static BeneficiaryProjLocInfo[] GetAllBeneficiaries() { ArrayList al = new ArrayList(); int retValue = -1; //Generated Code for query : dbo.GetAllVendors using (SqlDataReader dr = ProjManagementAdmin.GetAllBeneficiaries(out retValue)) //Initialize and retrieve code for Datareader goes here { while (dr.Read()) { BeneficiaryProjLocInfo b = new BeneficiaryProjLocInfo(); b.BeneficiaryId = Convert.ToInt32(dr["beneficiary_id"]); b.BeneficiaryName = dr["beneficiary_name"].ToString(); b.BeneficiaryAddress = dr["beneficiary_address"].ToString(); b.ProjectLocationId = Convert.ToInt32(dr["project_location_id"]); b.ProjectId = Convert.ToInt32(dr["project_id"]); b.ProjectName = dr["project_name"].ToString(); // b.ProjectCode = dr["project_code"].ToString(); b.LocationId = Convert.ToInt32(dr["location_id"]); b.LocationName = dr["location_name"].ToString(); b.IsActive = Convert.ToBoolean(dr["is_active"]); b.CreatedDate = Convert.ToDateTime(dr["created_date"]); b.ChangedDate = Convert.ToDateTime(dr["changed_date"]); b.ChangedBy = dr["changed_by"].ToString(); al.Add(b); } //dr.Close(); } BeneficiaryProjLocInfo[] allInfo = new BeneficiaryProjLocInfo[al.Count]; al.CopyTo(allInfo); return allInfo; }
/// <summary> /// Initializes this force-directed layout. Assumes that graph has some /// reasonable initial node positions. /// </summary> /// <param name="graph">The graph to layout.</param> /// <param name="start_node">The node to start layout from.</param> public ForceDirectedLayout(IReadOnlyGraph<FDLNode, FDLEdge> graph, FDLNode start_node) { if (graph == null) throw new ArgumentNullException("graph"); if (start_node == null) throw new ArgumentNullException("start_node"); if (!graph.ContainsNode(start_node)) throw new ArgumentException("start_node must be in this graph"); //initialize nodes array to only the reachable nodes ArrayList n = new ArrayList(graph.NodeCount); Algorithms.Algorithms.BreadthFirstSearch(graph, start_node, null, delegate(FDLNode node){ n.Add(node); }); nodes = new FDLNode[n.Count]; n.CopyTo(nodes); new_positions = new MutablePoint[nodes.Length]; accels = new double[nodes.Length]; //summarize constraints HashSet<FDLEdge> h = new HashSet<FDLEdge>(); for (int i = 0; i < nodes.Length; i++) { foreach (FDLEdge edge in nodes[i].OutEdges) { DefaultEdge reverse = edge.Target.GetEdgeTo(edge.Source); if(h.Contains(edge) || (reverse != null && h.Contains(reverse))) continue; h.Add(edge); } } constraints = new FDLEdge[h.Count]; h.CopyTo(constraints); }
public bool TryConvert(ConvertArgs args) { if (!args.DestinationType.IsArray) { return false; } if (args.Reader.Value == null) { args.ConvertedObject = null; return true; } ArrayList arrayList = new ArrayList(); var elementType = args.DestinationType.GetElementType(); var enumerableItems = args.Reader.Value as IEnumerable; if (enumerableItems == null) { return true; } foreach (var obj in enumerableItems) { Type toElementType = args.Converter.GetDestinationType(obj, elementType); var dstObject = args.Converter.MapObject(obj, toElementType); arrayList.Add(dstObject); } var array = (Array)Activator.CreateInstance(args.DestinationType, new object[] { arrayList.Count }); arrayList.CopyTo(array); args.ConvertedObject = array; return true; }
public static LocationInfo[] GetAllLocations() { ArrayList al = new ArrayList(); int retValue = -1; //Generated Code for query : dbo.GetAllVendors using (SqlDataReader dr = ProjManagementAdmin.GetAllLocations(out retValue)) //Initialize and retrieve code for Datareader goes here { while (dr.Read()) { LocationInfo location = new LocationInfo(); location.LocationId = Convert.ToInt32(dr["location_id"]); location.LocationName = dr["location_name"].ToString(); location.CreatedDate = Convert.ToDateTime(dr["created_date"]); location.ChangedDate = Convert.ToDateTime(dr["changed_date"]); location.ChangedByName = dr["changed_by"].ToString(); al.Add(location); } //dr.Close(); } LocationInfo[] allInfo = new LocationInfo[al.Count]; al.CopyTo(allInfo); return allInfo; }
private void SaveButton_Click(object sender, EventArgs e) { if (SubjectBox.Text.Length == 0) { MessageBox.Show("Cannot proceed with empty name"); return; } ArrayList list = new ArrayList((string[])Host.SubjectList.DataSource); list.Sort(); int id = list.BinarySearch(SubjectBox.Text); if (id >= 0) { MessageBox.Show("Subject with that name already exists!"); return; } id = ~id; list.Insert(id, SubjectBox.Text); string[] n = new string[list.Count]; list.CopyTo(n); Host.SubjectBox2.AutoCompleteCustomSource.Add(SubjectBox.Text); Host.SubjectList.DataSource = n; Host.RenewSubjectList(); Host.SubjectList.SelectedItem = SubjectBox.Text; this.Close(); }
/// <summary> /// Split Function that Supports Text Qualifiers /// Source: http://www.codeproject.com/KB/dotnet/TextQualifyingSplit.aspx /// </summary> private static string[] Split(string expression, string delimiter, string qualifier, bool ignoreCase) { bool qualifierState = false; int startIndex = 0; ArrayList values = new ArrayList(); for (int charIndex = 0; charIndex < expression.Length - 1; charIndex++) { if ((qualifier != null) & (string.Compare(expression.Substring(charIndex, qualifier.Length), qualifier, ignoreCase) == 0)) { qualifierState = !(qualifierState); } else if (!(qualifierState) & (delimiter != null) & (string.Compare(expression.Substring(charIndex, delimiter.Length), delimiter, ignoreCase) == 0)) { values.Add(expression.Substring(startIndex, charIndex - startIndex)); startIndex = charIndex + 1; } } if (startIndex < expression.Length) values.Add(expression.Substring(startIndex, expression.Length - startIndex)); string[] returnValues = new string[values.Count]; values.CopyTo(returnValues); return returnValues; }
public void Add(string name, string fieldValue, bool readOnly) { ArrayList list = new ArrayList(this.SharePointListFields); list.Add(new SharePointListField(name, fieldValue, readOnly)); this.sharePointListFields = new SharePointListField[list.Count]; list.CopyTo(this.SharePointListFields); }
/// <summary> /// Copy property value of object stored in source into destination array. /// </summary> /// <param name="source">List of object which property must be read</param> /// <param name="array">Destination array</param> /// <param name="property">Source Object Property Name</param> /// <param name="startIndx">Start index of source object</param> public static void CopyTo( IList source, Array array, string property, int index ) { ArrayList list = new ArrayList( source.Count ); PropertyInfo keyProp = null; int iCount = 0; foreach( object obj in source ) { if( keyProp == null ) { keyProp = obj.GetType().GetProperty( property ); if( keyProp == null ) throw new ArgumentException( "Property Name of object is wrong", "property" ); } if( iCount >= index ) { list.Add( keyProp.GetValue( obj, null ) ); } iCount++; } list.CopyTo( array ); list.Clear(); }
public void CopyTo(Array array, int index) { ArrayList arrayList = new ArrayList(); foreach (BrokerOrder brokerOrder in this) arrayList.Add((object)brokerOrder); arrayList.CopyTo(array, index); }
public void CopyTo(Array array, int index) { ArrayList arrayList = new ArrayList(); foreach (BrokerAccountField brokerAccountField in this) arrayList.Add((object)brokerAccountField); arrayList.CopyTo(array, index); }
static void Main(string[] args) { ArrayList al = new ArrayList(); al.Add("string"); al.Add('B'); al.Add(10); al.Add(DateTime.Now); ArrayList bl = new ArrayList(5); al.Remove('B'); // 从al中删除第一个匹配的对象,如果al中不包含该对象,数组保持不变,不引发异常。 al.Remove('B'); al.RemoveAt(0); al.RemoveRange(0, 1); bl.Add(1); bl.Add(11); bl.Add(111); bl.Insert(4, 1111); int[] inttest = (int[])bl.ToArray(typeof(int)); foreach(int it in inttest) Console.WriteLine(it); int[] inttest2 = new int[bl.Count]; bl.CopyTo(inttest2); ArrayList cl = new ArrayList(); cl.Add(1); cl.Add("Hello, World!"); object[] ol = (object[])cl.ToArray(typeof(object)); // stringp[] os = (string[])cl.ToArray(typeof(string)); Console.WriteLine("The Capacity of new ArrayList: {0}", al.Capacity); }
public static string[] SplitXP(this string expression, string delimiter, string qualifier, bool ignoreCase) { bool qualifierState = false; int startIndex = 0; var values = new System.Collections.ArrayList(); for (int charIndex = 0; charIndex < expression.Length - 1; charIndex++) { if ((qualifier != null) & (string.Compare(expression.Substring (charIndex, qualifier.Length), qualifier, ignoreCase) == 0)) { qualifierState = !(qualifierState); } else if (!(qualifierState) & (delimiter != null) & (string.Compare(expression.Substring (charIndex, delimiter.Length), delimiter, ignoreCase) == 0)) { values.Add(expression.Substring (startIndex, charIndex - startIndex)); startIndex = charIndex + 1; } } if (startIndex < expression.Length) { values.Add(expression.Substring (startIndex, expression.Length - startIndex)); } var returnValues = new string[values.Count]; values.CopyTo(returnValues); return(returnValues); }
public static UserInfo[] GetAllUsers() { ArrayList al = new ArrayList(); int retValue = -1; //Generated Code for query : dbo.GetAllVendors using (SqlDataReader dr = ProjManagementAdmin.GetAllUsers(out retValue)) //Initialize and retrieve code for Datareader goes here { while (dr.Read()) { UserInfo user = new UserInfo(); user.UserName = dr["user_name"].ToString(); user.UserId = Convert.ToInt32(dr["user_id"]); user.UserEmail = dr["user_email"].ToString(); user.RoleId = Convert.ToInt32(dr["role_id"]); // user.Password = Convert.ToChar(dr["password"]); user.CreatedDate = Convert.ToDateTime(dr["created_date"]); user.ChangedDate = Convert.ToDateTime(dr["changed_date"]); user.ChangedBy = dr["changed_by"].ToString(); al.Add(user); } //dr.Close(); } UserInfo[] allInfo = new UserInfo[al.Count]; al.CopyTo(allInfo); return allInfo; }
public Block[] getProxyBlocks( int limit ) { string cmdText = "SELECT * FROM ipblocks i WHERE ipb_reason LIKE \"%proxy%\" AND ipb_user = 0"; if( limit != 0 ) cmdText += " LIMIT " + limit.ToString( ); cmdText += ";"; MySqlCommand cmd = new MySqlCommand( cmdText ); cmd.Connection = db_connection; MySqlDataReader dr = cmd.ExecuteReader( ); ArrayList blocks = new ArrayList( ); while( dr.Read() ) { object[ ] vals = new object[ dr.FieldCount ]; dr.GetValues( vals ); blocks.Add(Block.newFromDataRow( vals )); } dr.Close( ); Block[ ] bA = new Block[ blocks.Count ]; blocks.CopyTo( bA ); return bA; }
//EXECUTION protected override void InternalExecution() { int size = 100; IList list = new ArrayList(); IQuantumState newState; IQuantumOperator randomizer = QuantumOperatorFactory.generateRandomizeOperator(); TesterLog("Generating " + size + " QuantumSimpleStates of 3 levels and initializing to random...."); for (int i = 0; i < size; i++) { newState = QuantumStateFactory.generateStateSimple(3); randomizer.Evaluate(newState); list.Add(newState); } TesterLog(""); TesterLog("Showing all of them"); for (int i = 0; i < size; i++) { newState = (IQuantumState)list[i]; TesterLog(newState.generateQuantumDebugger().FullDebug); } TesterLog(""); TesterLog("Getting a composed state of all of them"); IQuantumState[] array = new IQuantumState[list.Count]; list.CopyTo(array,0); IQuantumState composed = QuantumStateFactory.generateStateComposed(array); TesterLog(composed.generateQuantumDebugger().FullDebug); }
/// <summary> /// Construct the palette quantizer /// </summary> /// <param name="palette">The color palette to quantize to</param> /// <remarks> /// Palette quantization only requires a single quantization step /// </remarks> public PaletteQuantizer ( ArrayList palette ) : base ( true ) { _colorMap = new Hashtable ( ) ; _colors = new Color[palette.Count] ; palette.CopyTo ( _colors ) ; }
public void init() { IList temp = new ArrayList(); temp.Add(new ListItem("Interpret", "0")); temp.Add(new ListItem("Titel","1")); temp.Add(new ListItem("Autor","2")); temp.Add(new ListItem("Bpm","3")); temp.Add(new ListItem("Code","4")); temp.Add(new ListItem("Ending","5")); temp.Add(new ListItem("Label","6")); temp.Add(new ListItem("Laenge","7")); temp.Add(new ListItem("Verlag","8")); temp.Add(new ListItem("Year","9")); ListItem[] categories = new ListItem[temp.Count]; temp.CopyTo(categories, 0); temp = new ArrayList(); temp.Add(new ListItem("IS","0")); temp.Add(new ListItem("NOT", "1")); ListItem[] relators = new ListItem[temp.Count]; temp.CopyTo(relators, 0); using(mocks.Record()) { this.view.SearchCategories = categories; this.view.UnaryRelators = relators; } using(mocks.Playback()) { presenter.initialise(); } }
internal void AddClassesExcluding(ClassScope excludedClass, string name, ArrayList result) { ArrayList list = new ArrayList(); foreach (MemberInfo info in this.GetMembers(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static)) { if ((info is JSVariableField) && ((JSVariableField) info).IsLiteral) { object obj2 = ((JSVariableField) info).value; if (obj2 is ClassScope) { ClassScope other = (ClassScope) obj2; if (((other.name == info.Name) && ((excludedClass == null) || !excludedClass.IsSameOrDerivedFrom(other))) && (other.GetMember(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Length > 0)) { list.Add(other); } } } } if (list.Count != 0) { ClassScope[] array = new ClassScope[list.Count]; list.CopyTo(array); Array.Sort<ClassScope>(array); result.AddRange(array); } }
/// <summary> /// Parses name-value params. /// </summary> /// <param name="source">Parse source.</param> /// <param name="expressions">Expressions importance order. NOTE: must contain param and value groups.</param> public static _Parameter[] Paramparser_NameValue(string source,string[] expressions) { string tmp = source.Trim(); ArrayList param = new ArrayList(); foreach(string exp in expressions){ Regex r = new Regex(exp,RegexOptions.IgnoreCase); Match m = r.Match(tmp); if(m.Success){ param.Add(new _Parameter(m.Result("${param}").Trim(),m.Result("${value}"))); // remove matched string part form tmp tmp = tmp.Replace(m.ToString(),"").Trim(); } } // There are some unparsed params, add them as UnParsed if(tmp.Trim().Length > 0){ param.Add(new _Parameter("UNPARSED",tmp)); } _Parameter[] retVal = new _Parameter[param.Count]; param.CopyTo(retVal); return retVal; }
public void CopyTo(Array array, int index) { if (this.isDisposed) { throw new ObjectDisposedException(name); } if (array == null) { throw new ArgumentNullException("array"); } if ((index < array.GetLowerBound(0)) || (index > array.GetUpperBound(0))) { throw new ArgumentOutOfRangeException("index"); } int num = array.Length - index; int num2 = 0; ArrayList list = new ArrayList(); ManagementObjectEnumerator enumerator = this.GetEnumerator(); while (enumerator.MoveNext()) { ManagementBaseObject current = enumerator.Current; list.Add(current); num2++; if (num2 > num) { throw new ArgumentException(null, "index"); } } list.CopyTo(array, index); }
internal OracleDataReader(OracleCommand command, ArrayList refCursorParameterOrdinals, string statementText, CommandBehavior commandBehavior) { this.ObjectID = Interlocked.Increment(ref _objectTypeCount); this._commandBehavior = commandBehavior; this._statementText = statementText; this._closeConnectionToo = this.IsCommandBehavior(CommandBehavior.CloseConnection); if (CommandType.Text == command.CommandType) { this._keyInfoRequested = this.IsCommandBehavior(CommandBehavior.KeyInfo); } ArrayList list = new ArrayList(); int num2 = 0; OracleDataReader reader = null; for (int i = 0; i < refCursorParameterOrdinals.Count; i++) { int num3 = (int) refCursorParameterOrdinals[i]; OracleParameter parameter = command.Parameters[num3]; if (OracleType.Cursor == parameter.OracleType) { reader = (OracleDataReader) parameter.Value; reader._recordsAffected = num2; list.Add(reader); parameter.Value = DBNull.Value; } else { num2 += (int) parameter.Value; } } this._refCursorDataReaders = new OracleDataReader[list.Count]; list.CopyTo(this._refCursorDataReaders); this._nextRefCursor = 0; this.NextResultInternal(); }
/// <summary> /// Returns an array of any MethodInfo's on a Type that are marked as ValidationMethod /// </summary> /// <param name="objectType">CLR Type to search for validation methods</param> /// <returns></returns> public static MethodInfo[] GetValidationMethods(Type objectType) { var methodList = new ArrayList(); MethodInfo[] methods = objectType.GetMethods(); foreach (MethodInfo method in methods) { var att = (ValidationMethodAttribute) GetCustomAttribute(method, typeof (ValidationMethodAttribute)); if (att != null) { if (method.GetParameters().Length > 0) { string msg = string.Format( "Method *{0}* in Class *{1}* cannot be a validation method because it has parameters", method.Name, objectType.AssemblyQualifiedName); throw new ApplicationException(msg); } methodList.Add(method); } } var returnValue = new MethodInfo[methodList.Count]; methodList.CopyTo(returnValue, 0); return returnValue; }
//<snippet1> private void InitializeTreeView() { // Construct the TreeView object. this.TreeView1 = new System.Windows.Forms.TreeView(); // Set dock, location, size name, and tab order // values for the TreeView object. TreeView1.Dock = System.Windows.Forms.DockStyle.Left; TreeView1.Location = new System.Drawing.Point(0, 0); TreeView1.Name = "TreeView1"; TreeView1.Size = new System.Drawing.Size(152, 266); TreeView1.TabIndex = 1; // Associate the event-handling methods with the // BeforeLabeEdit and the AfterSelect events. TreeView1.BeforeLabelEdit += new NodeLabelEditEventHandler(TreeView1_BeforeLabelEdit); TreeView1.AfterSelect += new TreeViewEventHandler(TreeView1_AfterSelect); // Set the LabelEdit property to true to allow the // user to edit the TreeNode text. this.TreeView1.LabelEdit = true; // Declare and create objects needed to populate // the TreeView. string[] files = new string[] { "bigPresentation.ppt", "myFinances.xls", "myResume.doc" };; string filePath = "c:\\myFiles"; System.Collections.ArrayList nodes = new System.Collections.ArrayList(); // Create a node for each file, setting the Text property to the // file's name and the Tag property to file's fully-qualified name. foreach (string file in files) { TreeNode node = new TreeNode(file); node.Tag = filePath + "\\" + file; nodes.Add(node); } TreeNode[] treeNodes = new TreeNode[nodes.Count]; nodes.CopyTo(treeNodes); // Create a new node named topNode and add the ArrayList of // nodes to topNode. TreeNode topNode = new TreeNode("myFiles", treeNodes); topNode.Tag = filePath; // Add topNode to the TreeView. TreeView1.Nodes.Add(topNode); // Add the TreeView to the form. this.Controls.Add(TreeView1); }
public void CopyTo(Array array, int index) { // TODO: Add ControlListView.CopyTo implementation for (int i = 0; i < array.Length; i++) { if (!(array.GetValue(i) is TileListItem)) { throw new Exception("Only TileListItem class is expected"); } } this.Controls.CopyTo(array, index); controlList.CopyTo(array, index); }
static public int CopyTo__Array(IntPtr l) { try { System.Collections.ArrayList self = (System.Collections.ArrayList)checkSelf(l); System.Array a1; checkType(l, 2, out a1); self.CopyTo(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success) { System.Collections.ArrayList arraylist = (System.Collections.ArrayList)((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value; try { object lo; if (stackframe.player.linktypemapper.rtValueToLinkObject( argements[0], stackframe.player.linktypemapper.getLinkType( functionDefine.signature.parameters[0].type ), bin,true,out lo )) { arraylist.CopyTo((Array)lo); returnSlot.setValue(ASBinCode.rtData.rtUndefined.undefined); success = true; } else { stackframe.throwCastException(token,argements[0].rtType, functionDefine.signature.parameters[0].type ); success = false; } } catch (KeyNotFoundException) { success = false; stackframe.throwAneException(token,functionDefine.signature.parameters[0].type + "没有链接到脚本"); } catch (ArgumentException a) { success = false; stackframe.throwAneException(token,a.Message); } catch (IndexOutOfRangeException i) { success = false; stackframe.throwAneException(token,i.Message); } }
/// <summary> /// 将字符串按照指定长度截取并转存为字符数组,空格忽略 /// </summary> /// <param name="strValue"></param> /// <param name="nLength"></param> /// <returns></returns> public static string[] StringToStringArray(string strValue, int nLength) { string[] strAryResult = null; if (!string.IsNullOrEmpty(strValue)) { System.Collections.ArrayList strListResult = new System.Collections.ArrayList(); string strTemp = string.Empty; int nTemp = 0; for (int nloop = 0; nloop < strValue.Length; nloop++) { if (strValue[nloop] == ' ') { continue; } else { nTemp++; //校验截取的字符是否在A~F、0~9区间,不在则直接退出 System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^(([A-F])*(\d)*)$"); if (!reg.IsMatch(strValue.Substring(nloop, 1))) { return(strAryResult); } strTemp += strValue.Substring(nloop, 1); //判断是否到达截取长度 if ((nTemp == nLength) || (nloop == strValue.Length - 1 && !string.IsNullOrEmpty(strTemp))) { strListResult.Add(strTemp); nTemp = 0; strTemp = string.Empty; } } } if (strListResult.Count > 0) { strAryResult = new string[strListResult.Count]; strListResult.CopyTo(strAryResult); } } return(strAryResult); }
/// <summary> /// Returns a list of files in a give directory. /// </summary> /// <param name="fullName">The full path name to the directory.</param> /// <param name="indexFileNameFilter"></param> /// <returns>An array containing the files.</returns> public static System.String[] GetLuceneIndexFiles(System.String fullName, Index.IndexFileNameFilter indexFileNameFilter) { System.IO.DirectoryInfo dInfo = new System.IO.DirectoryInfo(fullName); System.Collections.ArrayList list = new System.Collections.ArrayList(); foreach (System.IO.FileInfo fInfo in dInfo.GetFiles()) { if (indexFileNameFilter.Accept(fInfo, fInfo.Name) == true) { list.Add(fInfo.Name); } } System.String[] retFiles = new System.String[list.Count]; list.CopyTo(retFiles); return(retFiles); }
static public int CopyTo__Int32__Array__Int32__Int32(IntPtr l) { try { System.Collections.ArrayList self = (System.Collections.ArrayList)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); System.Array a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); self.CopyTo(a1, a2, a3, a4); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static int CopyTo(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(System.Collections.ArrayList), typeof(System.Array))) { System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.ToObject(L, 1); System.Array arg0 = (System.Array)ToLua.ToObject(L, 2); obj.CopyTo(arg0); return(0); } else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(System.Collections.ArrayList), typeof(System.Array), typeof(int))) { System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.ToObject(L, 1); System.Array arg0 = (System.Array)ToLua.ToObject(L, 2); int arg1 = (int)LuaDLL.lua_tonumber(L, 3); obj.CopyTo(arg0, arg1); return(0); } else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(System.Collections.ArrayList), typeof(int), typeof(System.Array), typeof(int), typeof(int))) { System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.ToObject(L, 1); int arg0 = (int)LuaDLL.lua_tonumber(L, 2); System.Array arg1 = (System.Array)ToLua.ToObject(L, 3); int arg2 = (int)LuaDLL.lua_tonumber(L, 4); int arg3 = (int)LuaDLL.lua_tonumber(L, 5); obj.CopyTo(arg0, arg1, arg2, arg3); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.Collections.ArrayList.CopyTo")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int CopyTo(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2) { System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.CheckObject <System.Collections.ArrayList>(L, 1); System.Array arg0 = (System.Array)ToLua.CheckObject <System.Array>(L, 2); obj.CopyTo(arg0); return(0); } else if (count == 3) { System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.CheckObject <System.Collections.ArrayList>(L, 1); System.Array arg0 = (System.Array)ToLua.CheckObject <System.Array>(L, 2); int arg1 = (int)LuaDLL.luaL_checknumber(L, 3); obj.CopyTo(arg0, arg1); return(0); } else if (count == 5) { System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.CheckObject <System.Collections.ArrayList>(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); System.Array arg1 = (System.Array)ToLua.CheckObject <System.Array>(L, 3); int arg2 = (int)LuaDLL.luaL_checknumber(L, 4); int arg3 = (int)LuaDLL.luaL_checknumber(L, 5); obj.CopyTo(arg0, arg1, arg2, arg3); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.Collections.ArrayList.CopyTo")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void CopyTo(Array array, int index) { m_Entries.CopyTo(array, index); }
// Implement the ICollection interface. void ICollection.CopyTo(Array array, int index) { list.CopyTo(array, index); }
private decimal evalExternalFunctionCall(String funcName, String expr) { Tokenizer paramTokenizer = new Tokenizer(expr, ",", true); System.Collections.ArrayList functionParms = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); while (paramTokenizer.HasMoreTokens()) { String arg = getNextToken(paramTokenizer).Trim(); if ((arg.StartsWith("\"") || arg.StartsWith("'")) && (arg.EndsWith("\"") || arg.EndsWith("'"))) { // it is a string functionParms.Add(arg.Substring(1, (arg.Length - 1) - (1))); } else { // evaluate the parameter EvalValue eValue = eval(arg); // The corresponding type of parameter is passed if (eValue.S == null) { functionParms.Add(eValue.D); } else { functionParms.Add(eValue.S); } } if (paramTokenizer.HasMoreTokens()) { // Consume the ',' paramTokenizer.NextToken(); } } functionParms.Add((decimal)0); System.Object[] callParms = new System.Object[functionParms.Count]; functionParms.CopyTo(callParms); bool pAdded = false; try { funcName = funcName.ToLower(); DynamicExecute(funcName, callParms); } catch (System.Exception e) { bool retrySuccessful = false; if (!pAdded && e.ToString().IndexOf("ClassNotFoundException") != -1) { try { DynamicExecute("p" + funcName, callParms); retrySuccessful = true; } catch (System.Exception) { } } if (!retrySuccessful) { return(throwException(EXTERNAL_FUNCTION_ERROR, e.Message)); } } return(Convert.ToDecimal(callParms[callParms.Length - 1], System.Globalization.CultureInfo.InvariantCulture)); }