public static ArrayList generaCamposRelacion(ArrayList tabSelec, ArrayList alias, ArrayList camposRel) { ArrayList resp = new ArrayList(); if (camposRel != null) { foreach (ArrayList regCam in camposRel) { string nombreTabB = (string)regCam[2]; string nombreTabR = (string)regCam[3]; string nombreCampoTB = (string)regCam[4]; string nombreCampoTR = (string)regCam[5]; int indexTB = tabSelec.IndexOf(nombreTabB); int indexTR = tabSelec.IndexOf(nombreTabR); string aliasTB = (string)alias[indexTB]; string aliasTR = (string)alias[indexTR]; resp.Add(aliasTB + "." + nombreCampoTB + " = " + aliasTR + "." + nombreCampoTR); } } return resp; }
private void HighlightNext() { // Find next. int next = m_userDefinedCharacters.IndexOf(m_highlighted) + 1; next = next % m_userDefinedCharacters.Count; // Cast from Object to CustomCharacter UpdateHighlighted((CharLCDmp_v1_00.CyCustomCharacter)m_userDefinedCharacters[next]); }
public static void SwapPosition(ArrayList lista, Object node1, Object node2) { int exp1idx = lista.IndexOf(node1); int exp2idx = lista.IndexOf(node2); lista.RemoveAt(exp1idx); lista.Insert(exp1idx, node2); lista.RemoveAt(exp2idx); lista.Insert(exp2idx, node1); }
public static HashSet<float[]> Consolidate(ArrayList al, int w, int h, TextWriter log) { ArrayList al2 = new ArrayList(); foreach (float[] i in al) { al2.Add(i); } foreach (float[] i in al) { foreach (float[] j in al) { if (!((Math.Abs(i[0] - j[0]) > w) || (Math.Abs(i[1] - j[1]) > h) || (Math.Sqrt(Math.Pow(i[0] - j[0], 2) + Math.Pow(i[1] - j[1], 2)) > Math.Sqrt(Math.Pow(w, 2) + Math.Pow(h, 2))))) { if (i[2] > j[2]) { al2[al.IndexOf(j)] = i; } else if (i[2] < j[2]) { al2[al.IndexOf(i)] = j; } } } } HashSet<float[]> hash = new HashSet<float[]>(); foreach (float[] i in al2) { hash.Add(i); } log.WriteLine("The count of al2: " + al2.Count); log.WriteLine("The count of hash: " + hash.Count); al.Clear(); foreach (float[] i in hash) { al.Add(i); } log.WriteLine("The count after hash: " + al.Count); return hash; }
private void frmMessageNotify_Closed(object sender, System.EventArgs e) { if (this.Visible) { System.Threading.Interlocked.Decrement(ref s_intInstance); int intIndex = s_arlForms.IndexOf(this); s_arlForms.Remove(this); for (int i = intIndex; i < s_arlForms.Count; i++) { frmMessageNotify frmTemp = ((frmMessageNotify)s_arlForms[i]); frmTemp.Location = new Point(frmTemp.Location.X, frmTemp.Location.Y + this.Height); } ; } }
/// <summary> /// kozos inicializalas /// </summary> /// <param name="valtpanelek"> /// valtozaspanelek tombje /// </param> /// <param name="szulopanelek"> /// szulopanelek tombje /// </param> /// <param name="sajatpanelek"> /// alap panelek tombje vagy null /// </param> public void ValtszulopluszSzuloInit(Panel[] valtpanelek, Panel[] szulopanelek, Panel[] sajatpanelek) { object[] alap = null; if (sajatpanelek != null) alap = new object[] { Alapinfotipus.Alap, sajatpanelek }; object[] valt = null; object[] szulogy=null; Panel[] panelek = new Panel[] { panel1, panel2, panel4, panel5 ,panel11}; ArrayList eredetiar = new ArrayList(panelek); ArrayList ar = new ArrayList(valtpanelek); bool[] van = new bool[5]; for (int i = 0; i < van.Length; i++) { Panel eredeti = (Panel)eredetiar[i]; if (ar.IndexOf(eredeti) != -1) van[i] = true; } for (int i = 0; i < van.Length; i++) { if (!van[i]) this.Controls.Remove((Control)eredetiar[i]); } if (valtpanelek != null) { valt = new object[] { Alapinfotipus.Valtozasok, valtpanelek }; } if(szulopanelek!=null) szulogy = new object[] { Alapinfotipus.SzuloGyerekValtozasok, szulopanelek }; if (alap == null) AlapinfoInit(new object[] { valt, szulogy }); else AlapinfoInit(new object[] { alap, valt, szulogy }); }
private void ClickedAHole(object sender, System.EventArgs e) { try { int holeIdx = holes.IndexOf(sender); if (pegToMove == -1) { pegToMove = holeIdx; } else { if (pegToMove != holeIdx) { pegDestination = holeIdx; theGame.Move(pegToMove, pegDestination); if (theGame.GameOver) { setTheBoard(); MessageBox.Show("there are no moves left"); } //MessageBox.Show(String.Format("The Best Possible Score is {0}",gameDomain.BestPossibleScore(theGame.Signature))); } pegToMove = -1; pegDestination = -1; } setTheBoard(); } catch (Exception except) { pegToMove = -1; pegDestination = -1; MessageBox.Show(except.Message); } }
public override bool OnInsertFile(ManagerEngine man, IFile file) { HttpResponse response = HttpContext.Current.Response; HttpRequest request = HttpContext.Current.Request; HttpCookie cookie; ArrayList chunks; if ((cookie = request.Cookies["hist"]) == null) cookie = new HttpCookie("hist"); cookie.Expires = DateTime.Now.AddDays(30); if (cookie.Value != null) { chunks = new ArrayList(cookie.Value.Split(new char[]{','})); if (chunks.IndexOf(man.EncryptPath(file.AbsolutePath)) == -1) chunks.Add(man.EncryptPath(file.AbsolutePath)); cookie.Value = this.Implode(chunks, ","); } else cookie.Value = man.EncryptPath(file.AbsolutePath); response.Cookies.Remove("hist"); response.Cookies.Add(cookie); return true; }
//输入必经点集合 public ArrayList getPath(ArrayList pointList, int[,] A, int n,int start) { int[,] dist = run(A,n); bool[] flag = new bool[n + 1]; for (int i = 0; i <= n;i++ ) { flag[i] = false; } ArrayList list = new ArrayList(); list.Add(start); int reachPoint = start; for (int i = 0; i < pointList.Count; i++) { int min = MAXINT; for (int j = 1; j <= n; j++) { if ((dist[reachPoint, j] < min) && (pointList.IndexOf(j)!=-1) && (!flag[j])) { min = dist[reachPoint,j]; reachPoint = j; flag[j] = true; list.Add(j); } } } return list; }
public void fun1() { ArrayList a1 = new ArrayList(); a1.Add(1); a1.Add('c'); a1.Add("string1"); ArrayList al2 = new ArrayList(); al2.Add('a'); al2.Add(5); int n = (int)a1[0]; Console.WriteLine(n); a1[0] = 20; Console.WriteLine(a1.Count); Console.WriteLine(a1.Contains(55)); Console.WriteLine(a1.IndexOf(55)); //int[] num = (int[])a1.ToArray(); a1.Add(45); a1.Add(12); a1.Add(67); a1.Insert(1, "new value"); //a1.AddRange(al2); a1.InsertRange(1, al2); a1.Remove("string1"); a1.RemoveAt(2); a1.RemoveRange(0, 2); foreach (object o in a1) { Console.WriteLine(o.ToString()); } }
/// <summary> /// 获取Excel文件数据表列表 /// </summary> public static ArrayList GetExcelTables(string ExcelFileName) { DataTable dt = new DataTable(); ArrayList TablesList = new ArrayList(); if (File.Exists(ExcelFileName)) { using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" + ExcelFileName)) { try { conn.Open(); dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); } catch (Exception exp) { throw exp; } //获取数据表个数 int tablecount = dt.Rows.Count; for (int i = 0; i < tablecount; i++) { string tablename = dt.Rows[i][2].ToString().Trim().TrimEnd('$'); if (TablesList.IndexOf(tablename) < 0) { TablesList.Add(tablename); } } } } return TablesList; }
private int CycleDigits( int number ) { var diffList = new ArrayList(); var diff = 10; while (true) { if (diff % number != diff) { diff = diff % number; if (diff == 0) { return 0; } if (diffList.Contains(diff)) { return diffList.Count - diffList.IndexOf(diff); } diffList.Add(diff); diff = diff * 10; } else { diff = diff * 10; } } }
protected void Page_Load(object sender, System.EventArgs e) { try { if(Page.IsPostBack && Request["_BIP_ACTION"] == "AddRelatedDoc" ) { ArrayList docEnum = new ArrayList(); if(m_Document.RefDocuments != null) { foreach(int ids in m_Document.RefDocuments) docEnum.Add(ids); } int id = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]); if(Request["_BIP_ACTION"] == "AddRelatedDoc") { if(docEnum.IndexOf(id) == -1) docEnum.Add(id); } m_Document.RefDocuments = docEnum; m_Document.Update(); } ddlDocLinks.Items.Clear(); System.Collections.ArrayList docList = new System.Collections.ArrayList(); if(m_Document.ParentId >0) docList.Add(m_Document.ParentId); if(m_Document.PreviousVersionId >0) docList.Add(m_Document.PreviousVersionId); foreach(object obj in m_Document.RefDocuments) docList.Add(obj); DataTable tab =DocumentEnt.FindEnum(docList); if(tab != null) { ddlDocLinks.DataSource = tab; ddlDocLinks.DataValueField = "Id"; ddlDocLinks.DataTextField = "Header"; ddlDocLinks.DataBind(); tab.Dispose(); } ddlDocLinks.Items.Insert(0, new ListItem("<" + Bip.Components.BipResources.GetString("StrRelatedDocuments") + ">", "0")); PanAddDocLink.Visible = m_Document.CanEdit; if(m_Document.CanEdit || tab != null) PanOpenRefDocuments.Visible = true; else PanOpenRefDocuments.Visible = false; } catch(Exception ex) { ProcessException(ex); } }
internal static int fastRemove(ArrayList a, object o) { int num1 = -1; int num2 = a.Count; if (num2 > 1000) { num1 = a.IndexOf(o, num2 - 50, 50); } if (num1 < 0) { num1 = a.IndexOf(o); } if (num1 >= 0) { a.RemoveAt(num1); } return num1; }
// Helper Method protected bool haveSameStringsAtSameIndex(ArrayList list1, ArrayList list2) { bool haveSameElements = list1.Count == list2.Count; for (int i = 0; i < list1.Count; ++i) { bool sameItemAtIndexI = list1.IndexOf(i) == list2.IndexOf(i); haveSameElements = haveSameElements && sameItemAtIndexI; } return haveSameElements; }
private bool m_mthUnSelect(string strID, string strrow) { bool ret = false; if (objArr.IndexOf(strID + strrow.Trim().PadLeft(5, '0')) < 0) { ret = true; } return(ret); }
public ArrayList getCollectIdList(DataSet ds) { ArrayList CollectIdList = new ArrayList(); foreach (DataRow row in ds.Tables[0].Rows) { if (CollectIdList.IndexOf(row["CollectId"].ToString()) == -1) CollectIdList.Add(row["CollectId"].ToString()); } return CollectIdList; }
public string pathCreationDeletion(ArrayList argumentList, int Index, string argument, string path) { #region Creates and removes the file paths for the log and dictionary files Index = argumentList.IndexOf(argument) + 1; // Finds the index of either -f or -l and takes whatever is ahead of it as the new file/log path path = argumentList[Index].ToString(); argumentList.RemoveAt(Index); // Removes the file/log path arguments to not mess up the query and update commands later argumentList.RemoveAt(argumentList.IndexOf(argument)); return path; #endregion }
static void Main(string[] args) { // Array Console.WriteLine("Create an Array type collection of Animal objects and use it:"); Animal[] animalArray = new Animal[2]; // Strongly typed Cow myCow1 = new Cow("Deirdre"); animalArray[0] = myCow1; animalArray[1] = new Chicken("Ken"); foreach (Animal myAnimal in animalArray) { Console.WriteLine("New {0} object added to Array collection, " + "Name = {1}", myAnimal.ToString(), myAnimal.Name); } Console.WriteLine("Array collection {0} objects.", animalArray.Length); animalArray[0].Feed(); // invoke Animal method directly ((Chicken)animalArray[1]).LayEgg(); // cast to Chicken to invoke subclass method Console.WriteLine(); // ArrayList Console.WriteLine("Create an ArrayList type collection of Animal " + "objects and se it:"); ArrayList animalArrayList = new ArrayList(); // A collection of System.Objects Cow myCow2 = new Cow("Hayley"); animalArrayList.Add(myCow2); animalArrayList.Add(new Chicken("Row")); foreach (Animal myAnimal in animalArrayList) { Console.WriteLine("New {0} object added to ArrayList collection," + " Name = {1}", myAnimal.ToString(), myAnimal.Name); } Console.WriteLine("ArrayList collection contains {0} objects.", animalArrayList.Count); ((Animal)animalArrayList[0]).Feed(); // cast to Animal ((Chicken)animalArrayList[1]).LayEgg(); // cast to Chicken to invoke subclass method Console.WriteLine(); // Additional ArrayList manipulation Console.WriteLine("Additional manipulation of ArrayList:"); animalArrayList.RemoveAt(0); ((Animal)animalArrayList[0]).Feed(); animalArrayList.AddRange(animalArray); ((Chicken)animalArrayList[2]).LayEgg(); Console.WriteLine("The animal called {0} is at index {1}.", myCow1.Name, animalArrayList.IndexOf(myCow1)); myCow1.Name = "Janice"; Console.WriteLine("The animal is now called {0}.", ((Animal)animalArrayList[1]).Name); Console.ReadKey(); }
public static bool CreateExcelFile(string excelFile, string sheetName, DataTable frTable, ArrayList columnList, ArrayList headerList) { string SQLCmd = ""; OleDbConnection oleDbConn = OpenConnection(excelFile); if (oleDbConn == null) return false; try { string columName; int columnNo; for (int idx = 0; idx < frTable.Columns.Count; idx++) { if (columnList != null) { columnNo = columnList.IndexOf(frTable.Columns[idx].ColumnName.ToUpper()); if (columnNo < 0) continue; columName = headerList[columnNo].ToString(); } else columName = frTable.Columns[idx].ColumnName.ToString(); SQLCmd += (SQLCmd == "" ? "" : ",") + "[" + columName + "]"; switch (frTable.Columns[idx].DataType.ToString().Trim()) { case "System.Double": case "System.Decimal": case "System.Int64": SQLCmd = " double"; break; case "System.DateTime": SQLCmd = " date "; break; case "System.Boolean": SQLCmd += " bit"; break; default: SQLCmd += " string"; break; } } SQLCmd = "CREATE TABLE [" + sheetName + "] (" + SQLCmd + ");"; OleDbCommand oleDbComm = new OleDbCommand(SQLCmd, oleDbConn); oleDbComm.ExecuteNonQuery(); oleDbConn.Close(); return true; } catch (Exception er) { lastErrorMessage = er.Message.ToString(); } finally { if (oleDbConn != null && oleDbConn.State == ConnectionState.Open) oleDbConn.Close(); } return false; }
/// <summary> /// Remove a drawable object. /// Note that axes are not updated. /// </summary> /// <param name="p">Drawable to remove.</param> /// <param name="updateAxes">if true, the axes are updated.</param> public void Remove(IDrawable p, bool updateAxes) { int index = drawables_.IndexOf(p); if (index < 0) { return; } drawables_.RemoveAt(index); xAxisPositions_.RemoveAt(index); yAxisPositions_.RemoveAt(index); zPositions_.RemoveAt(index); if (updateAxes) { UpdateAxes(true); } RefreshZOrdering(); }
private static void DisplayInformation(ArrayList arrayList) { foreach (var element in arrayList) Console.Write(element + " "); Console.WriteLine("\n Size = " + arrayList.Count + "; Capacity = " + arrayList.Capacity); int index = arrayList.IndexOf("BLUE"); if (index != -1) Console.WriteLine("The arraylist contains Blue at index " + index); else Console.WriteLine("The arraylist does not contain Blue"); }
public int CheckForUpdate(string serverXmlFile, string localXmlFile, out Hashtable updateFileList) { updateFileList = new Hashtable(); if (!File.Exists(localXmlFile) || !File.Exists(serverXmlFile)) { return -1; } XmlFiles serverXmlFiles = new XmlFiles(serverXmlFile); XmlFiles localXmlFiles = new XmlFiles(localXmlFile); XmlNodeList newNodeList = serverXmlFiles.GetNodeList("AutoUpdater/Files"); XmlNodeList oldNodeList = localXmlFiles.GetNodeList("AutoUpdater/Files");//5+1+a+s+p+x int k = 0; for (int i = 0; i < newNodeList.Count; i++) { string[] fileList = new string[3]; string newFileName = newNodeList.Item(i).Attributes["Name"].Value.Trim(); string newVer = newNodeList.Item(i).Attributes["Ver"].Value.Trim(); ArrayList oldFileAl = new ArrayList(); for (int j = 0; j < oldNodeList.Count; j++) { string oldFileName = oldNodeList.Item(j).Attributes["Name"].Value.Trim(); string oldVer = oldNodeList.Item(j).Attributes["Ver"].Value.Trim(); oldFileAl.Add(oldFileName); oldFileAl.Add(oldVer); } int pos = oldFileAl.IndexOf(newFileName); if (pos == -1) { fileList[0] = newFileName; fileList[1] = newVer; updateFileList.Add(k, fileList); k++; } else if (pos > -1 && newVer.CompareTo(oldFileAl[pos + 1].ToString()) > 0) { fileList[0] = newFileName; fileList[1] = newVer; updateFileList.Add(k, fileList); k++; } } return k; }
static void Main(string[] args) { Console.WriteLine ("Create an Array type collection of Animal " + "objects and use it:"); // Создание коллекции типа Array из объектов // Animal и ее использование Animal[] animalArray = new Animal[2]; Cow myCow1 = new Cow("Deirdre"); animalArray[0] = myCow1; animalArray[1] = new Chicken ("Ken") ; foreach (Animal myAnimal in animalArray) { Console.WriteLine("New {0} object added to Array collection, " + "Name = {1}", myAnimal.ToString() , myAnimal.Name) ; // В коллекцию Array добавлен новый объект } Console.WriteLine("Array collection contains {0} objects.", animalArray.Length); // Вывод количества объектов в коллекции Array animalArray[0].Feed(); ((Chicken)animalArray[1]).LayEgg(); Console.WriteLine(); Console.WriteLine("Create an ArrayList type collection of Animal " + "objects and use it:") ; ArrayList animalArrayList = new ArrayList () ; Cow myCow2 = new Cow("Hayley"); animalArrayList.Add(myCow2); animalArrayList.Add(new Chicken ("Roy")); foreach (Animal myAnimal in animalArrayList) { Console.WriteLine ("New {0} object added to ArrayList collection," + " Name = {1}", myAnimal.ToString() , myAnimal.Name) ; } Console.WriteLine("ArrayList collection contains {0} objects.", animalArrayList.Count); ((Animal)animalArrayList[0]).Feed(); ((Chicken)animalArrayList[1]).LayEgg(); Console.WriteLine(); Console. WriteLine ("Additional manipulation of ArrayList:") ; // Дополнительное манипулирование коллекцией ArrayList animalArrayList.RemoveAt(0); ((Animal)animalArrayList[0]).Feed(); animalArrayList.AddRange(animalArray); ((Chicken)animalArrayList[2]).LayEgg(); Console.WriteLine("The animal called {0} is at index {1}.", myCow1.Name, animalArrayList.IndexOf(myCow1)); // Вывод животных и позиций myCow1.Name = "Janice"; Console.WriteLine("The animal is now called {0}.", ((Animal) animalArrayList[1]).Name) ; // Вывод животных Console.ReadKey(); }
public void CanIncludeWithEagerLoading() { var myarray = new ArrayList(); using (var db = new mybooksEntities()) { var author = db.myauthors.Include("mybooks.myeditions").AsEnumerable().First(); var strquery = ((ObjectQuery)db.myauthors.Include("mybooks.myeditions").AsEnumerable()).ToTraceString(); CheckSql(strquery, SQLSyntax.JoinUsingInclude); foreach (var book in author.mybooks.ToList()) { foreach (var edition in book.myeditions.ToList()) { myarray.Add(edition.Title); } } myarray.Sort(); Assert.AreEqual(0, myarray.IndexOf("Another Book First Edition")); Assert.AreEqual(1, myarray.IndexOf("Another Book Second Edition")); Assert.AreEqual(2, myarray.IndexOf("Another Book Third Edition")); Assert.AreEqual(3, myarray.IndexOf("Some Book First Edition")); Assert.AreEqual(myarray.Count, 4); } }
private void ClearDefaultsInSection(string section) { if (clearedCohorts.IndexOf(section) > -1) { return; } System.Web.UI.HtmlControls.HtmlGenericControl attachSect = (HtmlGenericControl)FindControlRecursive(attachments, section); if (attachSect != null) { attachSect.Controls.Clear(); clearedCohorts.Add(section); } }
/// <summary> /// Returns the file info string which will be used for the package /// </summary> public String CreateFileInfo() { String Info = ""; foreach (String FilePath in FileList) { Info += Convert.ToString(FileNames[FileList.IndexOf(FilePath)]) + ";" + (new System.IO.FileInfo(FilePath).Length) + "|"; } if (Info.EndsWith("|")) { Info = Info.Substring(0, Info.Length - 1); } return(Info); }
public static ArrayList buildSynonymsList(string p_dir, OracleConnection conn) { Console.WriteLine("Processing scripts ... {0}", p_dir); // First read all files from the file system string configSqlFileList = Settings.getSqlFileList(true); string configIgnoreDirList = Settings.getIgnoreDirList(true); string configIgnoreFileList = Settings.getIgnoreFileList(true); Log.Info("grants", "Searching for sql scripts"); string[] files = FolderSearch.Search(p_dir, true, configSqlFileList, configIgnoreDirList, configIgnoreFileList); ArrayList fileList = new ArrayList(); // each file can contain 0 or more blocks foreach (string filename in files) { ArrayList sqlCommandList = new ArrayList(SqlScript.Load(filename)); foreach (SqlObject sqlCommand in sqlCommandList) { if (sqlCommand.commandType == "SQL" && sqlCommand.objectType == "SYNONYM") fileList.Add(parseSynonymSql(sqlCommand.sqlText, filename)); } } // TODO: Check for duplicate synonyms Console.WriteLine("Processing database catalog ..."); // Read all entries from user_tab_privs_made string cmdQuery = "select user, synonym_name, table_owner||'.'||table_name||nvl2(db_link,'@','')||db_link targetName from user_synonyms"; OracleCommand cmd = new OracleCommand(cmdQuery, conn); OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { SynonymObject currObject = new SynonymObject(reader.GetString(0), reader.GetString(1), reader.GetString(2), false); int existingObjectIndex = fileList.IndexOf(currObject); // This object does not exist in arrayList if (existingObjectIndex == -1) fileList.Add(currObject); // because of duplicates loop through all occurences while (existingObjectIndex >= 0) { SynonymObject existingFileItem = (SynonymObject)fileList[existingObjectIndex]; existingFileItem.existsInSchema = true; existingObjectIndex = fileList.IndexOf(currObject, existingObjectIndex + 1); } } return fileList; }
static void Main(string[] args) { ArrayList myArrayList = new ArrayList(); myArrayList.Add(1); myArrayList.Add("SEIP"); myArrayList.Add(12.5); Console.WriteLine(myArrayList.IndexOf("SEIP"));//to see index number Console.WriteLine(myArrayList[1]); foreach (var VARIABLE in myArrayList) { Console.WriteLine(VARIABLE); } Console.ReadKey(); }
static public int IndexOf__Object(IntPtr l) { try { System.Collections.ArrayList self = (System.Collections.ArrayList)checkSelf(l); System.Object a1; checkType(l, 2, out a1); var ret = self.IndexOf(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
/// <summary> /// 30进制转10进制 /// </summary> /// <param name="num"></param> /// <returns></returns> public static Int64 ThirtyToDecimal(string num_str) { ArrayList ar = new ArrayList(key); Int64 k; Int64 num = 0; for (int i = 0; i < num_str.Length; i++) { k = ar.IndexOf(num_str[i].ToString()); if (k < 0) throw new Exception("有非法数据!"); k *= (Int64)Math.Pow(30, num_str.Length - i - 1); num += k; } return num; }
static public int IndexOf(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 2) { System.Collections.ArrayList self = (System.Collections.ArrayList)checkSelf(l); System.Object a1; checkType(l, 2, out a1); var ret = self.IndexOf(a1); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 3) { System.Collections.ArrayList self = (System.Collections.ArrayList)checkSelf(l); System.Object a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); var ret = self.IndexOf(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 4) { System.Collections.ArrayList self = (System.Collections.ArrayList)checkSelf(l); System.Object a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); var ret = self.IndexOf(a1, a2, a3); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
//�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ����Ӻ��� public void LinkFolder(string inputPath, FileInfo[] classList, string targetPath, string[] exCludePath, string[] exCludeFile) { if (Directory.Exists(inputPath)) { DirectoryInfo folder = new DirectoryInfo(inputPath); FileInfo[] list = folder.GetFiles("*.as", SearchOption.AllDirectories); int linkCount = list.Length; int exCludeCount = 0; ArrayList exCludeList = new ArrayList(); for (int i = 0; i < list.Length; i++) { FileInfo obFile = list[i]; bool allowLink = true; for (int j = 0; j < exCludeFile.Length; j++) { string fileName = obFile.FullName; if (fileName.Equals(exCludeFile[j], StringComparison.InvariantCultureIgnoreCase)) { allowLink = false; linkCount--; exCludeCount++; exCludeList.Add(fileName); } } for (int j = 0; j < exCludePath.Length; j++) { string folderName = obFile.DirectoryName; if (folderName.Equals(exCludePath[j], StringComparison.InvariantCultureIgnoreCase)) { allowLink = false; linkCount--; exCludeCount++; if (exCludeList.IndexOf(folderName) < 0) { exCludeList.Add(folderName); } } } if (allowLink) { LinkFile(obFile.FullName, classList, targetPath, true); } } string info = string.Join("\r\n", exCludeList.ToArray(typeof(string)) as string[]); string countInfo = linkCount.ToString() + " + " + exCludeCount.ToString() + " = " + list.Length.ToString(); ErrorBox.Show(countInfo + " \r\n" + info, "BatchClassLinkerError"); } }
/// <summary> /// inicializalas, ha Alap tipusunk is van /// </summary> /// <param name="valtpanelek"> /// a panelek tombje /// </param> /// <param name="sajatpanelek"> /// Alap tipusu panelek tombje vagy null /// </param> public virtual void ValtozasokInit(Panel[] valtpanelek, Panel[] sajatpanelek) { object[] alap = null; if (sajatpanelek != null) alap = new object[] { Alapinfotipus.Alap, sajatpanelek }; object[] valt = new object[] { Alapinfotipus.Valtozasok, valtpanelek }; Panel[] panelek = new Panel[]{panel1,panel2,panel3,panel4,panel5}; ArrayList eredetiar = new ArrayList(panelek); ArrayList ar = new ArrayList(valtpanelek); bool[] van = new bool[5]; for (int i = 0; i < van.Length; i++) { Panel eredeti = (Panel)eredetiar[i]; if (ar.IndexOf(eredeti) != -1) van[i] = true; } for (int i = 0; i < van.Length; i++) { if (!van[i]) this.Controls.Remove((Control)eredetiar[i]); } //switch (valtpanelek.Length) //{ // case 1: // this.Controls.Remove(panel2); // this.Controls.Remove(panel3); // this.Controls.Remove(panel4); // this.Controls.Remove(panel5); // break; // case 2: // this.Controls.Remove(panel3); // this.Controls.Remove(panel4); // this.Controls.Remove(panel5); // break; // case 3: // this.Controls.Remove(panel4); // this.Controls.Remove(panel5); // break; // case 4: // this.Controls.Remove(panel5); // break; //} if (alap == null) AlapinfoInit(new object[] { valt }); else AlapinfoInit(new object[] { alap, valt }); }
protected void btnPermisos_Click(object sender, System.EventArgs e) { if (Page.IsPostBack) { for (int i = 0; i < Page.Request.Form.Keys.Count; i++) { string control = Page.Request.Form.Keys[i].ToString(); if (control.Contains("|")) { char[] chArr1 = new char[] { '|' }; char[] chArr2 = new char[] { '$' }; char[] chArr3 = new char[] { '|' }; char[] chArr4 = new char[] { '$' }; string username = control.Split(chArr1)[0].Split(chArr2)[control.Split(chArr3)[0].Split(chArr4).Length - 1].Trim(); char[] chArr5 = new char[] { '|' }; char[] chArr6 = new char[] { '|' }; string seccion = control.Split(chArr5)[control.Split(chArr6).Length - 1].Trim(); int i1 = arrPermisos.IndexOf(Page.Request.Form[control].ToString()) + 1; string nivel = i1.ToString(); string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["BaseSqlServer"].ConnectionString; System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString); try { string strQuery = "UPDATE [matricula].[SGPermisos] SET " + seccion + " = '" + nivel + "' WHERE usuario = '" + username + "';"; System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(strQuery, connection); connection.Open(); cmd.ExecuteNonQuery(); connection.Close(); } catch (System.Exception e1) { System.Console.WriteLine("Ocurri\u00F3 un error al intentar actualizar el permiso (" + seccion + ":" + Page.Request.Form[control].ToString() + ") del usuario " + username + ". " + e1.Message); } finally { if (connection != null) { connection.Dispose(); } } } } } cargarPermisos(); }
private static string[] GetPinyins(Char c) { System.Collections.ArrayList alPinyin = new System.Collections.ArrayList(); alPinyin.Add(c.ToString()); ChineseChar x = new ChineseChar(c); foreach (string s in x.Pinyins) { if (s != null) { string py = s.Substring(0, s.Length - 1); if (alPinyin.IndexOf(py) == -1) { alPinyin.Add(py); } } } return((string[])alPinyin.ToArray(typeof(string))); }
static int IndexOf(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(System.Collections.ArrayList), typeof(object))) { System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.ToObject(L, 1); object arg0 = ToLua.ToVarObject(L, 2); int o = obj.IndexOf(arg0); LuaDLL.lua_pushinteger(L, o); return(1); } else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(System.Collections.ArrayList), typeof(object), typeof(int))) { System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.ToObject(L, 1); object arg0 = ToLua.ToVarObject(L, 2); int arg1 = (int)LuaDLL.lua_tonumber(L, 3); int o = obj.IndexOf(arg0, arg1); LuaDLL.lua_pushinteger(L, o); return(1); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(System.Collections.ArrayList), typeof(object), typeof(int), typeof(int))) { System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.ToObject(L, 1); object arg0 = ToLua.ToVarObject(L, 2); int arg1 = (int)LuaDLL.lua_tonumber(L, 3); int arg2 = (int)LuaDLL.lua_tonumber(L, 4); int o = obj.IndexOf(arg0, arg1, arg2); LuaDLL.lua_pushinteger(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.Collections.ArrayList.IndexOf")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static void Main(string[] args) { Console.WriteLine("Создание коллекции типа Array из объектов Animal и её использование."); Animal[] animalArray = new Animal[2]; Cow myCow1 = new Cow("Бурёнка"); animalArray[0] = myCow1; animalArray[1] = new Chicken("Дося"); foreach (var animal in animalArray) { Console.WriteLine("Объект {0} был добавлен в коллекцию Array, " + "Имя = {1}.", animal.ToString(), animal.Name); } Console.WriteLine("Коллекция Array содержит {0} объектов.", animalArray.Length); animalArray[0].Feed(); ((Chicken)animalArray[1]).LayEgg(); Console.WriteLine(); Console.WriteLine("Сщздание коллекции объектов Animal типа Array и её использование."); ArrayList animalArrayList = new ArrayList(); Cow myCow2 = new Cow("Таня"); animalArrayList.Add(myCow2); animalArrayList.Add(new Chicken("Феня")); foreach(Animal myAnimal in animalArrayList) { Console.WriteLine("Объект {0} был добавлен в коллекцию ArrayList, " + " Имя = {1}.", myAnimal.ToString(), myAnimal.Name); } Console.WriteLine("Коллекция ArrayList содержит {0} объктов.", animalArrayList.Count); ((Animal)animalArrayList[0]).Feed(); ((Chicken)animalArrayList[1]).LayEgg(); Console.WriteLine(); Console.WriteLine("Дополнительное манипулирование коллекцией ArrayList:"); animalArrayList.RemoveAt(0); ((Animal)animalArrayList[0]).Feed(); animalArrayList.AddRange(animalArray); ((Chicken)animalArrayList[2]).LayEgg(); Console.WriteLine("Животное по имени {0} находится под индексом {1}.", myCow1.Name, animalArrayList.IndexOf(myCow1)); myCow1.Name = "Джанис"; Console.WriteLine("Животное теперь зовут {0}!", ((Animal)animalArrayList[1]).Name); Console.ReadKey(); }
//Main_7_9_2 public static void Main_7_9_2() { //���弯������ ArrayList arrs = new ArrayList(); //����Add���������Ӽ���Ԫ�� arrs.Add(10); arrs.Add(new object()); arrs.Add("I'm OK."); arrs.Add(new MyClass()); arrs.Add(100); //����Remove�������Ƴ�ָ������ arrs.Remove(100); //����Insert�������������ָ������λ�� arrs.Insert(2, "A insert value"); //IndexOf���������ڴ���ʼλ�������������ص�һ��ƥ���������λ�� Int32 index = arrs.IndexOf("I'm OK."); //��ȡ���ϵ�ָ��Ԫ�� object obj = arrs[index]; Console.WriteLine("{0} -- {1}", obj, index); //��ȡ���ϵ�Ԫ�ظ��� Console.WriteLine(arrs.Count); //ͨ��ö������������Ԫ�� IEnumerator myEnumerator = arrs.GetEnumerator(); while (myEnumerator.MoveNext()) { Console.WriteLine(myEnumerator.Current); } //����ӵķ�ʽ����Ϊ foreach (object o in arrs) { Console.WriteLine(o.ToString()); } //������ϵ�����Ԫ�� arrs.Clear(); }
/// <summary> /// Converts Bitmap images to XPM data for use with ScintillaNet. /// Warning: images with more than (around) 50 colors will generate incorrect XPM /// tColor: specified transparent color in format: "#00FF00". /// </summary> static public string ConvertToXPM(Bitmap bmp, string tColor) { StringBuilder sb = new StringBuilder(); ArrayList colors = new ArrayList(); ArrayList chars = new ArrayList(); OctreeQuantizer quantizer = new OctreeQuantizer(50, 8, ColorTranslator.FromHtml(tColor)); Bitmap reducedBmp = quantizer.Quantize(bmp); int width = reducedBmp.Width; int height = reducedBmp.Height; int index; sb.Append("/* XPM */static char * xmp_data[] = {\"").Append(width).Append(" ").Append(height).Append(" ? 1\""); int colorsIndex = sb.Length; string col; char c; for (int y = 0; y<height; y++) { sb.Append(",\""); for (int x = 0; x<width; x++) { col = ColorTranslator.ToHtml(reducedBmp.GetPixel(x,y)); index = colors.IndexOf(col); if (index < 0) { index = colors.Add(col)+65; if (index > 90) index += 6; c = Encoding.ASCII.GetChars(new byte[]{(byte)(index & 0xff)})[0]; chars.Add(c); sb.Insert(colorsIndex, ",\""+c+" c "+col+"\""); colorsIndex += 14; } else c = (char)chars[index]; sb.Append(c); } sb.Append("\""); } sb.Append("};"); string result = sb.ToString(); int p = result.IndexOf("?"); string finalColor = result.Substring(0, p)+colors.Count+result.Substring(p+1).Replace(tColor.ToUpper(), "None"); return finalColor; }
/// <summary> /// 将Excel文件导出至DataTable(第一行作为表头) /// </summary> /// <param name="ExcelFilePath">Excel文件路径</param> /// <param name="TableName">数据表名,如果数据表名错误,默认为第一个数据表名</param> public static DataTable InputFromExcel(string ExcelFilePath, string TableName) { if (!File.Exists(ExcelFilePath)) { throw new Exception("Excel文件不存在!"); } //如果数据表名不存在,则数据表名为Excel文件的第一个数据表 ArrayList TableList = new ArrayList(); TableList = GetExcelTables(ExcelFilePath); if (TableList.IndexOf(TableName) < 0) { TableName = TableList[0].ToString().Trim(); } DataTable table = new DataTable(); OleDbConnection dbcon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelFilePath + ";Extended Properties=Excel 8.0"); OleDbCommand cmd = new OleDbCommand("select * from [" + TableName + "$]", dbcon); OleDbDataAdapter adapter = new OleDbDataAdapter(cmd); try { if (dbcon.State == ConnectionState.Closed) { dbcon.Open(); } adapter.Fill(table); } catch (Exception exp) { throw exp; } finally { if (dbcon.State == ConnectionState.Open) { dbcon.Close(); } } return table; }
public Window1(Config appConfig) { InitializeComponent(); configObj = appConfig; dataGrid1.ItemsSource = _configObj.imageLinks; dataGrid2.ItemsSource = _configObj.distributors; ArrayList knownColors = new ArrayList(); foreach (KnownColor col in Enum.GetValues(typeof(KnownColor))) { System.Drawing.Color color = System.Drawing.Color.FromKnownColor(col); if (!color.IsSystemColor) { knownColors.Add(col.ToString()); } } ColorPicker.ItemsSource = knownColors; ColorPicker.SelectedIndex = knownColors.IndexOf(appConfig.contactColor); }
int IList.IndexOf(Object value) { return(list.IndexOf(value)); }
//Valida datos antes de guardar la informacion private void ValidarDatos() { _errores.Clear(); foreach (object obj in _visualizacionesNuevas) { VisualizacionNueva vis = (VisualizacionNueva)obj; string nombre = vis.NombreVisualizacion.Trim(); if (nombre.Equals(string.Empty)) { _errores.Add(new ItemDatasetError("Visualizaciones de Stock", "Descripcion", "El campo nombre visualización no puede estar vacío")); } //Valida la existencia de la nueva visualizacion en la bd. string variable = "Momentos." + this.GetTaskName() + "." + this._processParent.Process.ProcessName + "." + "Validar.Visualizacion"; bool validarExisteVisualizacion = Variables.GetValueBool(variable); //Si es un alta no tiene q haber otra con ese nombre if (validarExisteVisualizacion && vis.Modo == "NEW") { tlg_VisualizacionDeStockDataset DataSetVisualizaciones = mz.erp.businessrules.tlg_VisualizacionDeStock.GetList(); if (DataSetVisualizaciones.Tables[0].Rows.Count > 0) { foreach (tlg_VisualizacionDeStockDataset.tlg_VisualizacionDeStockRow _row in DataSetVisualizaciones.Tables[0].Rows) { if ((string)_row["Descripcion"] == nombre) { _errores.Add(new ItemDatasetError("Visualizaciones de Stock", "Descripcion", "Ya existe otra visualización con ese nombre")); } } } } if (validarExisteVisualizacion && vis.Modo == "MODIF") { tlg_VisualizacionDeStockDataset DataSetVisualizaciones = mz.erp.businessrules.tlg_VisualizacionDeStock.GetList(); if (DataSetVisualizaciones.Tables[0].Rows.Count > 0) { foreach (tlg_VisualizacionDeStockDataset.tlg_VisualizacionDeStockRow _row in DataSetVisualizaciones.Tables[0].Rows) { if ((string)_row["IdVisualizacionDeStock"] != vis.KeyVisualizacion && (string)_row["Descripcion"] == vis.NombreVisualizacion) { _errores.Add(new ItemDatasetError("Visualizaciones de Stock", "Descripcion", "Ya existe otra visualización con ese nombre")); } } } } if (vis.Modo == "ADD") { string descripcionE = vis.DescripcionEstado.Trim(); if (descripcionE.Equals(string.Empty)) { _errores.Add(new ItemDatasetError("Visualizaciones de Stock", "Descripcion", "No se seleccionó el estado a agregar")); } //Me fijo que exista la visualizacion en la bd o que la este creando ahora if (!this.existeNuevaVisualizacion(vis.KeyVisualizacion, _visualizacionesNuevas.IndexOf(vis))) // si no se creo ahora me fijo si esta en la BD { tlg_VisualizacionDeStockDataset.tlg_VisualizacionDeStockRow row = mz.erp.businessrules.tlg_VisualizacionDeStock.GetByPk(vis.KeyVisualizacion); if (row == null) { _errores.Add(new ItemDatasetError("Visualizaciones de Stock", "Descripcion", "La visualización debe ser creada antes de agregarle un estado")); } else //Existe la visualizacion { int pos = vis.KeyEstado.IndexOf("_") + 1; string keyEstado = vis.KeyEstado.Substring(pos); tlg_VisualizacionDeStockDetDataset.tlg_VisualizacionDeStockDetRow rowD = mz.erp.businessrules.tlg_VisualizacionDeStockDet.GetByPk(vis.KeyVisualizacion, keyEstado); if (rowD != null) { _errores.Add(new ItemDatasetError("Visualizaciones de Stock", "Descripcion", "El estado ya existe en esa visualización")); } } } } } }
public int IndexOf(TileListItem value) { // TODO: Add ControlListView.IndexOf implementation return(controlList.IndexOf(value)); }
public int IndexOf(IBrowsableItem item) { return(list.IndexOf(item)); }