static void playWithArrayList() { ArrayList lst = new ArrayList() {1,2,3}; Debug.WriteLine("capacity {0}", lst.Capacity); Debug.WriteLine("count {0}", lst.Count); int a = 0; lst.Add(a = 15); lst.Add(null); lst.Add(new Car("diesel", 150, 200)); lst.Add(10.25f); Debug.WriteLine("capacity {0}", lst.Capacity); Debug.WriteLine("count {0}", lst.Count); lst.Insert(2, "insert"); lst.Add(15); Debug.WriteLine("capacity {0}", lst.Capacity); Debug.WriteLine("count {0}", lst.Count); lst.RemoveAt(1); lst.Add(a); lst.Remove(a); lst.Remove(15); Debug.WriteLine("capacity {0}", lst.Capacity); Debug.WriteLine("count {0}", lst.Count); Console.WriteLine(lst.IndexOf(15)); foreach (Object obj in lst) Console.WriteLine(obj); }
protected void Page_Load(object sender, EventArgs e) { SettingsPropertyCollection profileProperties = ProfileCommon.Properties; string[] settings; ArrayList keys = new ArrayList(); ArrayList alias = new ArrayList(); ArrayList name = new ArrayList(); foreach (SettingsProperty prop in profileProperties) { if (prop.Attributes["CustomProviderData"].ToString() != "None") { settings = prop.Attributes["CustomProviderData"].ToString().Split(';'); name.Add(settings[1] + prop.Name); alias.Add(settings[1] + settings[0]); } } name.Sort(); alias.Sort(); ArrayList name1 = ArrayList.Repeat("", name.Count); foreach (String item in name) name1[name.IndexOf(item)] = item.Substring(1); ArrayList alias1 = ArrayList.Repeat("", alias.Count); foreach (String item in alias) alias1[alias.IndexOf(item)] = item.Substring(1); int n = 0; StringDictionary properties = new StringDictionary(); foreach (string item in name1) { properties[item] = alias1[n].ToString(); n++; } rptProfile.DataSource = properties; rptProfile.DataBind(); }
public static void Main (string[] args) { var al = new ArrayList(); al.Add("zero"); al.Add("one"); al.Add("two"); al.IndexOf("zero"); Console.WriteLine(al.Count); Console.WriteLine(al[0]); Console.WriteLine(al[1]); Console.WriteLine(al[2]); al[1] = "one-updated"; Console.WriteLine(al[1]); // this used to fail }
// Use this for initialization void Start() { //creates an array of an undetermined size and type ArrayList aList = new ArrayList(); //create an array of all objects in the scene Object[] AllObjects = GameObject.FindObjectsOfType(typeof(Object)) as Object[]; //iterate through all objects foreach (Object o in AllObjects) { if (o.GetType() == typeof(GameObject)) { aList.Add(o); } } if (aList.Contains(SpecificObject)) { Debug.Log(aList.IndexOf(SpecificObject)); } if (aList.Contains(gameObject)) { aList.Remove(gameObject); } //initialize the AllGameObjects array AllGameObjects = new GameObject[aList.Count]; //copy the list to the array DistanceComparer dc = new DistanceComparer(); dc.Target = gameObject; aList.Sort(dc); aList.CopyTo(AllGameObjects); ArrayList sorted = new ArrayList(); sorted.AddRange(messyInts); sorted.Sort(); sorted.Reverse(); sorted.CopyTo(messyInts); }
public ArrayList getRouteBFS() { ArrayList path = new ArrayList(); Boolean[] visited = new Boolean[NUM_NODES]; for (int i = 0; i < NUM_NODES; i++) { visited[i] = false; } Queue queue = new Queue(); queue.Enqueue(0); //Add origin int it = 0; while (queue.Count != 0 && it <= LEVELS) { int parent = (int)queue.Dequeue(); path.Add(parent); visited[parent] = true; ArrayList childs = new ArrayList(); for (int i = 0; i < NUM_NODES; i++) { int childPos = i; float childValue = nodeValues[childPos]; if (((nodeEdges[parent, childPos] == INF) && (nodeEdges[childPos, parent] == INF)) || //No edges visited[childPos]) { //If the node isn't visited childValue = INF; } childs.Add(childValue); } ArrayList values = new ArrayList(childs); values.Sort(); float minValue = (float)values[0]; int indexMax = childs.IndexOf(minValue); if ((indexMax != -1) && (minValue < INF)) { queue.Enqueue(indexMax); } it++; } return path; }
public void btn_go_Click(object sender, EventArgs e) { try { string sql = ""; string colno = ""; string menuvalue1 = ""; string item = ""; //for (int i = 0; i < cbl_hostel.Items.Count; i++) //{ // if (cbl_hostel.Items[i].Selected == true) // { // if (menuvalue1 == "") // { // menuvalue1 = "" + cbl_hostel.Items[i].Value.ToString() + ""; // } // else // { // menuvalue1 = menuvalue1 + "'" + "," + "'" + cbl_hostel.Items[i].Value.ToString() + ""; // } // } //} for (int i = 0; i < cbl_supplier.Items.Count; i++) { if (cbl_supplier.Items[i].Selected == true) { if (item == "") { item = "" + cbl_supplier.Items[i].Value.ToString() + ""; } else { item = item + "'" + "," + "'" + cbl_supplier.Items[i].Value.ToString() + ""; } } } //if (ItemList.Count == 0) //{ // ItemList.Add("Hostel_Name"); // ItemList.Add("Session_Name"); // ItemList.Add("MenuName"); // ItemList.Add("Item_Code"); // ItemList.Add("item_name"); // ItemList.Add("RPU"); // ItemList.Add("Consumption_Date"); // ItemList.Add("qut"); // ItemList.Add("value"); // ItemList.Add("Total_Present"); //} Hashtable columnhash = new Hashtable(); columnhash.Clear(); int colinc = 0; columnhash.Add("vendor_name", "Supplier Name"); columnhash.Add("GI_Date", "Supplied Date"); columnhash.Add("Order_Date", "Purchase Order Date"); columnhash.Add("Order_Code", "Purchase Order Code"); columnhash.Add("itemheader_name", "Item Header Name"); columnhash.Add("Item_Code", "Item Code"); columnhash.Add("Item_Name", "Item Name"); columnhash.Add("Item_unit", "Measure"); columnhash.Add("order_qty", "Ordered QTY"); columnhash.Add("OrderedAmt", "Ordered QTY Amount"); columnhash.Add("Request_qty", "Requested QTY"); columnhash.Add("Request_Amt", "Requested QTY Amount"); columnhash.Add("RejQty", "Rejected QTY"); columnhash.Add("MasterValue", "Reject Reason"); if (ItemList.Count == 0) { ItemList.Add("Order_Date"); ItemList.Add("Order_Code"); ItemList.Add("GI_Date"); ItemList.Add("itemheader_name"); ItemList.Add("Item_Code"); ItemList.Add("Item_Name"); //ItemList.Add("Consumption_Date"); //ItemList.Add("qut"); //ItemList.Add("value"); //ItemList.Add("Total_Present"); } string getday = ""; string gettoday = ""; string from = ""; string to = ""; from = Convert.ToString(txt_fromdate.Text); string[] splitdate = from.Split('-'); splitdate = splitdate[0].Split('/'); DateTime dt = new DateTime(); if (splitdate.Length > 0) { dt = Convert.ToDateTime(splitdate[1] + "/" + splitdate[0] + "/" + splitdate[2]); } getday = dt.ToString("MM/dd/yyyy"); to = Convert.ToString(txt_todate.Text); string[] splitdate1 = to.Split('-'); splitdate1 = splitdate1[0].Split('/'); DateTime dt1 = new DateTime(); if (splitdate1.Length > 0) { dt1 = Convert.ToDateTime(splitdate1[1] + "/" + splitdate1[0] + "/" + splitdate1[2]); } gettoday = dt1.ToString("MM/dd/yyyy"); if (item != "") { string selectquery = ""; selectquery = "SELECT distinct P.OrderCode as Order_Code,CONVERT(varchar(10), OrderDate,103) as Order_Date,G.GoodsInwardCode as GI_Code,CONVERT(varchar(10), GoodsInwardDate,103) as GI_Date,ItemHeaderName as itemheader_name,m.itemcode as Item_Code,M.ItemName as Item_Name,M.ItemUnit as Item_unit,(AppQty-ISNULL(RejQty,0)) as order_qty,((AppQty-ISNULL(RejQty,0))*RPU) as OrderedAmt,AppQty as Request_qty,(AppQty * rpu) as Request_Amt,InwardQty,(InwardQty*RPU) InwardAmt,RejQty,v.VendorCompName as vendor_name,(select MasterValue from CO_MasterValues c where c.MasterCode=i.Reject_reason)as MasterValue FROM IT_PurchaseOrder P,IT_PurchaseOrderDetail I,IT_GoodsInward G,IM_ItemMaster M,CO_VendorMaster V WHERE P.PurchaseOrderPK = I.PurchaseOrderFK and I.ItemFK=M.ItemPK and I.ItemFK=G.ItemFK and p.VendorFK =v.VendorPK AND p.VendorFK in ('" + item + "') AND OrderDate between '" + dt.ToString("MM/dd/yyyy") + "' and '" + dt1.ToString("MM/dd/yyyy") + "' and p.PurchaseOrderPK=g.PurchaseOrderFK "; ds.Clear(); ds = d2.select_method_wo_parameter(selectquery, "Text"); if (ds.Tables[0].Rows.Count > 0) { pcolumnorder.Visible = true; Fpspread1.Sheets[0].RowHeader.Visible = false; //Fpspread1.Sheets[0].ColumnCount = 11; Fpspread1.CommandBar.Visible = false; Fpspread1.Sheets[0].RowCount = 0; Fpspread1.SheetCorner.ColumnCount = 0; FarPoint.Web.Spread.StyleInfo darkstyle = new FarPoint.Web.Spread.StyleInfo(); darkstyle.BackColor = ColorTranslator.FromHtml("#0CA6CA"); darkstyle.ForeColor = Color.White; Fpspread1.ActiveSheetView.ColumnHeader.DefaultStyle = darkstyle; Fpspread1.Sheets[0].ColumnHeader.RowCount = 1; Fpspread1.Sheets[0].RowHeader.Visible = false; Fpspread1.Sheets[0].ColumnCount = ItemList.Count + 1; Fpspread1.Sheets[0].RowCount = ds.Tables[0].Rows.Count; Fpspread1.Sheets[0].AutoPostBack = true; Fpspread1.Sheets[0].ColumnHeader.Cells[0, 0].Text = "S.No"; Fpspread1.Sheets[0].ColumnHeader.Cells[0, 0].Font.Bold = true; Fpspread1.Sheets[0].ColumnHeader.Cells[0, 0].Font.Name = "Book Antiqua"; Fpspread1.Sheets[0].ColumnHeader.Cells[0, 0].Font.Size = FontUnit.Medium; Fpspread1.Sheets[0].ColumnHeader.Cells[0, 0].HorizontalAlign = HorizontalAlign.Center; Fpspread1.Sheets[0].Columns[0].HorizontalAlign = HorizontalAlign.Center; FarPoint.Web.Spread.TextCellType txt = new FarPoint.Web.Spread.TextCellType(); for (int j = 0; j < ds.Tables[0].Columns.Count; j++) { colno = Convert.ToString(ds.Tables[0].Columns[j]); if (ItemList.Contains(Convert.ToString(colno))) { int index = ItemList.IndexOf(Convert.ToString(colno)); Fpspread1.Sheets[0].ColumnHeader.Cells[0, index + 1].Text = Convert.ToString(columnhash[colno]); Fpspread1.Sheets[0].ColumnHeader.Cells[0, index + 1].Font.Bold = true; Fpspread1.Sheets[0].ColumnHeader.Cells[0, index + 1].Font.Name = "Book Antiqua"; Fpspread1.Sheets[0].ColumnHeader.Cells[0, index + 1].Font.Size = FontUnit.Medium; Fpspread1.Sheets[0].ColumnHeader.Cells[0, index + 1].HorizontalAlign = HorizontalAlign.Center; } } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Fpspread1.Sheets[0].Cells[i, 0].Text = Convert.ToString(i + 1); Fpspread1.Sheets[0].Cells[i, 0].HorizontalAlign = HorizontalAlign.Center; for (int j = 0; j < ds.Tables[0].Columns.Count; j++) { if (ItemList.Contains(Convert.ToString(ds.Tables[0].Columns[j].ToString()))) { int index = ItemList.IndexOf(Convert.ToString(ds.Tables[0].Columns[j].ToString())); Fpspread1.Sheets[0].Columns[index + 1].Width = 150; Fpspread1.Sheets[0].Columns[index + 1].Locked = true; Fpspread1.Sheets[0].Cells[i, index + 1].CellType = txt; Fpspread1.Sheets[0].Cells[i, index + 1].Text = ds.Tables[0].Rows[i][j].ToString(); Fpspread1.Sheets[0].Cells[i, index + 1].Font.Name = "Book Antiqua"; Fpspread1.Sheets[0].Cells[i, index + 1].Font.Size = FontUnit.Medium; if (ds.Tables[0].Columns[j].ToString() == "order_qty") { Fpspread1.Sheets[0].Cells[i, index + 1].HorizontalAlign = HorizontalAlign.Right; } if (ds.Tables[0].Columns[j].ToString() == "OrderedAmt") { Fpspread1.Sheets[0].Cells[i, index + 1].HorizontalAlign = HorizontalAlign.Right; } if (ds.Tables[0].Columns[j].ToString() == "Request_qty") { Fpspread1.Sheets[0].Cells[i, index + 1].HorizontalAlign = HorizontalAlign.Right; } if (ds.Tables[0].Columns[j].ToString() == "Request_Amt") { Fpspread1.Sheets[0].Cells[i, index + 1].HorizontalAlign = HorizontalAlign.Right; } if (ds.Tables[0].Columns[j].ToString() == "Rej_qty") { Fpspread1.Sheets[0].Cells[i, index + 1].HorizontalAlign = HorizontalAlign.Right; } Fpspread1.Sheets[0].SetColumnMerge(index + 1, FarPoint.Web.Spread.Model.MergePolicy.Always); Fpspread1.Sheets[0].Cells[i, index + 1].VerticalAlign = VerticalAlign.Middle; } } } //Fpspread1.Sheets[0].SetColumnMerge(1, FarPoint.Web.Spread.Model.MergePolicy.Always); ////Fpspread1.Sheets[0].SetColumnMerge(2, FarPoint.Web.Spread.Model.MergePolicy.Always); ////Fpspread1.Sheets[0].SetColumnMerge(3, FarPoint.Web.Spread.Model.MergePolicy.Always); Fpspread1.Sheets[0].PageSize = Fpspread1.Sheets[0].RowCount; rptprint.Visible = true; Fpspread1.Visible = true; div1.Visible = true; lbl_error.Visible = false; pheaderfilter.Visible = true; pcolumnorder.Visible = true; } else { rptprint.Visible = false; //imgdiv2.Visible = true; // lbl_alert.Text = "No records found"; lbl_error.Visible = true; lbl_error.Text = "No records found"; pheaderfilter.Visible = false; pcolumnorder.Visible = false; div1.Visible = false; Fpspread1.Visible = false; } } else { rptprint.Visible = false; // imgdiv2.Visible = true; //lbl_alert.Text = "No records found"; lbl_error.Visible = true; lbl_error.Text = "Please Select Any One Supplier Name"; pheaderfilter.Visible = false; pcolumnorder.Visible = false; div1.Visible = false; Fpspread1.Visible = false; } } catch (Exception ex) { } }
public void TestArrayListWrappers02() { //-------------------------------------------------------------------------- // Variable definitions. //-------------------------------------------------------------------------- ArrayList arrList = null; int ndx = -1; string[] strHeroes = { "Aquaman", "Atom", "Batman", "Black Canary", "Captain America", "Captain Atom", "Batman", "Catwoman", "Cyborg", "Flash", "Green Arrow", "Batman", "Green Lantern", "Hawkman", "Huntress", "Ironman", "Nightwing", "Batman", "Robin", "SpiderMan", "Steel", "Superman", "Thor", "Batman", "Wildcat", "Wonder Woman", "Batman", null }; // // Construct array lists. // arrList = new ArrayList((ICollection)strHeroes); Assert.NotNull(arrList); //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of //BinarySearch, Following variable cotains each one of these types of array lists ArrayList[] arrayListTypes = { arrList, ArrayList.Adapter(arrList), ArrayList.FixedSize(arrList), arrList.GetRange(0, arrList.Count), ArrayList.ReadOnly(arrList), ArrayList.Synchronized(arrList)}; foreach (ArrayList arrayListType in arrayListTypes) { arrList = arrayListType; // // [] Obtain index of "Batman" items. // ndx = 0; int startIndex = 0; int tmpNdx = 0; while (startIndex < arrList.Count && (ndx = arrList.IndexOf("Batman", startIndex, (arrList.Count - startIndex))) != -1) { Assert.True(ndx >= startIndex); Assert.Equal(0, strHeroes[ndx].CompareTo((string)arrList[ndx])); tmpNdx = arrList.IndexOf("Batman", startIndex, ndx - startIndex + 1); Assert.Equal(ndx, tmpNdx); tmpNdx = arrList.IndexOf("Batman", startIndex, ndx - startIndex); Assert.Equal(-1, tmpNdx); startIndex = ndx + 1; } // // [] Attempt to find null object when a null element exists in the collections // ndx = arrList.IndexOf(null, 0, arrList.Count); Assert.Null(arrList[ndx]); // // [] Attempt invalid IndexOf using negative index // Assert.Throws<ArgumentOutOfRangeException>(() => arrList.IndexOf("Batman", -1000, arrList.Count)); // // [] Attempt invalid IndexOf using out of range index // Assert.Throws<ArgumentOutOfRangeException>(() => arrList.IndexOf("Batman", 1000, arrList.Count)); // // [] Attempt invalid IndexOf using index=Count // Assert.Equal(-1, arrList.IndexOf("Batman", arrList.Count, 0)); // // [] Attempt invalid IndexOf using endIndex greater than the size. // // Assert.Throws<ArgumentOutOfRangeException>(() => arrList.IndexOf("Batman", 3, arrList.Count + 10)); //[]Team Review feedback - attempt to find non-existent object and confirm that -1 returned arrList = new ArrayList(); for (int i = 0; i < 10; i++) arrList.Add(i); Assert.Equal(-1, arrList.IndexOf(50, 0, arrList.Count)); Assert.Equal(-1, arrList.IndexOf(0, 1, arrList.Count - 1)); } }
// Organizes all sprites by associating them with the // material they use. Returns an array list of // MaterialSpriteLists: List<MaterialSpriteList> OrganizeByMaterial(ArrayList sprites) { // A list of all materials ArrayList materials = new ArrayList(); // The map of materials to sprites List<MaterialSpriteList> map = new List<MaterialSpriteList>(); // The material of the sprite: Material mat; SpriteRoot sprite; MaterialSpriteList matSpriteList; int index; for (int i = 0; i < sprites.Count; ++i) { sprite = (SpriteRoot)sprites[i]; if (sprite.spriteMesh == null) { // See if it is because the sprite isn't associated // with a manager: if (sprite.managed) { // See if we can get the material // from an associated manager: if (sprite.manager != null) { mat = sprite.manager.renderer.sharedMaterial; } else // Else, no manager associated!: { EditorUtility.DisplayDialog("ERROR", "Sprite \"" + sprite.name + "\" is not associated with a SpriteManager, and can therefore not be included in the atlas build.", "Ok"); Selection.activeGameObject = sprite.gameObject; return null; } } else // Else get the material from the sprite's renderer { // as this is probably a prefab and that's why it // doesn't have a mesh: mat = sprite.renderer.sharedMaterial; } } else if (sprite.managed) { if (sprite.manager != null) { mat = sprite.manager.renderer.sharedMaterial; } else // Else, no manager associated!: { EditorUtility.DisplayDialog("ERROR", "Sprite \"" + sprite.name + "\" is not associated with a SpriteManager, and can therefore not be included in the atlas build.", "Ok"); Selection.activeGameObject = sprite.gameObject; return null; } } else mat = sprite.spriteMesh.material; index = materials.IndexOf(mat); // See if the material is already in our list: if (index >= 0) { matSpriteList = (MaterialSpriteList)map[index]; matSpriteList.sprites.Add(sprite); } else { // Validate that the sprite had a material: if (mat == null) { EditorUtility.DisplayDialog("ERROR: No material selected", "No material selected for sprite \"" + sprite.name + "\"! Please set a material and try again. Click OK to go directly to the sprite that generated this error.", "Ok"); Selection.activeGameObject = sprite.gameObject; return null; } materials.Add(mat); matSpriteList = new MaterialSpriteList(); matSpriteList.material = mat; matSpriteList.sprites.Add(sprite); map.Add(matSpriteList); } } return map; }
public void Generate() { BinaryWriter writer; IFormatter formatter; if (resources == null) { throw new InvalidOperationException("The resource writer has already been closed and cannot be edited"); } writer = new BinaryWriter(stream, Encoding.UTF8); formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.File | StreamingContextStates.Persistence)); /* The ResourceManager header */ writer.Write(ResourceManager.MagicNumber); writer.Write(ResourceManager.HeaderVersionNumber); /* Build the rest of the ResourceManager * header in memory, because we need to know * how long it is in advance */ MemoryStream resman_stream = new MemoryStream(); BinaryWriter resman = new BinaryWriter(resman_stream, Encoding.UTF8); resman.Write(typeof(ResourceReader).AssemblyQualifiedName); #if NET_2_0 resman.Write(typeof(RuntimeResourceSet).FullName); #else resman.Write(typeof(ResourceSet).AssemblyQualifiedName); #endif /* Only space for 32 bits of header len in the * resource file format */ int resman_len = (int)resman_stream.Length; writer.Write(resman_len); writer.Write(resman_stream.GetBuffer(), 0, resman_len); /* We need to build the ResourceReader name * and data sections simultaneously */ MemoryStream res_name_stream = new MemoryStream(); BinaryWriter res_name = new BinaryWriter(res_name_stream, Encoding.Unicode); MemoryStream res_data_stream = new MemoryStream(); BinaryWriter res_data = new BinaryWriter(res_data_stream, Encoding.UTF8); /* Not sure if this is the best collection to * use, I just want an unordered list of * objects with fast lookup, but without * needing a key. (I suppose a hashtable with * key==value would work, but I need to find * the index of each item later) */ ArrayList types = new ArrayList(); int [] hashes = new int [resources.Count]; int [] name_offsets = new int [resources.Count]; int count = 0; IDictionaryEnumerator res_enum = resources.GetEnumerator(); while (res_enum.MoveNext()) { /* Hash the name */ hashes [count] = GetHash((string)res_enum.Key); /* Record the offsets */ name_offsets [count] = (int)res_name.BaseStream.Position; /* Write the name section */ res_name.Write((string)res_enum.Key); res_name.Write((int)res_data.BaseStream.Position); if (res_enum.Value == null) { Write7BitEncodedInt(res_data, -1); count++; continue; } // implementation note: TypeByNameObject is // not used in 1.x profile. TypeByNameObject tbn = res_enum.Value as TypeByNameObject; Type type = tbn != null ? null : res_enum.Value.GetType(); object typeObj = tbn != null ? (object)tbn.TypeName : type; /* Keep a list of unique types */ #if NET_2_0 // do not output predefined ones. switch ((type != null && !type.IsEnum) ? Type.GetTypeCode(type) : TypeCode.Empty) { case TypeCode.Decimal: case TypeCode.Single: case TypeCode.Double: case TypeCode.SByte: case TypeCode.Int16: case TypeCode.Int32: case TypeCode.Int64: case TypeCode.Byte: case TypeCode.UInt16: case TypeCode.UInt32: case TypeCode.UInt64: case TypeCode.DateTime: case TypeCode.String: break; default: if (type == typeof(TimeSpan)) { break; } if (type == typeof(MemoryStream)) { break; } if (type == typeof(byte[])) { break; } if (!types.Contains(typeObj)) { types.Add(typeObj); } /* Write the data section */ Write7BitEncodedInt(res_data, (int)PredefinedResourceType.FistCustom + types.IndexOf(typeObj)); break; } #else if (!types.Contains(typeObj)) { types.Add(typeObj); } /* Write the data section */ Write7BitEncodedInt(res_data, types.IndexOf(type)); #endif /* Strangely, Char is serialized * rather than just written out */ #if NET_2_0 if (tbn != null) { res_data.Write((byte [])tbn.Value); } else if (type == typeof(Byte)) { res_data.Write((byte)PredefinedResourceType.Byte); res_data.Write((Byte)res_enum.Value); } else if (type == typeof(Decimal)) { res_data.Write((byte)PredefinedResourceType.Decimal); res_data.Write((Decimal)res_enum.Value); } else if (type == typeof(DateTime)) { res_data.Write((byte)PredefinedResourceType.DateTime); res_data.Write(((DateTime)res_enum.Value).Ticks); } else if (type == typeof(Double)) { res_data.Write((byte)PredefinedResourceType.Double); res_data.Write((Double)res_enum.Value); } else if (type == typeof(Int16)) { res_data.Write((byte)PredefinedResourceType.Int16); res_data.Write((Int16)res_enum.Value); } else if (type == typeof(Int32)) { res_data.Write((byte)PredefinedResourceType.Int32); res_data.Write((Int32)res_enum.Value); } else if (type == typeof(Int64)) { res_data.Write((byte)PredefinedResourceType.Int64); res_data.Write((Int64)res_enum.Value); } else if (type == typeof(SByte)) { res_data.Write((byte)PredefinedResourceType.SByte); res_data.Write((SByte)res_enum.Value); } else if (type == typeof(Single)) { res_data.Write((byte)PredefinedResourceType.Single); res_data.Write((Single)res_enum.Value); } else if (type == typeof(String)) { res_data.Write((byte)PredefinedResourceType.String); res_data.Write((String)res_enum.Value); } else if (type == typeof(TimeSpan)) { res_data.Write((byte)PredefinedResourceType.TimeSpan); res_data.Write(((TimeSpan)res_enum.Value).Ticks); } else if (type == typeof(UInt16)) { res_data.Write((byte)PredefinedResourceType.UInt16); res_data.Write((UInt16)res_enum.Value); } else if (type == typeof(UInt32)) { res_data.Write((byte)PredefinedResourceType.UInt32); res_data.Write((UInt32)res_enum.Value); } else if (type == typeof(UInt64)) { res_data.Write((byte)PredefinedResourceType.UInt64); res_data.Write((UInt64)res_enum.Value); } else if (type == typeof(byte[])) { res_data.Write((byte)PredefinedResourceType.ByteArray); byte [] data = (byte[])res_enum.Value; res_data.Write((uint)data.Length); res_data.Write(data, 0, data.Length); } else if (type == typeof(MemoryStream)) { res_data.Write((byte)PredefinedResourceType.Stream); byte [] data = ((MemoryStream)res_enum.Value).ToArray(); res_data.Write((uint)data.Length); res_data.Write(data, 0, data.Length); } else { /* non-intrinsic types are * serialized */ formatter.Serialize(res_data.BaseStream, res_enum.Value); } #else if (type == typeof(Byte)) { res_data.Write((Byte)res_enum.Value); } else if (type == typeof(Decimal)) { res_data.Write((Decimal)res_enum.Value); } else if (type == typeof(DateTime)) { res_data.Write(((DateTime)res_enum.Value).Ticks); } else if (type == typeof(Double)) { res_data.Write((Double)res_enum.Value); } else if (type == typeof(Int16)) { res_data.Write((Int16)res_enum.Value); } else if (type == typeof(Int32)) { res_data.Write((Int32)res_enum.Value); } else if (type == typeof(Int64)) { res_data.Write((Int64)res_enum.Value); } else if (type == typeof(SByte)) { res_data.Write((SByte)res_enum.Value); } else if (type == typeof(Single)) { res_data.Write((Single)res_enum.Value); } else if (type == typeof(String)) { res_data.Write((String)res_enum.Value); } else if (type == typeof(TimeSpan)) { res_data.Write(((TimeSpan)res_enum.Value).Ticks); } else if (type == typeof(UInt16)) { res_data.Write((UInt16)res_enum.Value); } else if (type == typeof(UInt32)) { res_data.Write((UInt32)res_enum.Value); } else if (type == typeof(UInt64)) { res_data.Write((UInt64)res_enum.Value); } else { /* non-intrinsic types are * serialized */ formatter.Serialize(res_data.BaseStream, res_enum.Value); } #endif count++; } /* Sort the hashes, keep the name offsets * matching up */ Array.Sort(hashes, name_offsets); /* now do the ResourceReader header */ #if NET_2_0 writer.Write(2); #else writer.Write(1); #endif writer.Write(resources.Count); writer.Write(types.Count); /* Write all of the unique types */ foreach (object type in types) { if (type is Type) { writer.Write(((Type)type).AssemblyQualifiedName); } else { writer.Write((string)type); } } /* Pad the next fields (hash values) on an 8 * byte boundary, using the letters "PAD" */ int pad_align = (int)(writer.BaseStream.Position & 7); int pad_chars = 0; if (pad_align != 0) { pad_chars = 8 - pad_align; } for (int i = 0; i < pad_chars; i++) { writer.Write((byte)"PAD" [i % 3]); } /* Write the hashes */ for (int i = 0; i < resources.Count; i++) { writer.Write(hashes[i]); } /* and the name offsets */ for (int i = 0; i < resources.Count; i++) { writer.Write(name_offsets [i]); } /* Write the data section offset */ int data_offset = (int)writer.BaseStream.Position + (int)res_name_stream.Length + 4; writer.Write(data_offset); /* The name section goes next */ writer.Write(res_name_stream.GetBuffer(), 0, (int)res_name_stream.Length); /* The data section is last */ writer.Write(res_data_stream.GetBuffer(), 0, (int)res_data_stream.Length); res_name.Close(); res_data.Close(); /* Don't close writer, according to the spec */ writer.Flush(); // ResourceWriter is no longer editable resources = null; }
public virtual Point GetTrainPoint(ArrayList alTrains, TrainBase t) { int index = -1; if (alTrains.Count > 1) { index = alTrains.IndexOf(t); } Point trainPoint = this.GetTrainPoint(); PathElement element = this; Point point2 = new Point(); if (t.HeadElementArrivedSource != -1) { int[] sources = element.GetSources(); Debug.Assert(sources.Length == 2); Point connectionSourcePoint = element.GetConnectionSourcePoint(sources[0]); Point point4 = element.GetConnectionSourcePoint(sources[1]); if (sources.Length != 2) { return trainPoint; } double introduced15 = Math.Pow(connectionSourcePoint.get_X() - point4.get_X(), 2.0); double num2 = Math.Sqrt(introduced15 + Math.Pow(connectionSourcePoint.get_Y() - point4.get_Y(), 2.0)); double num3 = (num2 * t.HeadOffset) / ((element.Length == 0) ? ((double) 1) : ((double) element.Length)); double num4 = 1.0; double num5 = 0.0; if (!(connectionSourcePoint.get_Y() == point4.get_Y())) { num4 = Math.Abs((double) (point4.get_X() - connectionSourcePoint.get_X())) / num2; num5 = Math.Abs((double) (point4.get_Y() - connectionSourcePoint.get_Y())) / num2; } double num6 = num3 * num4; double num7 = num3 * num5; if (t.HeadElementArrivedSource == sources[0]) { if (connectionSourcePoint.get_X() <= point4.get_X()) { connectionSourcePoint.set_X(connectionSourcePoint.get_X() + num6); } else { connectionSourcePoint.set_X(connectionSourcePoint.get_X() - num6); } if (connectionSourcePoint.get_Y() <= point4.get_Y()) { connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() + num7); } else { connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() - num7); } point2 = connectionSourcePoint; } else { if (point4.get_X() <= connectionSourcePoint.get_X()) { point4.set_X(point4.get_X() + num6); } else { point4.set_X(point4.get_X() - num6); } if (point4.get_Y() <= connectionSourcePoint.get_Y()) { point4.set_Y(point4.get_Y() + num7); } else { point4.set_Y(point4.get_Y() - num7); } point2 = point4; } trainPoint = point2; if (index != -1) { if (connectionSourcePoint.get_Y() == point4.get_Y()) { trainPoint.set_Y(trainPoint.get_Y() - 6.0); trainPoint.set_Y(trainPoint.get_Y() + (13 * index)); } else { trainPoint.set_X(trainPoint.get_X() - 6.0); trainPoint.set_X(trainPoint.get_X() + (13 * index)); } } } return trainPoint; }
public int GetSelectedIndex(object row) { return(selection.IndexOf(row)); }
public void GetFrontTest() { Assert.AreEqual("Bill", AList.IndexOf(1)); }
/* * @brief 随机钻石 * @desc 当创建完成所有的泡泡的时候,要随机几个可以得到钻石 */ void RandomAllPubbleDiamond() { UpdatePlayObjectsScriptsList(); int diamondNum = Random.Range(5, 9); ArrayList indexNumArr = new ArrayList(); for (int i = 0; i < diamondNum; i++) { int randomIndex = Random.Range(0, storageAllObjectScripts.Length); int indexOfArr = indexNumArr.IndexOf(randomIndex); while (indexOfArr >= 0) { //表示存在,则继续随机 randomIndex = Random.Range(0, storageAllObjectScripts.Length); indexOfArr = indexNumArr.IndexOf(randomIndex); } if (randomIndex < storageAllObjectScripts.Length) { storageAllObjectScripts[randomIndex].ChangeDiamongMark(); } } }
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Value != null) { if (e.RowHandle != 0 && e.RowHandle != gridView1.RowCount - 1) { if (e.Column.ColumnHandle == 0 || e.Column.ColumnHandle == gridView1.Columns.Count - 2 || e.Column.ColumnHandle == gridView1.Columns.Count - 1) { if (e.Value.ToString().Trim() != "" && _reColor.Items.IndexOf(e.Value.ToString().Trim()) == -1) { if (DialogResult.Yes == XtraMessageBox.Show("所填內容不在已有列表中,是否新增?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)) { DataTable dtTem = _dtColor.Clone(); DataRow dr = dtTem.NewRow(); dr["ID"] = 0; dr["Name"] = e.Value.ToString().Trim(); dr["Value"] = 0; dr["IsEnd"] = 0; dr["IsUse"] = true; dr["ColorTypeID"] = 0; dr["Sn"] = (int.Parse(_dtColor.Rows[_dtColor.Rows.Count - 1]["Sn"].ToString()) + 1).ToString().PadLeft(3, '0'); dr["A"] = 1; dtTem.Rows.Add(dr); dtTem.Rows[0]["ID"] = BasicClass.GetDataSet.Add(bllC, dtTem); _dtColor.Rows.Add(dtTem.Rows[0].ItemArray); _reColor.Items.Add(e.Value.ToString().Trim()); return; } else { gridView1.SetFocusedValue(""); } } } } if (e.RowHandle == 0) { if (e.Value.ToString().Trim() != "" && _reSize.Items.IndexOf(e.Value.ToString().Trim()) == -1) { if (_liS.IndexOf(e.Value.ToString().Trim()) == -1) { if (DialogResult.Yes == XtraMessageBox.Show("所填內容不在已有列表中,是否新增?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)) { DataTable dtTem = _dtSize.Clone(); DataRow dr = dtTem.NewRow(); dr["ID"] = 0; dr["Name"] = e.Value.ToString().Trim(); dr["IsEnd"] = 0; dr["IsUse"] = true; dr["SizeTypeID"] = 0; dr["Sn"] = string.Empty;// (int.Parse(_dtSize.Rows[_dtSize.Rows.Count - 1]["Sn"].ToString()) + 1).ToString().PadLeft(3, '0'); dr["A"] = 1; dtTem.Rows.Add(dr); BasicClass.GetDataSet.Add(bllS, dtTem); _dtSize.Rows.Add(dtTem.Rows[0].ItemArray); _reSize.Items.Add(e.Value.ToString().Trim()); _liS.Add(e.Value.ToString().Trim()); } else { gridView1.SetFocusedValue(""); } } else { gridView1.SetFocusedValue(""); return; } } } if (e.RowHandle == gridView1.RowCount - 2) { DataTable dttem = (DataTable)(gridControl1.DataSource); dttem.Rows.RemoveAt(dttem.Rows.Count - 1); dttem.Rows.Add(dttem.NewRow()); dttem.Rows.Add(dttem.NewRow()); FormOpen.ReSumTable(dttem); gridView1.SetRowCellValue(gridView1.RowCount - 1, gridView1.Columns[0], "合计"); return; } if (e.Column.ColumnHandle == gridView1.Columns.Count - 4) { int c = gridView1.Columns.Count; DataTable dttem = (DataTable)(gridControl1.DataSource); dttem.Columns.Add("Columns" + c.ToString(), typeof(string)); dttem.Rows[0]["Columns" + c.ToString()] = ""; dttem.Columns["Columns" + c.ToString()].SetOrdinal(dttem.Columns.Count - 4); gridView1.Columns.Add(); gridView1.Columns[c].FieldName = "Columns" + c.ToString(); gridView1.Columns[c].VisibleIndex = c - 3; gridView1.Columns[c].Visible = true; gridView1.Columns[c].Width = gridView1.Columns[1].Width; return; } if (e.RowHandle != 0 && e.RowHandle != gridView1.RowCount - 1 && e.Column.ColumnHandle > 0 && e.Column.ColumnHandle < gridView1.Columns.Count - 3) { DataTable dttem = (DataTable)(gridControl1.DataSource); FormOpen.ReSumTable(dttem); } _IsEdit = true; _isCanEdit = true; int sAmount = 0; try { sAmount = int.Parse(gridView1.GetRowCellValue(gridView1.RowCount - 1, gridView1.Columns[gridView1.Columns.Count - 3]).ToString()); } catch { } ChangeVal(sAmount, "总数"); } }
public object ArrFind_Kac(object data) { return(KarisikList.IndexOf(data)); }
public void TestDuplicatedItems() { //-------------------------------------------------------------------------- // Variable definitions. //-------------------------------------------------------------------------- ArrayList arrList = null; string[] strHeroes = { "Aquaman", "Atom", "Batman", "Black Canary", "Captain America", "Captain Atom", "Catwoman", "Cyborg", "Flash", "Green Arrow", "Green Lantern", "Hawkman", "Daniel Takacs", "Ironman", "Nightwing", "Robin", "SpiderMan", "Steel", "Gene", "Thor", "Wildcat", null }; // Construct ArrayList. arrList = new ArrayList(strHeroes); //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of //BinarySearch, Following variable cotains each one of these types of array lists ArrayList[] arrayListTypes = { (ArrayList)arrList.Clone(), (ArrayList)ArrayList.Adapter(arrList).Clone(), (ArrayList)arrList.GetRange(0, arrList.Count).Clone(), (ArrayList)ArrayList.Synchronized(arrList).Clone() }; foreach (ArrayList arrayListType in arrayListTypes) { arrList = arrayListType; // // [] IndexOf an array normal // for (int i = 0; i < strHeroes.Length; i++) { Assert.Equal(i, arrList.IndexOf(strHeroes[i])); } //[] Check IndexOf when element is in list twice arrList.Clear(); arrList.Add(null); arrList.Add(arrList); arrList.Add(null); Assert.Equal(0, arrList.IndexOf(null)); //[] check for something which does not exist in a list arrList.Clear(); Assert.Equal(-1, arrList.IndexOf(null)); } }
public void TestArrayListWrappers01() { //-------------------------------------------------------------------------- // Variable definitions. //-------------------------------------------------------------------------- // no null string[] strHeroes = { "Aquaman", "Atom", "Batman", "Black Canary", "Captain America", "Captain Atom", "Batman", "Catwoman", "Cyborg", "Flash", "Green Arrow", "Batman", "Green Lantern", "Hawkman", "Huntress", "Ironman", "Nightwing", "Batman", "Robin", "SpiderMan", "Steel", "Superman", "Thor", "Batman", "Wildcat", "Wonder Woman", "Batman", }; ArrayList arrList = null; int ndx = -1; // Construct ArrayList. arrList = new ArrayList((ICollection)strHeroes); //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of //BinarySearch, Following variable cotains each one of these types of array lists ArrayList[] arrayListTypes = { (ArrayList)arrList.Clone(), (ArrayList)ArrayList.Adapter(arrList).Clone(), (ArrayList)arrList.GetRange(0, arrList.Count).Clone(), (ArrayList)ArrayList.Synchronized(arrList).Clone() }; foreach (ArrayList arrayListType in arrayListTypes) { arrList = arrayListType; // // Construct array lists. // Assert.NotNull(arrList); // // [] Obtain index of "Batman" items. // int startIndex = 0; while (startIndex < arrList.Count && (ndx = arrList.IndexOf("Batman", startIndex)) != -1) { Assert.True(startIndex <= ndx); Assert.Equal(0, strHeroes[ndx].CompareTo((string)arrList[ndx])); // // [] Attempt to find null object. // // Remove range of items. ndx = arrList.IndexOf(null, 0); Assert.Equal(-1, ndx); // // [] Attempt invalid IndexOf using negative index // Assert.Throws <ArgumentOutOfRangeException>(() => arrList.IndexOf("Batman", -1000)); // // [] Attempt invalid IndexOf using out of range index // Assert.Throws <ArgumentOutOfRangeException>(() => arrList.IndexOf("Batman", 1000)); // []Team review feedback - query for an existing object after the index. expects -1 arrList.Clear(); for (int i = 0; i < 10; i++) { arrList.Add(i); } Assert.Equal(-1, arrList.IndexOf(0, 1)); } } }
public void TestArrayListWrappers02() { //-------------------------------------------------------------------------- // Variable definitions. //-------------------------------------------------------------------------- ArrayList arrList = null; int ndx = -1; string[] strHeroes = { "Aquaman", "Atom", "Batman", "Black Canary", "Captain America", "Captain Atom", "Batman", "Catwoman", "Cyborg", "Flash", "Green Arrow", "Batman", "Green Lantern", "Hawkman", "Huntress", "Ironman", "Nightwing", "Batman", "Robin", "SpiderMan", "Steel", "Superman", "Thor", "Batman", "Wildcat", "Wonder Woman", "Batman", null }; // // Construct array lists. // arrList = new ArrayList((ICollection)strHeroes); Assert.NotNull(arrList); //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of //BinarySearch, Following variable cotains each one of these types of array lists ArrayList[] arrayListTypes = { arrList, ArrayList.Adapter(arrList), ArrayList.FixedSize(arrList), arrList.GetRange(0, arrList.Count), ArrayList.ReadOnly(arrList), ArrayList.Synchronized(arrList) }; foreach (ArrayList arrayListType in arrayListTypes) { arrList = arrayListType; // // [] Obtain index of "Batman" items. // ndx = 0; int startIndex = 0; int tmpNdx = 0; while (startIndex < arrList.Count && (ndx = arrList.IndexOf("Batman", startIndex, (arrList.Count - startIndex))) != -1) { Assert.True(ndx >= startIndex); Assert.Equal(0, strHeroes[ndx].CompareTo((string)arrList[ndx])); tmpNdx = arrList.IndexOf("Batman", startIndex, ndx - startIndex + 1); Assert.Equal(ndx, tmpNdx); tmpNdx = arrList.IndexOf("Batman", startIndex, ndx - startIndex); Assert.Equal(-1, tmpNdx); startIndex = ndx + 1; } // // [] Attempt to find null object when a null element exists in the collections // ndx = arrList.IndexOf(null, 0, arrList.Count); Assert.Null(arrList[ndx]); // // [] Attempt invalid IndexOf using negative index // Assert.Throws <ArgumentOutOfRangeException>(() => arrList.IndexOf("Batman", -1000, arrList.Count)); // // [] Attempt invalid IndexOf using out of range index // Assert.Throws <ArgumentOutOfRangeException>(() => arrList.IndexOf("Batman", 1000, arrList.Count)); // // [] Attempt invalid IndexOf using index=Count // Assert.Equal(-1, arrList.IndexOf("Batman", arrList.Count, 0)); // // [] Attempt invalid IndexOf using endIndex greater than the size. // // Assert.Throws <ArgumentOutOfRangeException>(() => arrList.IndexOf("Batman", 3, arrList.Count + 10)); //[]Team Review feedback - attempt to find non-existent object and confirm that -1 returned arrList = new ArrayList(); for (int i = 0; i < 10; i++) { arrList.Add(i); } Assert.Equal(-1, arrList.IndexOf(50, 0, arrList.Count)); Assert.Equal(-1, arrList.IndexOf(0, 1, arrList.Count - 1)); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { plcOther.Controls.Clear(); if (AuthenticationHelper.IsAuthenticated()) { // Set the layout of tab menu tabMenu.TabControlLayout = BasicTabControl.GetTabMenuLayout(TabControlLayout); // Remove 'saved' parameter from query string string absoluteUri = URLHelper.RemoveParameterFromUrl(RequestContext.CurrentURL, "saved"); var currentUser = MembershipContext.AuthenticatedUser; // Get customer info GeneralizedInfo customer = null; int customerId = 0; var emptyCustomer = ModuleManager.GetReadOnlyObject(PredefinedObjectType.CUSTOMER); if (emptyCustomer != null) { var q = emptyCustomer.Generalized.GetDataQuery( true, s => s .WhereEquals("CustomerUserID", currentUser.UserID) .OrderBy("CustomerCreated") .TopN(1), false ); var result = q.Result; if (!DataHelper.DataSourceIsEmpty(result)) { customer = ModuleManager.GetObject(result.Tables[0].Rows[0], PredefinedObjectType.CUSTOMER); customerId = customer.ObjectID; } } // Get friends enabled setting bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(SiteContext.CurrentSiteName); // Selected page URL string selectedPage = string.Empty; // Menu initialization tabMenu.UrlTarget = "_self"; ArrayList activeTabs = new ArrayList(); // Handle 'Notifications' tab displaying bool showNotificationsTab = (DisplayMyNotifications && LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.Notifications, ModuleName.NOTIFICATIONS)); bool isWindowsAuthentication = RequestHelper.IsWindowsAuthentication(); string tabName; // Personal tab if (DisplayMyPersonalSettings) { tabName = personalTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyPersonalSettings"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, personalTab) }); if (currentUser != null) { selectedPage = tabName; } } // These items can be displayed only for customer if ((customer != null) && ModuleEntryManager.IsModuleLoaded(ModuleName.ECOMMERCE)) { if (DisplayMyDetails) { // Try to load the control dynamically (if available) ucMyDetails = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyDetails.ascx") as CMSAdminControl; if (ucMyDetails != null) { ucMyDetails.ID = "ucMyDetails"; plcOther.Controls.Add(ucMyDetails); // Set new tab tabName = detailsTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyDetails"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, detailsTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyAddresses) { // Try to load the control dynamically (if available) ucMyAddresses = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyAddresses.ascx") as CMSAdminControl; if (ucMyAddresses != null) { ucMyAddresses.ID = "ucMyAddresses"; plcOther.Controls.Add(ucMyAddresses); // Set new tab tabName = addressesTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyAddresses"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, addressesTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyOrders) { // Try to load the control dynamically (if available) ucMyOrders = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyOrders.ascx") as CMSAdminControl; if (ucMyOrders != null) { ucMyOrders.ID = "ucMyOrders"; plcOther.Controls.Add(ucMyOrders); // Set new tab tabName = ordersTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyOrders"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, ordersTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyCredits) { // Try to load the control dynamically (if available) ucMyCredit = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyCredit.ascx") as CMSAdminControl; if (ucMyCredit != null) { ucMyCredit.ID = "ucMyCredit"; plcOther.Controls.Add(ucMyCredit); // Set new tab tabName = creditTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyCredit"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, creditTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } } if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication) { // Set new tab tabName = passwordTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.ChangePassword"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, passwordTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } if ((ucMyNotifications == null) && showNotificationsTab) { // Try to load the control dynamically (if available) ucMyNotifications = Page.LoadUserControl("~/CMSModules/Notifications/Controls/UserNotifications.ascx") as CMSAdminControl; if (ucMyNotifications != null) { ucMyNotifications.ID = "ucMyNotifications"; plcOther.Controls.Add(ucMyNotifications); // Set new tab tabName = notificationsTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyNotifications"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, notificationsTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyMessages == null) && DisplayMyMessages && ModuleManager.IsModuleLoaded(ModuleName.MESSAGING)) { // Try to load the control dynamically (if available) ucMyMessages = Page.LoadUserControl("~/CMSModules/Messaging/Controls/MyMessages.ascx") as CMSAdminControl; if (ucMyMessages != null) { ucMyMessages.ID = "ucMyMessages"; plcOther.Controls.Add(ucMyMessages); // Set new tab tabName = messagesTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyMessages"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, messagesTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyFriends == null) && DisplayMyFriends && ModuleManager.IsModuleLoaded(ModuleName.COMMUNITY) && friendsEnabled) { // Try to load the control dynamically (if available) ucMyFriends = Page.LoadUserControl("~/CMSModules/Friends/Controls/MyFriends.ascx") as CMSAdminControl; if (ucMyFriends != null) { ucMyFriends.ID = "ucMyFriends"; plcOther.Controls.Add(ucMyFriends); // Set new tab tabName = friendsTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyFriends"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, friendsTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyAllSubscriptions == null) && DisplayMySubscriptions) { // Try to load the control dynamically (if available) ucMyAllSubscriptions = Page.LoadUserControl("~/CMSModules/Membership/Controls/Subscriptions.ascx") as CMSAdminControl; if (ucMyAllSubscriptions != null) { // Set control ucMyAllSubscriptions.Visible = false; ucMyAllSubscriptions.SetValue("ShowBlogs", DisplayBlogs); ucMyAllSubscriptions.SetValue("ShowMessageBoards", DisplayMessageBoards); ucMyAllSubscriptions.SetValue("ShowNewsletters", DisplayNewsletters); ucMyAllSubscriptions.SetValue("ShowForums", DisplayForums); ucMyAllSubscriptions.SetValue("ShowReports", DisplayReports); ucMyAllSubscriptions.SetValue("sendconfirmationemail", SendConfirmationEmails); ucMyAllSubscriptions.ID = "ucMyAllSubscriptions"; plcOther.Controls.Add(ucMyAllSubscriptions); // Set new tab tabName = subscriptionsTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyAllSubscriptions"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, subscriptionsTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } // My memberships if ((ucMyMemberships == null) && DisplayMyMemberships) { // Try to load the control dynamically ucMyMemberships = Page.LoadUserControl("~/CMSModules/Membership/Controls/MyMemberships.ascx") as CMSAdminControl; if (ucMyMemberships != null) { ucMyMemberships.SetValue("UserID", currentUser.UserID); if (!String.IsNullOrEmpty(MembershipsPagePath)) { ucMyMemberships.SetValue("BuyMembershipURL", DocumentURLProvider.GetUrl(MembershipsPagePath)); } plcOther.Controls.Add(ucMyMemberships); // Set new tab tabName = membershipsTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("myaccount.mymemberships"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, membershipsTab) }); if (selectedPage == String.Empty) { selectedPage = tabName; } } } if ((ucMyCategories == null) && DisplayMyCategories) { // Try to load the control dynamically (if available) ucMyCategories = Page.LoadUserControl("~/CMSModules/Categories/Controls/Categories.ascx") as CMSAdminControl; if (ucMyCategories != null) { ucMyCategories.Visible = false; ucMyCategories.SetValue("DisplaySiteCategories", false); ucMyCategories.SetValue("DisplaySiteSelector", false); ucMyCategories.ID = "ucMyCategories"; plcOther.Controls.Add(ucMyCategories); // Set new tab tabName = categoriesTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyCategories"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, categoriesTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } // Set CSS class pnlBody.CssClass = CssClass; // Get page URL page = QueryHelper.GetString(ParameterName, selectedPage); // Set controls visibility ucChangePassword.Visible = false; ucChangePassword.StopProcessing = true; if (ucMyAddresses != null) { ucMyAddresses.Visible = false; ucMyAddresses.StopProcessing = true; } if (ucMyOrders != null) { ucMyOrders.Visible = false; ucMyOrders.StopProcessing = true; } if (ucMyDetails != null) { ucMyDetails.Visible = false; ucMyDetails.StopProcessing = true; } if (ucMyCredit != null) { ucMyCredit.Visible = false; ucMyCredit.StopProcessing = true; } if (ucMyAllSubscriptions != null) { ucMyAllSubscriptions.Visible = false; ucMyAllSubscriptions.StopProcessing = true; ucMyAllSubscriptions.SetValue("CacheMinutes", CacheMinutes); } if (ucMyNotifications != null) { ucMyNotifications.Visible = false; ucMyNotifications.StopProcessing = true; } if (ucMyMessages != null) { ucMyMessages.Visible = false; ucMyMessages.StopProcessing = true; } if (ucMyFriends != null) { ucMyFriends.Visible = false; ucMyFriends.StopProcessing = true; } if (ucMyMemberships != null) { ucMyMemberships.Visible = false; ucMyMemberships.StopProcessing = true; } if (ucMyCategories != null) { ucMyCategories.Visible = false; ucMyCategories.StopProcessing = true; } tabMenu.SelectedTab = activeTabs.IndexOf(page); // Select current page switch (page) { case personalTab: if (myProfile != null) { // Get alternative form info AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeFormName); if (afi != null) { myProfile.StopProcessing = false; myProfile.Visible = true; myProfile.AllowEditVisibility = AllowEditVisibility; myProfile.AlternativeFormName = AlternativeFormName; } else { lblError.Text = String.Format(GetString("altform.formdoesntexists"), AlternativeFormName); lblError.Visible = true; myProfile.Visible = false; } } break; // My details tab case detailsTab: if (ucMyDetails != null) { ucMyDetails.Visible = true; ucMyDetails.StopProcessing = false; ucMyDetails.SetValue("Customer", customer); } break; // My addresses tab case addressesTab: if (ucMyAddresses != null) { ucMyAddresses.Visible = true; ucMyAddresses.StopProcessing = false; ucMyAddresses.SetValue("CustomerId", customerId); } break; // My orders tab case ordersTab: if (ucMyOrders != null) { ucMyOrders.Visible = true; ucMyOrders.StopProcessing = false; ucMyOrders.SetValue("CustomerId", customerId); ucMyOrders.SetValue("ShowOrderTrackingNumber", ShowOrderTrackingNumber); ucMyOrders.SetValue("ShowOrderToShoppingCart", ShowOrderToShoppingCart); } break; // My credit tab case creditTab: if (ucMyCredit != null) { ucMyCredit.Visible = true; ucMyCredit.StopProcessing = false; ucMyCredit.SetValue("CustomerId", customerId); } break; // Password tab case passwordTab: ucChangePassword.Visible = true; ucChangePassword.StopProcessing = false; ucChangePassword.AllowEmptyPassword = AllowEmptyPassword; break; // Notification tab case notificationsTab: if (ucMyNotifications != null) { ucMyNotifications.Visible = true; ucMyNotifications.StopProcessing = false; ucMyNotifications.SetValue("UserId", currentUser.UserID); ucMyNotifications.SetValue("UnigridImageDirectory", UnigridImageDirectory); } break; // My messages tab case messagesTab: if (ucMyMessages != null) { ucMyMessages.Visible = true; ucMyMessages.StopProcessing = false; } break; // My friends tab case friendsTab: if (ucMyFriends != null) { ucMyFriends.Visible = true; ucMyFriends.StopProcessing = false; ucMyFriends.SetValue("UserID", currentUser.UserID); } break; // My subscriptions tab case subscriptionsTab: if (ucMyAllSubscriptions != null) { ucMyAllSubscriptions.Visible = true; ucMyAllSubscriptions.StopProcessing = false; ucMyAllSubscriptions.SetValue("userid", currentUser.UserID); ucMyAllSubscriptions.SetValue("siteid", SiteContext.CurrentSiteID); } break; // My memberships tab case membershipsTab: if (ucMyMemberships != null) { ucMyMemberships.Visible = true; ucMyMemberships.StopProcessing = false; } break; // My categories tab case categoriesTab: if (ucMyCategories != null) { ucMyCategories.Visible = true; ucMyCategories.StopProcessing = false; } break; } } else { // Hide control if current user is not authenticated Visible = false; } } }
// </PrintNonRecursive> private void PopulateTreeView() { // Add students to the ArrayList of Student objects. for (int x = 0; x < 5; x++) { studentArray.Add(new Student("Student " + x.ToString())); } // Add subjects to each Student object in the ArrayList. foreach (Student student in studentArray) { for (int y = 0; y < 10; y++) { student.StudentSubjects.Add(new Subject("Subject " + y.ToString())); } } Random _random = new Random(); // Add subjects to each Student object in the ArrayList. foreach (Student student in studentArray) { foreach (Subject subject in student.StudentSubjects) { var gen = _random.Next(1, 10); for (int y = 0; y < gen; y++) { subject.SubjectTextbooks.Add(new TextBook("TextBook " + y.ToString())); } } } // Suppress repainting the TreeView until all the objects have been created. trvTest.BeginUpdate(); // Clear the TreeView each time the method is called. trvTest.Nodes.Clear(); // Add a root TreeNode for each Student object in the ArrayList. foreach (Student student in studentArray) { trvTest.Nodes.Add(new TreeNode(student.StudentName)); // Add a child treenode for each Subject object in the current student object. foreach (Subject subject in student.StudentSubjects) { trvTest.Nodes[studentArray.IndexOf(student)].Nodes.Add( new TreeNode(subject.SubjectID)); // Add a child treenode for each TextBook object in the current Subject object. foreach (TextBook textbook in subject.SubjectTextbooks) { trvTest.Nodes[studentArray.IndexOf(student)].Nodes[student.StudentSubjects.IndexOf(subject)].Nodes.Add( new TreeNode(textbook.TextBookID)); } } } // Begin repainting the TreeView. trvTest.EndUpdate(); }
private void CompareObjects(ArrayList good, ArrayList bad, Hashtable hsh1) { //IList, this includes ICollection tests as well!! DoIListTests(good, bad, hsh1); //we will now test ArrayList specific methods good.Clear(); for (int i = 0; i < 100; i++) good.Add(i); //AL's CopyTo methods int[] iArr1 = null; int[] iArr2 = null; iArr1 = new int[100]; iArr2 = new int[100]; good.CopyTo(iArr1); bad.CopyTo(iArr2); for (int i = 0; i < 100; i++) { if (iArr1[i] != iArr2[i]) hsh1["CopyTo"] = "()"; } iArr1 = new int[100]; iArr2 = new int[100]; good.CopyTo(0, iArr1, 0, 100); try { bad.CopyTo(0, iArr2, 0, 100); for (int i = 0; i < 100; i++) { if (iArr1[i] != iArr2[i]) hsh1["CopyTo"] = "()"; } } catch { hsh1["CopyTo"] = "(int, Array, int, int)"; } iArr1 = new int[200]; iArr2 = new int[200]; for (int i = 0; i < 200; i++) { iArr1[i] = 50; iArr2[i] = 50; } good.CopyTo(50, iArr1, 100, 20); try { bad.CopyTo(50, iArr2, 100, 20); for (int i = 0; i < 200; i++) { if (iArr1[i] != iArr2[i]) hsh1["CopyTo"] = "(Array, int, int)"; } } catch { hsh1["CopyTo"] = "(int, Array, int, int)"; } //Clone() ArrayList alstClone = (ArrayList)bad.Clone(); //lets make sure that the clone is what it says it is if (alstClone.Count != bad.Count) hsh1["Clone"] = "Count"; for (int i = 0; i < bad.Count; i++) { if (alstClone[i] != bad[i]) hsh1["Clone"] = "[]"; } //GerEnumerator() IEnumerator ienm1 = null; IEnumerator ienm2 = null; ienm1 = good.GetEnumerator(0, 100); try { ienm2 = bad.GetEnumerator(0, 100); DoIEnumerableTest(ienm1, ienm2, good, bad, hsh1, false); } catch { hsh1["GetEnumerator"] = "(int, int)"; } ienm1 = good.GetEnumerator(50, 50); try { ienm2 = bad.GetEnumerator(50, 50); DoIEnumerableTest(ienm1, ienm2, good, bad, hsh1, false); } catch { hsh1["GetEnumerator"] = "(int, int)"; } try { bad.GetEnumerator(50, 150); hsh1["GetEnumerator"] = "(int, int)"; } catch (Exception) { } ienm1 = good.GetEnumerator(0, 100); try { ienm2 = bad.GetEnumerator(0, 100); good.RemoveAt(0); DoIEnumerableTest(ienm1, ienm2, good, bad, hsh1, true); } catch { hsh1["GetEnumerator"] = "(int, int)"; } //GetRange good.Clear(); for (int i = 0; i < 100; i++) good.Add(i); ArrayList alst1 = good.GetRange(0, good.Count); try { ArrayList alst2 = bad.GetRange(0, good.Count); for (int i = 0; i < good.Count; i++) { if (alst1[i] != alst2[i]) hsh1["GetRange"] = i; } } catch { hsh1["Range"] = "(int, int)"; } //IndexOf(Object, int) if (bad.Count > 0) { for (int i = 0; i < good.Count; i++) { if (good.IndexOf(good[i], 0) != bad.IndexOf(good[i], 0)) { hsh1["IndexOf"] = "(Object, int)"; } if (good.IndexOf(good[i], i) != bad.IndexOf(good[i], i)) { hsh1["IndexOf"] = "(Object, int)"; } if (i < (good.Count - 1)) { if (good.IndexOf(good[i], i + 1) != bad.IndexOf(good[i], i + 1)) { hsh1["IndexOf"] = "(Object, int)"; } } } try { bad.IndexOf(1, -1); } catch (ArgumentException) { } catch (Exception ex) { hsh1["IndexOf"] = ex; } try { bad.IndexOf(1, bad.Count); } catch (ArgumentException) { } catch (Exception ex) { hsh1["IndexOf"] = ex; } // IndexOf(Object, int, int) // The semantics of this method has changed, the 3rd parameter now refers to count instead of length for (int i = 0; i < good.Count; i++) { if (good.IndexOf(good[i], 0, good.Count - 1) != bad.IndexOf(good[i], 0, good.Count - 1)) { hsh1["IndexOf"] = "(Object, int, int)"; } if (good.IndexOf(good[i], i, good.Count - i) != bad.IndexOf(good[i], i, good.Count - i)) { hsh1["IndexOf"] = "(Object, int)"; } if (good.IndexOf(good[i], i, 0) != bad.IndexOf(good[i], i, 0)) { hsh1["IndexOf"] = "(Object, int)"; } if (i < (good.Count - 1)) { if (good.IndexOf(good[i], i + 1, good.Count - (i + 1)) != bad.IndexOf(good[i], i + 1, good.Count - (i + 1))) { hsh1["IndexOf"] = "(Object, int)"; } } } try { bad.IndexOf(1, 0, -1); } catch (ArgumentException) { } catch (Exception ex) { hsh1["IndexOf"] = ex; } try { bad.IndexOf(1, 0, bad.Count); } catch (ArgumentException) { } catch (Exception ex) { hsh1["IndexOf"] = ex; } try { bad.IndexOf(1, bad.Count - 1, bad.Count - 2); } catch (ArgumentException) { } catch (Exception ex) { hsh1["IndexOf"] = ex; } //LastIndexOf(Object) for (int i = 0; i < good.Count; i++) { if (good.LastIndexOf(good[i]) != bad.LastIndexOf(good[i])) { hsh1["LastIndexOf"] = "(Object)"; } if (good.LastIndexOf(i + 1000) != bad.LastIndexOf(i + 1000)) { hsh1["LastIndexOf"] = "(Object)"; } } try { bad.LastIndexOf(null); } catch (ArgumentException) { } catch (Exception ex) { hsh1["LastIndexOf"] = ex; } //LastIndexOf(Object, int) for (int i = 0; i < good.Count; i++) { if (good.LastIndexOf(good[i], good.Count - 1) != bad.LastIndexOf(good[i], good.Count - 1)) { hsh1["LastIndexOf"] = "(Object, int)"; } if (good.LastIndexOf(good[i], 0) != bad.LastIndexOf(good[i], 0)) { hsh1["LastIndexOf"] = "(Object, int)"; } if (good.LastIndexOf(good[i], i) != bad.LastIndexOf(good[i], i)) { hsh1["LastIndexOf"] = "(Object, int)"; } if (i < (good.Count - 1)) { if (good.LastIndexOf(good[i], i + 1) != bad.LastIndexOf(good[i], i + 1)) { hsh1["LastIndexOf"] = "(Object, int)"; } } } try { bad.LastIndexOf(1, -1); } catch (ArgumentException) { } catch (Exception ex) { hsh1["LastIndexOf"] = ex; } try { bad.LastIndexOf(1, bad.Count); } catch (ArgumentException) { } catch (Exception ex) { hsh1["LastIndexOf"] = ex; } //LastIndexOf(Object, int, int) for (int i = 0; i < good.Count; i++) { if (good.LastIndexOf(good[i], good.Count - 1, 0) != bad.LastIndexOf(good[i], good.Count - 1, 0)) { hsh1["LastIndexOf"] = "(Object, int, int)"; } if (good.LastIndexOf(good[i], good.Count - 1, i) != bad.LastIndexOf(good[i], good.Count - 1, i)) { hsh1["LastIndexOf"] = "(Object, int)"; } if (good.LastIndexOf(good[i], i, i) != bad.LastIndexOf(good[i], i, i)) { hsh1["LastIndexOf"] = "(Object, int)"; } if (i < (good.Count - 1)) { if (good.LastIndexOf(good[i], good.Count - 1, i + 1) != bad.LastIndexOf(good[i], good.Count - 1, i + 1)) { hsh1["LastIndexOf"] = "(Object, int)"; } } } try { bad.LastIndexOf(1, 1, -1); } catch (ArgumentException) { } catch (Exception ex) { hsh1["LastIndexOf"] = ex; } try { bad.LastIndexOf(1, bad.Count - 2, bad.Count - 1); } catch (ArgumentException) { } catch (Exception ex) { hsh1["LastIndexOf"] = ex; } } //ReadOnly() ArrayList alst3 = ArrayList.ReadOnly(bad); if (!alst3.IsReadOnly) hsh1["ReadOnly"] = "Not"; IList ilst1 = ArrayList.ReadOnly((IList)bad); if (!ilst1.IsReadOnly) hsh1["ReadOnly"] = "Not"; //Synchronized() alst3 = ArrayList.Synchronized(bad); if (!alst3.IsSynchronized) hsh1["Synchronized"] = "Not"; ilst1 = ArrayList.Synchronized((IList)bad); if (!ilst1.IsSynchronized) hsh1["Synchronized"] = "Not"; //ToArray() if (good.Count == bad.Count) { object[] oArr1 = good.ToArray(); object[] oArr2 = bad.ToArray(); for (int i = 0; i < good.Count; i++) { if ((int)oArr1[i] != (int)oArr2[i]) hsh1["ToArray"] = "()"; } //ToArray(type) iArr1 = (int[])good.ToArray(typeof(int)); iArr2 = (int[])bad.ToArray(typeof(int)); for (int i = 0; i < good.Count; i++) { if (iArr1[i] != iArr2[i]) hsh1["ToArray"] = "(Type)"; } } //Capacity - get if (good.Capacity != bad.Capacity) { hsh1["Capacity"] = "get"; } //Fixed size methods if (!hsh1.ContainsKey("IsReadOnly")) { good.Clear(); for (int i = 100; i > 0; i--) good.Add(i); //Sort() & BinarySearch(Object) bad.Sort(); for (int i = 0; i < bad.Count - 1; i++) { if ((int)bad[i] > (int)bad[i + 1]) hsh1["Sort"] = "()"; } for (int i = 0; i < bad.Count; i++) { if (bad.BinarySearch(bad[i]) != i) hsh1["BinarySearch"] = "(Object)"; } //Reverse() bad.Reverse(); if (bad.Count > 0) { for (int i = 0; i < 99; i++) { if ((int)bad[i] < (int)bad[i + 1]) hsh1["Reverse"] = "()"; } good.Clear(); for (int i = 100; i > 0; i--) good.Add(i.ToString()); } good.Clear(); for (int i = 90; i > 64; i--) good.Add(((Char)i).ToString()); try { bad.Sort(new CaseInsensitiveComparer()); if (bad.Count > 0) { for (int i = 0; i < (bad.Count - 1); i++) { if (((String)bad[i]).CompareTo(((String)bad[i + 1])) >= 0) hsh1["Sort"] = "(IComparer)"; } for (int i = 0; i < bad.Count; i++) { if (bad.BinarySearch(bad[i], new CaseInsensitiveComparer()) != i) hsh1["BinarySearch"] = "(Object, IComparer)"; } } bad.Reverse(); good.Clear(); for (int i = 65; i < 91; i++) good.Add(((Char)i).ToString()); if (bad.Count > 0) { for (int i = 0; i < good.Count; i++) { if (bad.BinarySearch(0, bad.Count, bad[i], new CaseInsensitiveComparer()) != i) hsh1["BinarySearch"] = "(int, int, Object, IComparer)"; } } } catch (Exception) { } good.Clear(); for (int i = 0; i < 100; i++) good.Add(i); Queue que = new Queue(); for (int i = 0; i < 100; i++) que.Enqueue(i + 5000); try { bad.SetRange(0, que); } catch (Exception ex) { hsh1["SetRange"] = "Copy_ExceptionType, " + ex.GetType().Name; } for (int i = bad.Count; i < bad.Count; i++) { if ((int)bad[i] != (i + 5000)) { hsh1["SetRange"] = i; } } } else { //we make sure that the above methods throw here good.Clear(); for (int i = 100; i > 0; i--) good.Add(i); try { bad.Sort(); hsh1["Sort"] = "Copy"; } catch (NotSupportedException) { } catch (Exception) { hsh1["Sort"] = "Copy_ExceptionType"; } try { bad.Reverse(); hsh1["Reverse"] = "Copy"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["Reverse"] = "Copy_ExceptionType, " + ex.GetType().Name; } try { bad.Sort(new CaseInsensitiveComparer()); hsh1["Sort"] = "Copy - Icomparer"; } catch (NotSupportedException) { } catch (Exception) { hsh1["Sort"] = "Copy_ExceptionType"; } try { bad.Sort(0, 0, new CaseInsensitiveComparer()); hsh1["Sort"] = "Copy - int, int, IComparer"; } catch (NotSupportedException) { } catch (Exception) { hsh1["Sort"] = "Copy_ExceptionType"; } //BinarySearch try { for (int i = 0; i < bad.Count; i++) { if (bad.BinarySearch(bad[i]) != i) hsh1["BinarySearch"] = "(Object)"; } hsh1["BinarySearch"] = "(Object)"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["BinarySearch"] = ex.GetType().Name; } try { for (int i = 0; i < bad.Count; i++) { if (bad.BinarySearch(bad[i], new CaseInsensitiveComparer()) != i) hsh1["BinarySearch"] = "(Object)"; } hsh1["BinarySearch"] = "Exception not thrown, (Object, IComparer)"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["BinarySearch"] = ex.GetType().Name; } try { for (int i = 0; i < bad.Count; i++) { if (bad.BinarySearch(0, bad.Count, bad[i], new CaseInsensitiveComparer()) != i) hsh1["BinarySearch"] = "(Object)"; } hsh1["BinarySearch"] = "Exception not thrown, (Object, IComparer)"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["BinarySearch"] = ex.GetType().Name; } good.Clear(); for (int i = 0; i < 100; i++) good.Add(i); Queue que = new Queue(); for (int i = 0; i < 100; i++) que.Enqueue(i + 5000); try { bad.SetRange(0, que); hsh1["Sort"] = "Copy - int, int, IComparer"; } catch (NotSupportedException) { } catch (Exception) { hsh1["Sort"] = "Copy_ExceptionType"; } } //Modifiable methods if (!hsh1.ContainsKey("IsReadOnly") && !hsh1.ContainsKey("Fixed")) { good.Clear(); for (int i = 0; i < 100; i++) good.Add(i); Queue que = new Queue(); for (int i = 0; i < 100; i++) que.Enqueue(i + 5000); bad.InsertRange(0, que); for (int i = 0; i < 100; i++) { if ((int)bad[i] != i + 5000) { hsh1["InsertRange"] = i; } } //AddRange() que = new Queue(); for (int i = 0; i < 100; i++) que.Enqueue(i + 2222); bad.AddRange(que); for (int i = bad.Count - 100; i < bad.Count; i++) { if ((int)bad[i] != (i - (bad.Count - 100)) + 2222) { hsh1["AddRange"] = i + " " + (int)bad[i]; } } bad.RemoveRange(0, que.Count); for (int i = 0; i < 100; i++) { if ((int)bad[i] != i) { hsh1["RemoveRange"] = i + " " + (int)bad[i]; } } //Capacity try { bad.Capacity = bad.Capacity * 2; } catch (Exception ex) { hsh1["Capacity"] = ex.GetType().Name; } try { bad.Capacity = -1; hsh1["Capacity"] = "No_Exception_Thrown, -1"; } catch (ArgumentException) { } catch (Exception ex) { hsh1["Capacity"] = ex.GetType().Name; } int iMakeSureThisDoesNotCause = 0; while (bad.Capacity == bad.Count) { if (iMakeSureThisDoesNotCause++ > 100) break; bad.Add(bad.Count); } if (iMakeSureThisDoesNotCause > 100) hsh1["TrimToSize"] = "Monekeyed, " + bad.Count + " " + bad.Capacity; //TrimToSize() try { bad.TrimToSize(); if (bad.Capacity != bad.Count) { hsh1["TrimToSize"] = "Problems baby"; } } catch (Exception ex) { hsh1["TrimToSize"] = ex.GetType().Name; } } else { Queue que = new Queue(); for (int i = 0; i < 100; i++) que.Enqueue(i + 5000); try { bad.AddRange(que); hsh1["AddRange"] = "Copy"; } catch (NotSupportedException) { } catch (Exception) { hsh1["AddRange"] = "Copy_ExceptionType"; } try { bad.InsertRange(0, que); hsh1["InsertRange"] = "Copy"; } catch (NotSupportedException) { } catch (Exception) { hsh1["InsertRange"] = "Copy_ExceptionType"; } good.Clear(); for (int i = 0; i < 10; i++) good.Add(i); try { bad.RemoveRange(0, 10); hsh1["RemoveRange"] = "Copy"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["RemoveRange"] = "Copy_ExceptionType, " + ex.GetType().Name; } try { bad.Capacity = bad.Capacity * 2; hsh1["Capacity"] = "No_Exception_Thrown, bad.Capacity*2"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["Capacity"] = ex.GetType().Name; } try { bad.TrimToSize(); hsh1["TrimToSize"] = "No_Exception_Thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["TrimToSize"] = ex.GetType().Name; } } }
/// <summary> /// populate search ui with given media /// </summary> /// <param name="value"></param> private void populateForm(ArrayList mediaArray, DataView availableCategories, ArrayList availableMediaCategories) { try { ArrayList categories = new ArrayList(); ArrayList mediaCategories = new ArrayList(); Media newMedia = new Media(); foreach (Media media in mediaArray) { if (txtTitleResult.Text.Trim().Length == 0 && mediaArray.IndexOf(media) != mediaArray.Count - 1) { txtTitleResult.Text = media.Title; } else if (txtTitleResult.Text.Trim().ToLower() != media.Title.Trim().ToLower()) { txtTitleResult.Text = ""; } if (txtDirectorResult.Text.Trim().Length == 0 && mediaArray.IndexOf(media) != mediaArray.Count - 1) { txtDirectorResult.Text = media.Director; } else if (txtDirectorResult.Text.Trim().ToLower() != media.Director.Trim().ToLower()) { txtDirectorResult.Text = ""; } string[] catArray; if (media.category.Contains("/")) { catArray = media.category.Split('/'); } else { catArray = media.category.Split('|'); } string[] medCatArray; if (media.MediaType.Contains("/")) { medCatArray = media.MediaType.Split('/'); } else { medCatArray = media.MediaType.Split('|'); } foreach (DataRowView drv in availableCategories) { string catString = drv["category"].ToString(); string[] tempCatArray; if (catString.Contains("/")) { tempCatArray = catString.Split('/'); } else { tempCatArray = catString.Split('|'); } foreach (string cat in tempCatArray) { if (!categories.Contains(cat.Trim()) && cat.Trim().Length > 0) { categories.Add(cat.Trim()); } } } //add current categories foreach (string category in catArray) { if (category.Trim().Length > 0 && !lbCurrentGenres.Items.Contains(category)) { lbCurrentGenres.Items.Add(category.Trim()); } if (categories.Contains(category.Trim())) { categories.Remove(category.Trim()); } } categories.TrimToSize(); //add available categories foreach (string category in categories) { if (!lbAvailableGenres.Items.Contains(category.Trim())) { lbAvailableGenres.Items.Add(category.Trim()); } } foreach (string catString in availableMediaCategories) { //check for both "/" and "|" string[] tempCatArray; if (catString.Contains("/")) { tempCatArray = catString.Split('/'); } else { tempCatArray = catString.Split('|'); } foreach (string cat in tempCatArray) { if (!mediaCategories.Contains(cat.Trim()) && cat.Trim().Length > 0) { mediaCategories.Add(cat.Trim()); } } } //add current mediaCategories foreach (string category in medCatArray) { if (category.Trim().Length > 0 && !lbSelectedCategories.Items.Contains(category)) { lbSelectedCategories.Items.Add(category.Trim()); } if (mediaCategories.Contains(category.Trim())) { mediaCategories.Remove(category.Trim()); } } mediaCategories.TrimToSize(); //add available mediaCategories foreach (string category in mediaCategories) { if (!lbAvailableCategories.Items.Contains(category.Trim())) { lbAvailableCategories.Items.Add(category.Trim()); } } if (txtReleaseYearResult.Text.Trim().Length == 0 && mediaArray.IndexOf(media) != mediaArray.Count - 1) { txtReleaseYearResult.Text = media.ReleaseYear; } else if (txtReleaseYearResult.Text.Trim().ToLower() != media.ReleaseYear.Trim().ToLower()) { txtReleaseYearResult.Text = ""; } if (txtTaglineResult.Text.Trim().Length == 0 && mediaArray.IndexOf(media) != mediaArray.Count - 1) { txtTaglineResult.Text = media.Description; } else if (txtTaglineResult.Text.Trim().ToLower() != media.Description.Trim().ToLower()) { txtTaglineResult.Text = ""; } if (txtImdbNumResult.Text.Trim().Length == 0 && mediaArray.IndexOf(media) != mediaArray.Count - 1) { txtImdbNumResult.Text = media.IMDBNum; } else if (txtImdbNumResult.Text.Trim().ToLower() != media.IMDBNum.Trim().ToLower()) { txtImdbNumResult.Text = ""; } if (txtRatingResult.Text.Trim().Length == 0 && mediaArray.IndexOf(media) != mediaArray.Count - 1) { txtRatingResult.Text = media.Rating; } else if (txtRatingResult.Text.Trim().ToLower() != media.Rating.Trim().ToLower()) { txtRatingResult.Text = ""; } if (txtRatingReasonResult.Text.Trim().Length == 0 && mediaArray.IndexOf(media) != mediaArray.Count - 1) { txtRatingReasonResult.Text = media.RatingDescription; } else if (txtRatingReasonResult.Text.Trim().ToLower() != media.RatingDescription.Trim().ToLower()) { txtRatingReasonResult.Text = ""; } //if (System.IO.File.Exists(media.coverImage)) // thumbnailPictureBox.ImageLocation = media.coverImage; //else // thumbnailPictureBox.ImageLocation = Application.StartupPath + "//images//media//coverimages//notavailable.jpg"; //add filepaths //string[] filePaths; //if (media.filePath != null && media.filePath.Contains("|")) // filePaths = media.filePath.Split('|'); //else //{ // filePaths = new string[1]; // filePaths[0] = media.filePath; //} //foreach (string filepath in filePaths) //{ // if (!lbFiles.Items.Contains(filepath)) // lbFiles.Items.Add(filepath.Trim()); //} //add description txtDescription.Text = media.Description; txtShortDescription.Text = media.ShortDescription; txtCoverImage.Text = media.coverImage; txtGoofs.Text = media.Goofs; txtTrivia.Text = media.Trivia; txtPerformers.Text = media.Performers; } //enable/disable controls txtDirectorResult.ReadOnly = readOnly; txtImdbNumResult.ReadOnly = readOnly; txtRatingReasonResult.ReadOnly = readOnly; txtRatingResult.ReadOnly = readOnly; txtReleaseYearResult.ReadOnly = readOnly; txtTaglineResult.ReadOnly = readOnly; txtTitleResult.ReadOnly = readOnly; txtPerformers.ReadOnly = readOnly; btnAddCategory.Enabled = !readOnly; btnAddGenre.Enabled = !readOnly; btnAddNewCategory.Enabled = !readOnly; btnAddNewGenre.Enabled = !readOnly; btnRemoveCategory.Enabled = !readOnly; btnRemoveGenre.Enabled = !readOnly; } catch (Exception ex) { Tools.WriteToFile(ex); } }
private Boolean runTest() { Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; ArrayList alst = null; ArrayList tst = null; IList ilst1 = null; IList ilst2 = null; String strLoc = null; Hashtable hsh1 = null; IDictionaryEnumerator idic = null; try { strLoc = "Loc_04872dsf"; iCountTestcases++; alst = new ArrayList(); tst = ArrayList.Adapter(alst); hsh1 = new Hashtable(); CompareObjects(alst, tst, hsh1); iCountTestcases++; if(hsh1.Count>2 || ((String)hsh1["Capacity"] != "get") || ((String)hsh1["TrimToSize"] != "Monekeyed, 301 301") ) { iCountErrors++; Console.WriteLine("Err_742dsf! Adapter"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<" + idic.Key + "><" + idic.Value + ">"); } } strLoc = "Loc_210742wdsfg"; iCountTestcases++; alst = new ArrayList(); for(int i=0; i<100;i++) alst.Add(i); tst = ArrayList.Adapter(alst); hsh1 = new Hashtable(); CompareObjects(alst, tst, hsh1); if(hsh1.Count>2 || ((String)hsh1["Capacity"] != "get") || ((String)hsh1["TrimToSize"] != "Monekeyed, 301 301") ) { iCountErrors++; Console.WriteLine("Err_75629ewf! Adapter"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_6927csf"; iCountTestcases++; alst = new ArrayList(); tst = ArrayList.FixedSize(alst); hsh1 = new Hashtable(); CompareObjects(alst, tst, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("Fixed")) { iCountErrors++; Console.WriteLine("Err_0371dsf! Adapter"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_79231"; alst = new ArrayList(); for(int i=0; i<100;i++) alst.Add(i); tst = ArrayList.FixedSize(alst); hsh1 = new Hashtable(); CompareObjects(alst, tst, hsh1); iCountTestcases++; if(hsh1.Count>1 || !hsh1.ContainsKey("Fixed")) { iCountErrors++; Console.WriteLine("Err_8427efs! Adapter"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_6792dsf"; iCountTestcases++; ilst1 = new ArrayList(); ilst2 = ArrayList.FixedSize(ilst1); hsh1 = new Hashtable(); DoIListTests(ilst1, ilst2, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("Fixed")) { iCountErrors++; Console.WriteLine("Err_127we! FixedSize, IList"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_7432adf"; ilst1 = new ArrayList(); for(int i=0; i<100; i++) { ilst1.Add(i); } ilst2 = ArrayList.FixedSize(ilst1); hsh1 = new Hashtable(); DoIListTests(ilst1, ilst2, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("Fixed")) { iCountErrors++; Console.WriteLine("Err_67438dsafsf! FixedSize, IList"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_0452fgf"; iCountTestcases++; alst = new ArrayList(); tst = ArrayList.ReadOnly(alst); hsh1 = new Hashtable(); CompareObjects(alst, tst, hsh1); if(hsh1.Count>2 || !hsh1.ContainsKey("IsReadOnly") || ((String)hsh1["BinarySearch"] != "Exception not thrown, (Object, IComparer)") ) { iCountErrors++; Console.WriteLine("Err_752rw342! ReadOnly, ArrayList"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_8342asdf"; iCountTestcases++; alst = new ArrayList(); for(int i=0; i<100;i++) alst.Add(i); tst = ArrayList.ReadOnly(alst); hsh1 = new Hashtable(); CompareObjects(alst, tst, hsh1); if(hsh1.Count>2 || !hsh1.ContainsKey("IsReadOnly") || ((String)hsh1["BinarySearch"] != "Exception not thrown, (Object, IComparer)") ) { iCountErrors++; Console.WriteLine("Err_03482sagfdg! ReadOnly - ArrayList"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_67294sf"; iCountTestcases++; ilst1 = new ArrayList(); ilst2 = ArrayList.ReadOnly(ilst1); hsh1 = new Hashtable(); DoIListTests(ilst1, ilst2, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("IsReadOnly")) { iCountErrors++; Console.WriteLine("Err_9723dvsf! ReadOnly, IList"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_7432adf"; iCountTestcases++; ilst1 = new ArrayList(); for(int i=0; i<100; i++) { ilst1.Add(i); } ilst2 = ArrayList.ReadOnly(ilst1); hsh1 = new Hashtable(); DoIListTests(ilst1, ilst2, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("IsReadOnly")) { iCountErrors++; Console.WriteLine("Err_97213sdfs! ReadOnly, IList"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_945wsd"; iCountTestcases++; alst = new ArrayList(); tst = ArrayList.Synchronized(alst); hsh1 = new Hashtable(); CompareObjects(alst, tst, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("IsSynchronized")) { iCountErrors++; Console.WriteLine("Err_0327sdf! Synchronized, ArrayList"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_8342asdf"; alst = new ArrayList(); for(int i=0; i<100;i++) alst.Add(i); tst = ArrayList.Synchronized(alst); hsh1 = new Hashtable(); CompareObjects(alst, tst, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("IsSynchronized")) { iCountErrors++; Console.WriteLine("Err_2874s! Synchronized, ArrayList"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_307ens"; iCountTestcases++; ilst1 = new ArrayList(); ilst2 = ArrayList.Synchronized(ilst1); hsh1 = new Hashtable(); DoIListTests(ilst1, ilst2, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("IsSynchronized")) { iCountErrors++; Console.WriteLine("Err_735sx! Synchronized, IList"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_7432adf"; ilst1 = new ArrayList(); for(int i=0; i<100; i++) { ilst1.Add(i); } ilst2 = ArrayList.Synchronized(ilst1); hsh1 = new Hashtable(); DoIListTests(ilst1, ilst2, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("IsSynchronized")) { iCountErrors++; Console.WriteLine("Err_9934sds! Synchronized, IList"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_0732fgf"; iCountTestcases++; alst = new ArrayList(); tst = alst.GetRange(0, 0); hsh1 = new Hashtable(); CompareRangeObjects(alst, tst, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("TrimToSize") ) { Console.WriteLine("Err_0784ns! Range"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_045an"; alst = new ArrayList(); for(int i=0; i<100;i++) alst.Add(i); tst = alst.GetRange(0, 100); hsh1 = new Hashtable(); CompareRangeObjects(alst, tst, hsh1); if(hsh1.Count>1 || !hsh1.ContainsKey("TrimToSize") ) { iCountErrors++; Console.WriteLine("Err_297cs! Range"); idic = hsh1.GetEnumerator(); while(idic.MoveNext()) { Console.WriteLine("<<" + idic.Key + " <<" + idic.Value + ">>"); } } strLoc = "Loc_47yv7"; iCountTestcases++; Int16 i16; Int32 i32; Int64 i64; UInt16 ui16; UInt32 ui32; UInt64 ui64; Int32 iValue; Boolean fPass; i16 = 1; i32 = 2; i64 = 3; ui16 = 4; ui32 = 5; ui64 = 6; alst = new ArrayList(); alst.Add(i16); alst.Add(i32); alst.Add(i64); alst.Add(ui16); alst.Add(ui32); alst.Add(ui64); iCountTestcases++; fPass = true; for(int i=0; i<alst.Count; i++) { if(alst.Contains(i) && i!=2) fPass = false; } if(!fPass) { iCountErrors++; Console.WriteLine("Err_7423dsf! Unexpected value returned"); } iCountTestcases++; fPass = true; iValue = 1; for(int i=0; i<alst.Count; i++) { if((alst.IndexOf(i)==-1) && (i==2)) { Console.WriteLine(iValue + " " + i); fPass = false; } if((alst.IndexOf(i)!=-1) && (i!=2)) { Console.WriteLine(iValue + " " + i); fPass = false; } } if(!fPass) { iCountErrors++; Console.WriteLine("Err_7423dsf! Unexpected value returned"); } iCountTestcases++; fPass = true; try { alst.Sort(); fPass = false; } catch(InvalidOperationException) { } catch(Exception ex) { fPass = false; Console.WriteLine(ex); } if(!fPass) { iCountErrors++; Console.WriteLine("Err_7423dsf! Unexpected value returned"); } } catch(Exception ex) { iCountErrors++; Console.WriteLine("Err_3452dfsd! Unexpected exception caught! " + strLoc + " Exception, " + ex); } if ( iCountErrors == 0 ) { Console.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases); return true; } else { Console.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums ); return false; } }
public static int IndexOf(PageEntry e) { return(m_List.IndexOf(e)); }
public int indexOf(DefineTypeNode node) { return(definitions_.IndexOf(node)); }
/** Command Line Handling **/ /***************************/ // Command line parsing // This function allows command repetition. However public void parseCLI() { Logger.record("[parseCLI]: Parsing Application's command line arguments if existent", "SMWidget", "info"); if (Environment.GetCommandLineArgs().Length > 1) // First argument is the command path+name { Logger.record("\t[parseCLI]: Command Line Arguments found. Will parse.", "SMWidget", "info"); ArrayList CLIArguments = new ArrayList(); foreach (string argument in Environment.GetCommandLineArgs()) { CLIArguments.Add(argument); } /// Help Commands: if (CLIArguments.Contains(helpCommand1) || CLIArguments.Contains(helpCommand2) || CLIArguments.Contains(helpCommand3)) { Logger.record("\t\t[parseCLI]: a help command received in arguments.", "SMWidget", "info"); CLIHelp = true; prematureEnd = true; // Q: Why do we care removing the helpCommands entries from arguments? // A: Because in cases where command line options are combined, or when there are duplicate commands, // or in the future we don't exit the application immediately, leaving them could have bad impact. if (CLIArguments.Contains(helpCommand1)) { CLIArguments.RemoveAt(CLIArguments.IndexOf(helpCommand1)); } else if (CLIArguments.Contains(helpCommand2)) { CLIArguments.RemoveAt(CLIArguments.IndexOf(helpCommand2)); } else if (CLIArguments.Contains(helpCommand3)) { CLIArguments.RemoveAt(CLIArguments.IndexOf(helpCommand3)); } } /// Directory Commands: if (CLIArguments.Contains(changeDirCommand)) { Logger.record("\t\t[parseCLI]: '" + changeDirCommand + "' command received in argument " + CLIArguments.IndexOf(changeDirCommand).ToString(), "SMWidget", "info"); // We DON'T use 'prematureEnd = false;' because that could cancel the '= true' of another option // Q: Why do we care removing the reportCommand entry from arguments? // A: Because in cases where command line options are combined, or when there are duplicate commands, // or in the future we don't exit the application immediately, leaving them could have bad impact. // The next condition checks if the index of the htmlCommand is not the last argument. // The argument after htmlCommand will be regarded as the file to Parse. Even if it is not :) if (CLIArguments.IndexOf(changeDirCommand) < CLIArguments.ToArray().Length - 1) // remove 1 because the first is the app name { Logger.record("\t\t\t[parseCLI]: There's another argument to serve as file name. Will proceed.", "SMWidget", "info"); changeDir = true; newDir = CLIArguments[CLIArguments.IndexOf(changeDirCommand) + 1].ToString(); Logger.record("\t\t\t[parseCLI]: the folder to use is " + newDir + " in " + CLIArguments.IndexOf(htmlCommand).ToString(), "SMWidget", "info"); CLIArguments.RemoveAt(CLIArguments.IndexOf(changeDirCommand) + 1); } CLIArguments.RemoveAt(CLIArguments.IndexOf(changeDirCommand)); } /// Report Commands: if (CLIArguments.Contains(reportCommand)) { Logger.record("\t\t[parseCLI]: '" + reportCommand + "' command received in argument " + CLIArguments.IndexOf(reportCommand).ToString(), "SMWidget", "info"); CLIReport = true; prematureEnd = true; // Q: Why do we care removing the reportCommand entry from arguments? // A: Because in cases where command line options are combined, or when there are duplicate commands, // or in the future we don't exit the application immediately, leaving them could have bad impact. CLIArguments.RemoveAt(CLIArguments.IndexOf(reportCommand)); } /// HTML Commands: if (CLIArguments.Contains(htmlCommand)) { Logger.record("\t\t[parseCLI]: '" + htmlCommand + "' command received in argument " + CLIArguments.IndexOf(htmlCommand).ToString(), "SMWidget", "info"); prematureEnd = true; // Q: Why do we care removing the reportCommand entry from arguments? // A: Because in cases where command line options are combined, or when there are duplicate commands, // or in the future we don't exit the application immediately, leaving them could have bad impact. // The next condition checks if the index of the htmlCommand is not the last argument. // The argument after htmlCommand will be regarded as the file to Parse. Even if it is not :) if (CLIArguments.IndexOf(htmlCommand) < CLIArguments.ToArray().Length - 1) // remove 1 because the first is the app name { Logger.record("\t\t\t[parseCLI]: There's another argument to serve as file name. Will proceed.", "SMWidget", "info"); CLIHtml = true; htmlFile = CLIArguments[CLIArguments.IndexOf(htmlCommand) + 1].ToString(); Logger.record("\t\t\t[parseCLI]: the file to parse is " + htmlFile + " in " + CLIArguments.IndexOf(htmlCommand).ToString(), "SMWidget", "info"); CLIArguments.RemoveAt(CLIArguments.IndexOf(htmlCommand) + 1); } CLIArguments.RemoveAt(CLIArguments.IndexOf(htmlCommand)); } /// Copy of the remaining arguments to note types if (CLIArguments.ToArray().Length > 1) { currentSession.noteTypes = new string[Math.Max(CLIArguments.ToArray().Length - 1, 2)]; int i = 1; for (; i < CLIArguments.ToArray().Length; i++) { Logger.record("\t\t[parseCLI]: Copying " + i.ToString() + " arguments to the new note types", "SMWidget", "config"); currentSession.noteTypes[i - 1] = CLIArguments[i].ToString().Replace(",", ".").Trim(); Logger.record("\t\t[parseCLI]: Lenght of noteTypes: " + currentSession.noteTypes.Length, "SMWidget", "config"); } // The 'if' statement below is used to protect against arguments that provide only one note type. 'i == 2' in that case. if (2 == i) { currentSession.noteTypes[1] = CLIArguments[1].ToString().Replace(",", ".").Trim(); } } } }
protected void Page_Load(object sender, EventArgs e) { try { //string SessionIDName = "VGI022_" + PageTimeStamp.Value; //DataTable dt = (DataTable)Session[SessionIDName]; //DataRow dr = dt.Rows[100]; //dr["aSD"] = "100"; AuthorityControls(this); ErrorMsgLabel.Text = ""; //txtPickBatch.Text = "1"; //------------------------------------------------------ if (!Page.IsPostBack) { if (this.Request["mode"].ToString().ToUpper() == "VIEW") { string sAssignNo = this.Request["ID"].ToString().ToUpper(); if (Session["VGI02QueryID"] != null) { IDList = (ArrayList)Session["VGI02QueryID"]; if (IDList.IndexOf(sAssignNo) == -1) IDList.Add(sAssignNo); } else { IDList.Clear(); IDList.Add(sAssignNo); Session["VGI02QueryID"] = IDList; } } else if (this.Request["mode"].ToString().ToUpper() == "NEW") { // ScriptManager.RegisterStartupScript(Page, this.GetType(), "VGI022.aspx", "confirm(' 此動作將會切換到系統其他頁面,請確認資料已儲存,您確定要切換嗎? ');", true); this.btn_CancelM.Attributes.Add("onclick", "javascript:return confirm('此動作將會切換到系統其他頁面,請確認資料已儲存,您確定要切換嗎? ');"); this.btn_Find.Attributes.Add("onclick", "javascript:return confirm('此動作將會切換到系統其他頁面,請確認資料已儲存,您確定要切換嗎? ');"); this.btn_Save.Attributes.Add("onclick", "javascript:return confirm('確定儲存指配點貨單?');"); // function GotoAcceptQty(destChanNo , destStore , destIteem , destPeriod , destAcceptDate , destAcceptQty ) // TextBox txtChanNo = (TextBox)this.SLP_CHAN_NO.FindControl("TextBoxCode"); // TextBox txtSTORE = (TextBox)this.SLP_STORE.FindControl("TextBoxCode"); TextBox txtSKU = (TextBox)this.SLP_SKU.FindControl("TextBoxCode"); TextBox txtPeriod = (TextBox)this.SLP_Period.FindControl("TextBoxCode"); TextBox txtAcceptDate = (TextBox)this.SLP_AcceptDate.FindControl("TextBoxCode"); TextBox txtAccept = (TextBox)this.SLP_Accept.FindControl("TextBoxCode"); // txtSKU.Attributes.Add("onblur", "GotoItemPeriod('" + txtPeriod.ClientID + "')"); // txtPeriod.Attributes.Add("onblur", "GotoAcceptQty('" + txtChanNo.ClientID + "','" + txtSTORE.ClientID + "','" + txtSKU.ClientID // + "','" + txtPeriod.ClientID + "','" + txtAcceptDate.ClientID + "','" + txtAccept.ClientID + "')"); txtPeriod.Attributes.Add("onblur", "GotoAcceptQty()"); // txtAccept.Attributes.Add("onFocus", "CheckAcceptData()"); txtAccept.Attributes.Add("onkeydown", "return TTLQytWarning();"); //this.ddlChanNo.Attributes["onchange"] = "GetStoreData(document.getElementById('" + this.ddlChanNo.ClientID + "'));"; // this.ddlChanNo.Attributes["onblur"] = "document.getElementById('" + ddlStore.ClientID + "').focus();"; this.ddlStore.Attributes["onblur"] = "document.getElementById('" + txtSKU.ClientID + "').focus();"; } // this.btn_CancelD.Attributes.Add("onclick", "AddNewItem()"); //寫入首次載入Page TimeStamp PageTimeStamp.Value = string.Format("{0}{1}{2}{3}{4}{5}", DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString().PadLeft(2, '0'), DateTime.Now.Day.ToString().PadLeft(2, '0'), DateTime.Now.Hour.ToString().PadLeft(2, '0'), DateTime.Now.Minute.ToString().PadLeft(2, '0'), DateTime.Now.Second.ToString().PadLeft(2, '0') ); this.txt_PageStatus.Text = "NEW"; GetPageDefault(); // throw new Exception("明細資料在編輯狀態,不可儲存!!"); ToolBarInit(); //if (this.txt_PageStatus.Text != "QUERY") //{ // ScriptManager.RegisterStartupScript( // this.UpdatePanel7, // typeof(UpdatePanel), // "隨便寫", // "document.getElementById('" + this.ddlChanNo.ClientID + "').focus();", true); //} } //else //{ // if (ddlChanNo.Items.Count > 0) // { // MaintainAssign BCO = new MaintainAssign(ConntionDB); // DataTable Dt = BCO.GetStoreByChanNo(ddlChanNo.SelectedItem.Value); // this.ddlStore.DataSource = Dt; // ddlStore.DataTextField = "name"; // ddlStore.DataValueField = "store"; // ddlStore.DataBind(); // if (ddlStore.Items.Count > 0) // { // ddlStore.SelectedValue = Request.Form[ddlStore.UniqueID]; // } // } //} } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
/// <summary> /// 检查更新文件 /// </summary> /// <param name="serverXmlFile"></param> /// <param name="localXmlFile"></param> /// <param name="updateFileList"></param> /// <returns></returns> public int CheckForUpdate() { string localXmlFile = Application.StartupPath + "\\AutoUpdaterList.xml"; if (!File.Exists(localXmlFile)) { return(-1); } XmlFiles updaterXmlFiles = new XmlFiles(localXmlFile); string tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\"; this.UpdaterUrl = updaterXmlFiles.GetNodeValue("//Url") + "/AutoUpdaterList.xml"; this.DownAutoUpdateFile(tempUpdatePath); string serverXmlFile = tempUpdatePath + "\\AutoUpdaterList.xml"; if (!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"); 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; k++; } else if (pos > -1 && newVer.CompareTo(oldFileAl[pos + 1].ToString()) > 0) { fileList[0] = newFileName; fileList[1] = newVer; k++; } } return(k); }
private void UpdateTracks(CvBlobs blobs, List<Trak> tracks, double minDist, int maxLife) { ArrayList matched = new ArrayList(); List<int> enter = new List<int>(); List<int> end = new List<int>(); List<int> active = new List<int>(); foreach (var blob in blobs) { Vector2 blobPos = TransformKinectToScreenPos(new Vector2((float)blob.Value.Centroid.X, (float)(blob.Value.Centroid.Y))); float distanceFromCenter = Vector2.Distance(blobPos, new Vector2(Screen.width / 2, Screen.height / 2)); if (distanceFromCenter < ((Screen.height / 2) - radiusRemove))//check Centroid is inside Pond Bounds { //Debug.Log("Inbounds"); bool tracked = false; double minFound = 1000.0; Trak closest = new Trak(); //Find if blob is being tracked foreach (Trak track in tracks) { double distance = Vector2.Distance(new Vector2((float)blob.Value.Centroid.X, (float)blob.Value.Centroid.Y), new Vector2((float)track.X, (float)track.Y)); if (distance < minDist) { //Debug.Log("Found Closest"); tracked = true; if (distance < minFound) { closest = track; minFound = distance; } } } if (tracked) { //Debug.Log("updating tracked"); //Ok it is tracked! do your stuff blob! closest.Active++; closest.Inactive = 0; closest.Lifetime++; closest.Label = blob.Key; closest.X = blob.Value.Centroid.X; closest.Y = blob.Value.Centroid.Y; closest.Centroid = blob.Value.Centroid; closest.MaxX = blob.Value.MaxX; closest.MaxY = blob.Value.MaxY; closest.MinX = blob.Value.MinX; closest.MinY = blob.Value.MinY; matched.Add(closest.Id); tracked = true; active.Add((int)closest.Id); //break; } else { //Debug.Log("New track"); //Blob Is not tracked? create new trak trakCount++; Trak track = new Trak(); track.Active = 1; track.Inactive = 0; track.Lifetime = 1; track.Label = blob.Key; track.X = blob.Value.Centroid.X; track.Y = blob.Value.Centroid.Y; track.Centroid = blob.Value.Centroid; track.MaxX = blob.Value.MaxX; track.MaxY = blob.Value.MaxY; track.MinX = blob.Value.MinX; track.MinY = blob.Value.MinY; track.Id = trakCount; tracks.Add(track); enter.Add((int)track.Id); } } } for (int i = 0; i < tracks.Count; i++) { Trak track = (Trak)tracks[i]; if (matched.IndexOf(track.Id) == -1) { if (track.Inactive >= maxLife) { //Tracked object left, this track is leaving end.Add((int)track.Id); } else { //this track was not matched, let's wait maxLife frames track.Active = 0; track.Inactive++; track.Lifetime++; } } } foreach (StoneArea stoneArea in Spawner.Instance.stoneAreas) { bool toOpen = false; for (int i = 0; i < tracks.Count; i++) { Trak track = tracks[i]; if (track.Active > 0) { Vector2 blobPos = TransformKinectToScreenPos(new Vector2((float)track.X, (float)(track.Y))); if (Vector2.Distance(blobPos, stoneArea.GetPositionOnScreen()) < Screen.height * stoneAreaDist) { track.stoneArea = true; toOpen = true; //break; } else { track.stoneArea = false; } } } stoneArea.GoActivate(toOpen); } foreach (FoodArea foodArea in Spawner.Instance.foodAreas) { bool toOpen = false; for (int i = 0; i < tracks.Count; i++) { Trak track = tracks[i]; if (tracks[i].Active > 0) { Vector2 blobPos = TransformKinectToScreenPos(new Vector2((float)track.X, (float)(track.Y))); if (Vector2.Distance(blobPos, foodArea.GetPositionOnScreen()) < Screen.height * foodAreaDist) { track.foodArea = true; toOpen = true; // break; } else { track.foodArea = false; } } } foodArea.GoActivate(toOpen); } foreach (int id in active) { //Debug.Log(id); int idt = id; OnBlobActive(idt); } foreach (int id in end) { //Debug.Log(id); int idt = id; OnBlobExit(idt); } foreach (int id in enter) { //Debug.Log(id); int idt = id; OnBlobEnter(idt); } }
private Boolean ImportTable(string table, OleDbConnection conm, SqlConnection con) { ArrayList fname = new ArrayList(); ArrayList key = new ArrayList(); ArrayList type = new ArrayList(); ArrayList pic = new ArrayList(); string sql, sql1, wh, st, st1; if (!PublicFunction.CheckFieldOfTable(con, table)) { return(false); } sql = "select * from " + table; RecordSetMDB rs = new RecordSetMDB(sql, conm); sql = "Insert Into [" + table + "] ("; for (int i = 0; i < rs.cols; i++) { if (Func.Fun.CheckFieldOfTable(con, table, rs.Field(i))) { fname.Add(rs.Field(i)); key.Add(Func.Fun.CheckPrimaryKey(con, table, rs.Field(i))); st = Func.Fun.GetTypeField(con, table, rs.Field(i)); type.Add(st); if (i != 0) { sql += ","; } sql += "[" + rs.Field(i) + "]"; if (st == "6") { pic.Add(rs.Field(i)); } } } sql += ") values("; for (int j = 0; j < rs.rows; j++) { if (stop) { CL(); return(false); } sql1 = ""; wh = ""; st1 = ""; for (int i = 0; i < fname.Count; i++) { //insert if (sql1 != "") { sql1 += ","; } if (pic.IndexOf(fname[i] + "") >= 0 || rs.record(j, fname[i] + "") == null || rs.record(j, fname[i] + "") == "") { if ((Boolean)key[i]) { sql1 = sql1 + "''"; } else { sql1 = sql1 + "Default"; } } // Get TypeName of Field, return {1 (nvarchar,char..), 2 (datetime), 3 (bit), 4 (float), 5 (int)} else { switch ((string)type[i]) // DataType { case "1": sql1 = sql1 + "N'" + T_String.sqlsql(rs.record(j, fname[i] + "")) + "'"; break; case "2": sql1 = sql1 + doiDT(rs.record(j, fname[i] + "")); break; case "3": if (rs.record(j, fname[i] + "") == "True") { sql1 = sql1 + "1"; } else if (rs.record(j, fname[i] + "") == "False") { sql1 = sql1 + "0"; } else { sql1 = sql1 + rs.record(j, fname[i] + ""); } break; case "4": sql1 = sql1 + rs.record(j, fname[i] + ""); break; case "5": sql1 = sql1 + rs.record(j, fname[i] + ""); break; default: sql1 = sql1 + "N'" + T_String.sqlsql(rs.record(j, fname[i] + "")) + "'"; break; } } //Delete if ((Boolean)key[i]) { if (wh != "") { wh += " and "; } // Get TypeName of Field, return {1 (nvarchar,char..), 2 (datetime), 3 (bit), 4 (float), 5 (int)} switch ((string)type[i]) // DataType { case "1": wh = wh + fname[i] + "=N'" + T_String.sqlsql(rs.record(j, fname[i] + "")) + "'"; break; case "2": wh = wh + fname[i] + "=" + doiDT(rs.record(j, fname[i] + "")) + ""; break; case "3": if (rs.record(j, fname[i] + "") == "True") { wh = wh + fname[i] + "=1"; } else if (rs.record(j, fname[i] + "") == "False") { wh = wh + fname[i] + "=0"; } else { wh = wh + fname[i] + "=" + rs.record(j, fname[i] + ""); } break; case "4": wh = wh + fname[i] + "=" + rs.record(j, fname[i] + ""); break; case "5": wh = wh + fname[i] + "=" + rs.record(j, fname[i] + ""); break; default: wh = wh + fname[i] + "=N'" + T_String.sqlsql(rs.record(j, fname[i] + "")) + "'"; break; } } if ((Boolean)key[i]) { if (st1 != "") { st1 += " and "; } //cu // if (Func.Fun.GetTypeField(con,table,fname[i]+"")=="2") // { // if (rs.record(j,fname[i]+"")+""=="") // st1+=fname[i]+"=''"; // else // st1+=fname[i]+"='"+ DateTime.Parse(rs.record(j,fname[i]+"")).ToString("yyyy/MM/dd HH:mm:ss") +"'"; // } // else // { // st1+=fname[i]+"='"+ T_String.sqlsql(rs.record(j,fname[i]+""))+"'"; // } if (Func.Fun.GetTypeField(con, table, fname[i] + "") == "2") { if (rs.record(j, fname[i] + "") + "" == "") { st1 += fname[i] + "=''"; } else { st1 += fname[i] + "='" + DateTime.Parse(rs.record(j, fname[i] + "")).ToString("yyyy/MM/dd HH:mm:ss") + "'"; } } else { if (Func.Fun.GetTypeField(con, table, fname[i] + "") == "1") { st1 += fname[i] + "='" + T_String.sqlsql(rs.record(j, fname[i] + "")) + "'"; } else { st1 += fname[i] + "=" + T_String.sqlsql(rs.record(j, fname[i] + "")) + ""; } } } } //PublicFunction.SQL_Execute("Delete from ["+table+"] where "+wh,con); PublicFunction.SQL_Execute(sql + sql1 + ")", con); for (int m = 0; m < pic.Count; m++) { if (st1 != "") { st = "Select [" + pic[m] + "] from [" + table + "] where " + st1; UploadImageToSQL(LoadImageFromMDB(st, conm), pic[m] + "", table, wh, con); } } ///lb1.Text=r+"/"+txt5.Text+" records."; ll.Text = "*" + table + "* __ " + (j + 1) + "/" + rs.rows + " records. " + (int)((j + 1) * 100 / rs.rows) + "% "; pro.Value = (int)((j + 1) * 100 / rs.rows); // pro.Value=(int)(r*100/T_String.IsNullTo0(txt5.Text)); } pro.Value = 100; return(true); }
//#endregion #region private Methods... #endregion //#region public Methods... #region public cDBMetadata_DB[] DBConnections(); /// <summary> /// first item in the array, represents default db connection /// </summary> /// <returns></returns> public OGen.NTier.lib.metadata.cDBMetadata_DB[] UnBind_DBConnections() { OGen.NTier.lib.metadata.cDBMetadata_DB[] DBConnections_out; ArrayList _dbservertypes; DBServerTypes _dbservertype; int _dbindex; int _justadded; _dbservertypes = new ArrayList(); for (int i = 0; i < lvwConnections.Items.Count; i++) { if ( // if Default lvwConnections.Items[i].SubItems[(int)eConnectionColumns.Default].Text != string.Empty ) { _dbservertype = (DBServerTypes)Enum.Parse( typeof(DBServerTypes), lvwConnections.Items[i].SubItems[ (int)eConnectionColumns.DBServerType ].Text ); //if (!_dbservertypes.Contains(_dbservertype)) // no need to check! _dbservertypes.Add(_dbservertype); break; // default was found } } for (int i = 0; i < lvwConnections.Items.Count; i++) { if ( // if !Default lvwConnections.Items[i].SubItems[(int)eConnectionColumns.Default].Text == string.Empty ) { _dbservertype = (DBServerTypes)Enum.Parse( typeof(DBServerTypes), lvwConnections.Items[i].SubItems[ (int)eConnectionColumns.DBServerType ].Text ); if (!_dbservertypes.Contains(_dbservertype)) { _dbservertypes.Add(_dbservertype); } } } //--- DBConnections_out = new OGen.NTier.lib.metadata.cDBMetadata_DB[ _dbservertypes.Count ]; //--- for (int i = 0; i < _dbservertypes.Count; i++) { DBConnections_out[i] = new OGen.NTier.lib.metadata.cDBMetadata_DB( // ToDos: here! check this... null, (DBServerTypes)_dbservertypes[i] ); } for (int i = 0; i < lvwConnections.Items.Count; i++) { _dbservertype = (DBServerTypes)Enum.Parse( typeof(DBServerTypes), lvwConnections.Items[i].SubItems[ (int)eConnectionColumns.DBServerType ].Text ); _dbindex = _dbservertypes.IndexOf(_dbservertype); _justadded = DBConnections_out[_dbindex].Connections.Add( true, // ToDos: here! lvwConnections.Items[i].SubItems[ (int)eConnectionColumns.DBMode ].Text, true ); DBConnections_out[_dbindex].Connections[_justadded].Connectionstring = lvwConnections.Items[i].SubItems[ (int)eConnectionColumns.DBConnectionstring ].Text; DBConnections_out[_dbindex].Connections[_justadded].isDefault = ( lvwConnections.Items[i].SubItems[(int)eConnectionColumns.Default].Text != string.Empty ); } return(DBConnections_out); }
private void My2(TreeView tv, TreeNode tnParent, DataTable m_DataTable) { if ("shimaopm" == this.up_sPMNameLower && user.m_EntityDataAccessUnit != null) { //加权限控制:只能看本部门下的预算表 2006.7.25 if (user.m_EntityDataAccessUnit != null) { for (int i = m_DataTable.Rows.Count - 1; i >= 0; i--) { //m_DataTable.SetCurrentRow(i); string UnitCode = m_DataTable.Rows[i]["UnitCode"].ToString(); if (user.m_EntityDataAccessUnit.CurrentTable.Select("UnitCode='" + UnitCode + "'").Length <= 0) //没权限 { m_DataTable.Rows.Remove(m_DataTable.Rows[i]); } } } } string GroupCode = tnParent.Value; DataRow[] drs = m_DataTable.Select(string.Format("GroupCode = '{0}'", GroupCode)); ArrayList ary = new ArrayList(); foreach (DataRow dr in drs) { string DistrictCode = RmsPM.BLL.CostBudgetRule.GetPBSDistrictCode(RmsPM.BLL.ConvertRule.ToString(dr["PBSType"]), RmsPM.BLL.ConvertRule.ToString(dr["PBSCode"])); if ("" == DistrictCode) { TreeNode tn = new TreeNode(); tn.Value += dr["PBSType"] + ","; tn.Value += dr["PBSCode"] + ","; tn.Value += dr["PBSName"] + ","; tn.Value += dr["CostBudgetSetCode"].ToString() + ","; tn.Value += dr["CostBudgetSetName"].ToString(); tn.Text = dr["CostBudgetSetName"].ToString(); //tn. // mytree "frameMain"; tnParent.ChildNodes.Add(tn); } else //区域 { if (ary.IndexOf(DistrictCode) < 0) { ary.Add(DistrictCode); TreeNode tn = new TreeNode(); tn.Value = ""; tn.Text = RmsPM.BLL.ProductRule.GetBuildingName(DistrictCode); tn.NavigateUrl = "#"; tnParent.ChildNodes.Add(tn); //区域中加预算 foreach (DataRow drw in drs) { string CurrentDistrictCode = RmsPM.BLL.CostBudgetRule.GetPBSDistrictCode(RmsPM.BLL.ConvertRule.ToString(drw["PBSType"]), RmsPM.BLL.ConvertRule.ToString(drw["PBSCode"])); if (DistrictCode == CurrentDistrictCode) { TreeNode tnSub = new TreeNode(); tnSub.Value += drw["PBSType"] + ","; tnSub.Value += drw["PBSCode"] + ","; tnSub.Value += drw["PBSName"] + ","; tnSub.Value += drw["CostBudgetSetCode"].ToString() + ","; tnSub.Value += drw["CostBudgetSetName"].ToString(); tnSub.Text = drw["CostBudgetSetName"].ToString(); // mytree.Target = "frameMain"; tn.ChildNodes.Add(tnSub); } } } } } }
public void Add(string FName, double hr) { int i = Name.IndexOf(FName); Data[i] = T_String.CongTG(IsN(Data[i] + ""), hr); }
private void showtree() { string CostBudgetSetCode = "" + Request["CostBudgetSetCode"]; ((TreeView)this.RadComboBox1.Items[0].FindControl("TreeView1")).Nodes.Clear(); string sqlUnit = "Select * from Building"; QueryAgent qa = new QueryAgent(); tbUnit = qa.ExecSqlForDataSet(sqlUnit).Tables[0]; string projectcode = Request.QueryString["ProjectCode"] + ""; //取目标费用表 CostBudgetSetStrategyBuilder sb = new CostBudgetSetStrategyBuilder(); sb.AddStrategy(new Strategy(CostBudgetSetStrategyName.ProjectCode, projectcode)); string sql; //权限 //ArrayList arA = new ArrayList(); //arA.Add(user.UserCode); //arA.Add(user.BuildStationCodes()); //sb.AddStrategy(new Strategy(DAL.QueryStrategy.CostBudgetSetStrategyName.AccessRange, arA)); //缺省排序(项目总体费用排在最后) sb.AddOrder("GroupSortID", true); sb.AddOrder("PBSType", true); sb.AddOrder("CostBudgetSetName", true); sql = sb.BuildQueryViewString(); QueryAgent qal = new QueryAgent(); DataTable m_DataTable = qal.ExecSqlForDataSet(sql).Tables[0]; qal.Dispose(); //为初始化树节点做准备 DataRow[] inidrs = m_DataTable.Select("CostBudgetSetCode = '" + CostBudgetSetCode + "'"); if (inidrs.Length > 0) { this.PBSTypeID.Value = inidrs[0]["PBSType"].ToString(); PBSCodeID.Value = inidrs[0]["PBSCode"].ToString(); PBSNameID.Value = inidrs[0]["PBSName"].ToString(); this.txtSelectCostBudgetSetCode.Value = inidrs[0]["CostBudgetSetCode"].ToString(); RegisterClientScriptBlock("IsExecSearchTree", "<script>IsExecSearchTree = 1;</script>"); this.RadComboBox1.Items[0].Text = inidrs[0]["CostBudgetSetName"].ToString(); } ArrayList al = new ArrayList(); foreach (DataRow dr in m_DataTable.Rows) { string GroupCode = RmsPM.BLL.ConvertRule.ToString(dr["GroupCode"]); if ((GroupCode != "") && (al.IndexOf(GroupCode) < 0)) { al.Add(GroupCode); } } foreach (string GroupCode in al) { DataRow[] drs = m_DataTable.Select("GroupCode = '" + GroupCode + "'"); if (drs.Length > 0) { TreeNode mytree = new TreeNode(); mytree.Value = drs[0]["GroupCode"].ToString(); mytree.Text = drs[0]["GroupName"].ToString(); mytree.NavigateUrl = "#"; ((TreeView)this.RadComboBox1.Items[0].FindControl("TreeView1")).Nodes.Add(mytree); My2((TreeView)this.RadComboBox1.Items[0].FindControl("TreeView1"), mytree, m_DataTable); } } ((TreeView)this.RadComboBox1.Items[0].FindControl("TreeView1")).ExpandAll(); //((TreeView)this.RadComboBox1.Items[0].FindControl("TreeView1")).ShowExpandCollapse = false; //((TreeView)this.RadComboBox1.Items[0].FindControl("TreeView1")).ImageSet = System.Web.UI.WebControls.TreeViewImageSet.Arrows; //((TreeView)this.RadComboBox1.Items[0].FindControl("TreeView1")).Attributes.Add("onclick", "clicktr()"); }
public void TestDuplicatedItems() { //-------------------------------------------------------------------------- // Variable definitions. //-------------------------------------------------------------------------- ArrayList arrList = null; string[] strHeroes = { "Aquaman", "Atom", "Batman", "Black Canary", "Captain America", "Captain Atom", "Catwoman", "Cyborg", "Flash", "Green Arrow", "Green Lantern", "Hawkman", "Daniel Takacs", "Ironman", "Nightwing", "Robin", "SpiderMan", "Steel", "Gene", "Thor", "Wildcat", null }; // Construct ArrayList. arrList = new ArrayList(strHeroes); //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of //BinarySearch, Following variable cotains each one of these types of array lists ArrayList[] arrayListTypes = { (ArrayList)arrList.Clone(), (ArrayList)ArrayList.Adapter(arrList).Clone(), (ArrayList)arrList.GetRange(0, arrList.Count).Clone(), (ArrayList)ArrayList.Synchronized(arrList).Clone()}; foreach (ArrayList arrayListType in arrayListTypes) { arrList = arrayListType; // // [] IndexOf an array normal // for (int i = 0; i < strHeroes.Length; i++) { Assert.Equal(i, arrList.IndexOf(strHeroes[i])); } //[] Check IndexOf when element is in list twice arrList.Clear(); arrList.Add(null); arrList.Add(arrList); arrList.Add(null); Assert.Equal(0, arrList.IndexOf(null)); //[] check for something which does not exist in a list arrList.Clear(); Assert.Equal(-1, arrList.IndexOf(null)); } }
public void Torus() { // Total vertices int totalVertices = segments * tubes; // Total primitives int totalPrimitives = totalVertices * 2; // Total indices int totalIndices = totalPrimitives * 3; // Init vertexList and indexList ArrayList verticesList = new ArrayList(); ArrayList indicesList = new ArrayList(); // Save these locally as floats float numSegments = segments; float numTubes = tubes; // Calculate size of segment and tube float segmentSize = 2 * Pi / numSegments; float tubeSize = 2 * Pi / numTubes; // Create floats for our xyz coordinates float x = 0; float y = 0; float z = 0; // Init temp lists with tubes and segments ArrayList segmentList = new ArrayList(); ArrayList tubeList = new ArrayList(); // Loop through number of tubes for (int i = 0; i < numSegments; i++) { tubeList = new ArrayList(); for (int j = 0; j < numTubes; j++) { // Calculate X, Y, Z coordinates. x = (segmentRadius + tubeRadius * Mathf.Cos(j * tubeSize)) * Mathf.Cos(i * segmentSize); y = (segmentRadius + tubeRadius * Mathf.Cos(j * tubeSize)) * Mathf.Sin(i * segmentSize); z = tubeRadius * Mathf.Sin(j * tubeSize); // Add the vertex to the tubeList tubeList.Add(new Vector3(x, z, y)); // Add the vertex to global vertex list verticesList.Add(new Vector3(x, z, y)); } // Add the filled tubeList to the segmentList segmentList.Add(tubeList); } // Loop through the segments for (int i = 0; i < segmentList.Count; i++) { // Find next (or first) segment offset int n = (i + 1) % segmentList.Count; // Find current and next segments ArrayList currentTube = (ArrayList)segmentList[i]; ArrayList nextTube = (ArrayList)segmentList[n]; // Loop through the vertices in the tube for (int j = 0; j < currentTube.Count; j++) { // Find next (or first) vertex offset int m = (j + 1) % currentTube.Count; // Find the 4 vertices that make up a quad Vector3 v1 = (Vector3)currentTube[j]; Vector3 v2 = (Vector3)currentTube[m]; Vector3 v3 = (Vector3)nextTube[m]; Vector3 v4 = (Vector3)nextTube[j]; // Draw the first triangle indicesList.Add((int)verticesList.IndexOf(v1)); indicesList.Add((int)verticesList.IndexOf(v2)); indicesList.Add((int)verticesList.IndexOf(v3)); // Finish the quad indicesList.Add((int)verticesList.IndexOf(v3)); indicesList.Add((int)verticesList.IndexOf(v4)); indicesList.Add((int)verticesList.IndexOf(v1)); } } Mesh mesh = new Mesh(); Vector3[] vertices = new Vector3[totalVertices]; verticesList.CopyTo(vertices); int[] triangles = new int[totalIndices]; indicesList.CopyTo(triangles); mesh.vertices = vertices; mesh.triangles = triangles; mesh.RecalculateBounds(); mesh.Optimize(); MeshFilter mFilter = GetComponent(typeof(MeshFilter)) as MeshFilter; mFilter.mesh = mesh; }
public void TestMultiDataTypes() { short i16 = 1; int i32 = 2; long i64 = 3; ushort ui16 = 4; uint ui32 = 5; ulong ui64 = 6; ArrayList alst = new ArrayList(); alst.Add(i16); alst.Add(i32); alst.Add(i64); alst.Add(ui16); alst.Add(ui32); alst.Add(ui64); //[] we make sure that ArrayList only return true for Contains() when both the value and the type match //in numeric types for (int i = 0; i < alst.Count; i++) { Assert.True(!alst.Contains(i) || i == 2); } //[]IndexOf should also work in this context for (int i = 0; i < alst.Count; i++) { Assert.True((alst.IndexOf(i) != -1) || (i != 2)); Assert.True((alst.IndexOf(i) == -1) || (i == 2)); } //[]Sort should fail cause the objects are of different types Assert.Throws<InvalidOperationException>(() => alst.Sort()); }
/// <summary> /// Returns the ordinal index of a MenuItem, if it exists; if the item does not exist, /// -1 is returned. /// </summary> /// <param name="item">The MenuItem to search for.</param> /// <returns>The ordinal position of the item in the collection.</returns> public virtual int IndexOf(SubMenuItem item) { return(menuItems.IndexOf(item)); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { plcOther.Controls.Clear(); if (CMSContext.CurrentUser.IsAuthenticated()) { // Set the layout of tab menu tabMenu.TabControlLayout = BasicTabControl.GetTabMenuLayout(TabControlLayout); // Remove 'saved' parameter from querystring string absoluteUri = URLHelper.RemoveParameterFromUrl(URLRewriter.CurrentURL, "saved"); CurrentUserInfo currentUser = CMSContext.CurrentUser; // Get customer info GeneralizedInfo customer = ModuleCommands.ECommerceGetCustomerInfoByUserId(currentUser.UserID); bool userIsCustomer = (customer != null); // Get friends enabled setting bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(CMSContext.CurrentSiteName); // Get customer ID int customerId = 0; if (userIsCustomer) { customerId = ValidationHelper.GetInteger(customer.ObjectID, 0); } // Selected page url string selectedPage = string.Empty; // Menu initialization tabMenu.UrlTarget = "_self"; ArrayList activeTabs = new ArrayList(); string tabName = string.Empty; int arraySize = 0; if (DisplayMyPersonalSettings) { arraySize++; } if (DisplayMyMessages) { arraySize++; } // Handle 'Notifications' tab displaying bool hideUnavailableUI = SettingsKeyProvider.GetBoolValue("CMSHideUnavailableUserInterface"); bool showNotificationsTab = (DisplayMyNotifications && ModuleEntry.IsModuleLoaded(ModuleEntry.NOTIFICATIONS) && (!hideUnavailableUI || LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Notifications))); bool isWindowsAuthentication = RequestHelper.IsWindowsAuthentication(); if (showNotificationsTab) { arraySize++; } if (DisplayMyFriends && friendsEnabled) { arraySize++; } if (DisplayMyDetails && userIsCustomer) { arraySize++; } if (DisplayMyCredits && userIsCustomer) { arraySize++; } if (DisplayMyAddresses && userIsCustomer) { arraySize++; } if (DisplayMyOrders && userIsCustomer) { arraySize++; } if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication) { arraySize++; } if (DisplayMySubscriptions) { arraySize++; } if (this.DisplayMyMemberships) { arraySize++; } if (DisplayMyCategories) { arraySize++; } tabMenu.Tabs = new string[arraySize, 5]; if (DisplayMyPersonalSettings) { tabName = personalTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyPersonalSettings"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, personalTab)); if (currentUser != null) { selectedPage = tabName; } } // These items can be displayed only for customer if (userIsCustomer && ModuleEntry.IsModuleLoaded(ModuleEntry.ECOMMERCE)) { if (DisplayMyDetails) { // Try to load the control dynamically (if available) ucMyDetails = Page.LoadControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyDetails.ascx") as CMSAdminControl; if (ucMyDetails != null) { ucMyDetails.ID = "ucMyDetails"; plcOther.Controls.Add(ucMyDetails); tabName = detailsTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyDetails"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, detailsTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyAddresses) { // Try to load the control dynamically (if available) ucMyAddresses = Page.LoadControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyAddresses.ascx") as CMSAdminControl; if (ucMyAddresses != null) { ucMyAddresses.ID = "ucMyAddresses"; plcOther.Controls.Add(ucMyAddresses); tabName = addressesTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyAddresses"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, addressesTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyOrders) { // Try to load the control dynamically (if available) ucMyOrders = Page.LoadControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyOrders.ascx") as CMSAdminControl; if (ucMyOrders != null) { ucMyOrders.ID = "ucMyOrders"; plcOther.Controls.Add(ucMyOrders); tabName = ordersTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyOrders"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, ordersTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyCredits) { // Try to load the control dynamically (if available) ucMyCredit = Page.LoadControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyCredit.ascx") as CMSAdminControl; if (ucMyCredit != null) { ucMyCredit.ID = "ucMyCredit"; plcOther.Controls.Add(ucMyCredit); tabName = creditTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyCredit"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, creditTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } } if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication) { tabName = passwordTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.ChangePassword"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, passwordTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } if ((ucMyNotifications == null) && showNotificationsTab) { // Try to load the control dynamically (if available) ucMyNotifications = Page.LoadControl("~/CMSModules/Notifications/Controls/UserNotifications.ascx") as CMSAdminControl; if (ucMyNotifications != null) { ucMyNotifications.ID = "ucMyNotifications"; plcOther.Controls.Add(ucMyNotifications); tabName = notificationsTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyNotifications"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, notificationsTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyMessages == null) && DisplayMyMessages && ModuleEntry.IsModuleLoaded(ModuleEntry.MESSAGING)) { // Try to load the control dynamically (if available) ucMyMessages = Page.LoadControl("~/CMSModules/Messaging/Controls/MyMessages.ascx") as CMSAdminControl; if (ucMyMessages != null) { ucMyMessages.ID = "ucMyMessages"; plcOther.Controls.Add(ucMyMessages); tabName = messagesTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyMessages"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, messagesTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyFriends == null) && DisplayMyFriends && ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY) && friendsEnabled) { // Try to load the control dynamically (if available) ucMyFriends = Page.LoadControl("~/CMSModules/Friends/Controls/MyFriends.ascx") as CMSAdminControl; if (ucMyFriends != null) { ucMyFriends.ID = "ucMyFriends"; plcOther.Controls.Add(ucMyFriends); tabName = friendsTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyFriends"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, friendsTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyAllSubscriptions == null) && DisplayMySubscriptions) { // Try to load the control dynamically (if available) ucMyAllSubscriptions = Page.LoadControl("~/CMSModules/Membership/Controls/Subscriptions.ascx") as CMSAdminControl; if (ucMyAllSubscriptions != null) { ucMyAllSubscriptions.Visible = false; ucMyAllSubscriptions.SetValue("ShowBlogs", DisplayBlogs); ucMyAllSubscriptions.SetValue("ShowMessageBoards", DisplayMessageBoards); ucMyAllSubscriptions.SetValue("ShowNewsletters", DisplayNewsletters); ucMyAllSubscriptions.SetValue("sendconfirmationemail", SendConfirmationEmails); ucMyAllSubscriptions.ID = "ucMyAllSubscriptions"; plcOther.Controls.Add(ucMyAllSubscriptions); tabName = subscriptionsTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyAllSubscriptions"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, subscriptionsTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } // My memberships if ((this.ucMyMemberships == null) && this.DisplayMyMemberships) { // Try to load the control dynamically this.ucMyMemberships = this.Page.LoadControl("~/CMSModules/Membership/Controls/MyMemberships.ascx") as CMSAdminControl; if (this.ucMyMemberships != null) { this.ucMyMemberships.SetValue("UserID", currentUser.UserID); if (!String.IsNullOrEmpty(this.MembershipsPagePath)) { this.ucMyMemberships.SetValue("BuyMembershipURL", CMSContext.GetUrl(this.MembershipsPagePath)); } this.plcOther.Controls.Add(this.ucMyMemberships); tabName = membershipsTab; activeTabs.Add(tabName); this.tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = this.GetString("myaccount.mymemberships"); this.tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, this.ParameterName, membershipsTab)); if (selectedPage == String.Empty) { selectedPage = tabName; } } } if ((ucMyCategories == null) && DisplayMyCategories) { // Try to load the control dynamically (if available) ucMyCategories = Page.LoadControl("~/CMSModules/Categories/Controls/Categories.ascx") as CMSAdminControl; if (ucMyCategories != null) { ucMyCategories.Visible = false; ucMyCategories.SetValue("DisplaySiteCategories", false); ucMyCategories.SetValue("DisplaySiteSelector", false); ucMyCategories.ID = "ucMyCategories"; plcOther.Controls.Add(ucMyCategories); tabName = categoriesTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyCategories"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, categoriesTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } // Set css class pnlBody.CssClass = CssClass; // Get page url page = QueryHelper.GetString(ParameterName, selectedPage); // Set controls visibility ucChangePassword.Visible = false; ucChangePassword.StopProcessing = true; if (ucMyAddresses != null) { ucMyAddresses.Visible = false; ucMyAddresses.StopProcessing = true; } if (ucMyOrders != null) { ucMyOrders.Visible = false; ucMyOrders.StopProcessing = true; } if (ucMyDetails != null) { ucMyDetails.Visible = false; ucMyDetails.StopProcessing = true; } if (ucMyCredit != null) { ucMyCredit.Visible = false; ucMyCredit.StopProcessing = true; } if (ucMyAllSubscriptions != null) { ucMyAllSubscriptions.Visible = false; ucMyAllSubscriptions.StopProcessing = true; ucMyAllSubscriptions.SetValue("CacheMinutes", CacheMinutes); } if (ucMyNotifications != null) { ucMyNotifications.Visible = false; ucMyNotifications.StopProcessing = true; } if (ucMyMessages != null) { ucMyMessages.Visible = false; ucMyMessages.StopProcessing = true; } if (ucMyFriends != null) { ucMyFriends.Visible = false; ucMyFriends.StopProcessing = true; } if (this.ucMyMemberships != null) { this.ucMyMemberships.Visible = false; this.ucMyMemberships.StopProcessing = true; } if (this.ucMyCategories != null) { this.ucMyCategories.Visible = false; this.ucMyCategories.StopProcessing = true; } tabMenu.SelectedTab = activeTabs.IndexOf(page); // Select current page switch (page) { case personalTab: if (myProfile != null) { // Get alternative form info AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeFormName); if (afi != null) { myProfile.StopProcessing = false; myProfile.Visible = true; myProfile.AllowEditVisibility = AllowEditVisibility; myProfile.AlternativeFormName = AlternativeFormName; } else { lblError.Text = String.Format(GetString("altform.formdoesntexists"), AlternativeFormName); lblError.Visible = true; myProfile.Visible = false; } } break; case detailsTab: if (ucMyDetails != null) { ucMyDetails.Visible = true; ucMyDetails.StopProcessing = false; ucMyDetails.SetValue("Customer", customer); } break; case addressesTab: if (ucMyAddresses != null) { ucMyAddresses.Visible = true; ucMyAddresses.StopProcessing = false; ucMyAddresses.SetValue("CustomerId", customerId); } break; case ordersTab: if (ucMyOrders != null) { ucMyOrders.Visible = true; ucMyOrders.StopProcessing = false; ucMyOrders.SetValue("CustomerId", customerId); ucMyOrders.SetValue("ShowOrderTrackingNumber", ShowOrderTrackingNumber); } break; case creditTab: if (ucMyCredit != null) { ucMyCredit.Visible = true; ucMyCredit.StopProcessing = false; ucMyCredit.SetValue("CustomerId", customerId); } break; case passwordTab: ucChangePassword.Visible = true; ucChangePassword.StopProcessing = false; ucChangePassword.AllowEmptyPassword = AllowEmptyPassword; break; case notificationsTab: if (ucMyNotifications != null) { ucMyNotifications.Visible = true; ucMyNotifications.StopProcessing = false; ucMyNotifications.SetValue("UserId", currentUser.UserID); ucMyNotifications.SetValue("UnigridImageDirectory", UnigridImageDirectory); } break; case messagesTab: if (ucMyMessages != null) { ucMyMessages.Visible = true; ucMyMessages.StopProcessing = false; } break; case friendsTab: if (ucMyFriends != null) { ucMyFriends.Visible = true; ucMyFriends.StopProcessing = false; ucMyFriends.SetValue("UserID", currentUser.UserID); } break; case subscriptionsTab: if (ucMyAllSubscriptions != null) { ucMyAllSubscriptions.Visible = true; ucMyAllSubscriptions.StopProcessing = false; ucMyAllSubscriptions.SetValue("userid", currentUser.UserID); ucMyAllSubscriptions.SetValue("siteid", CMSContext.CurrentSiteID); } break; case membershipsTab: if (this.ucMyMemberships != null) { this.ucMyMemberships.Visible = true; this.ucMyMemberships.StopProcessing = false; } break; case categoriesTab: if (this.ucMyCategories != null) { this.ucMyCategories.Visible = true; this.ucMyCategories.StopProcessing = false; } break; } } else { // Hide control if current user is not authenticated Visible = false; } } }
//test read product queue public void updateProductQueue(string productName) { string path = DataUtility.GetProductPath() + "ProductQueue.json"; int count = 0; if (productkeys.Count == 0) { if (File.Exists(path)) { //get the queue of products from json file Debug.Log("File existed"); string json = File.ReadAllText(path); productList = JsonConvert.DeserializeObject <List <Product> >(json); foreach (Product p in productList) { if (count < maxProductsCountInCache) { productkeys.Add(p.name); count++; } else { DeleteProductModelFile(p.name); } } } else { Debug.Log("File not existed"); //get the queue of products from Testsample count = 0; string productModelFolder = DataUtility.GetProductModelPath(); DirectoryInfo dir = new DirectoryInfo(productModelFolder); Debug.Log("dir = " + dir.Name); productkeys.Clear(); FileInfo[] files = dir.GetFiles(); foreach (FileInfo f in files) { string modelName = f.Name.Substring(0, f.Name.Length - f.Extension.Length); Debug.Log("modelName = " + modelName); if (count < maxProductsCountInCache) { //productkeys.Insert(0, modelName); Debug.Log("productkeys.Add " + modelName); productkeys.Add(modelName); count++; } else { DeleteProductModelFile(modelName); } } } } Debug.Log("productkeys." + productkeys.Count); if (productkeys.IndexOf(productName) != -1) { Debug.Log("b productkeys.IndexOf (productName) != -1"); productkeys.Remove(productName); } else if (productkeys.Count == maxProductsCountInCache) { string pname = (string)productkeys[maxProductsCountInCache - 1]; Debug.Log("productkeys.Count == maxProductsCountInCache pname = " + pname); DeleteProductModelFile(pname); productkeys.RemoveAt(maxProductsCountInCache - 1); } productkeys.Insert(0, productName); newProductList.Clear(); int newCount = 0; Debug.Log("string pk in productkeys."); foreach (string pk in productkeys) { Product newProduct = new Product(); newProduct.name = pk; newProduct.queue = newCount; //put it at the begin newProductList.Add(newProduct); newCount++; } Debug.Log("WriteAllText(path, str)"); string str = JsonConvert.SerializeObject(newProductList); Debug.Log("out: " + str); File.WriteAllText(path, str); }
internal System.ComponentModel.License method_10(LicenseContext licenseContext_0, Type type_0, object object_2, bool bool_6, bool bool_7, bool bool_8, bool bool_9, string string_10, string string_11, byte[] byte_3, bool bool_10, bool bool_11, bool bool_12) { if (!bool_7 && !bool_8 && !bool_9 && !bool_11 && !bool_12) { if (licenseContext_0 == null) { return null; } if (Class1.sortedList_1[type_0.Assembly.FullName] != null) { if ((bool)Class1.sortedList_0[type_0.Assembly.FullName]) { return (Class1.Class12)Class1.sortedList_1[type_0.Assembly.FullName]; } return null; } else if (Class1.sortedList_1[typeof(Class1).Assembly.FullName] != null) { AssemblyName[] referencedAssemblies = typeof(Class1).Assembly.GetReferencedAssemblies(); int i = 0; while (i < referencedAssemblies.Length) { if (!(type_0.Assembly.GetName().FullName == referencedAssemblies[i].FullName)) { i++; } else { if ((bool)Class1.sortedList_0[typeof(Class1).Assembly.FullName]) { return (Class1.Class12)Class1.sortedList_1[typeof(Class1).Assembly.FullName]; } return null; } } } else { AssemblyName[] referencedAssemblies2 = typeof(Class1).Assembly.GetReferencedAssemblies(); for (int j = 0; j < referencedAssemblies2.Length; j++) { if (typeof(Class1).Assembly.GetName().FullName == referencedAssemblies2[j].FullName) { type_0 = typeof(Class1); break; } } } } Class1.Class4 @class = new Class1.Class4(); new Class1.Class12(this, ""); BinaryReader binaryReader = new BinaryReader(typeof(Class1).Assembly.GetManifestResourceStream("92a1b607-6502-4e33-ae50-ad799c7d4334")); binaryReader.BaseStream.Position = 0L; byte[] array = new byte[0]; byte[] array2 = binaryReader.ReadBytes((int)binaryReader.BaseStream.Length); byte[] array3 = new byte[32]; array3[0] = 177; array3[0] = 136; array3[0] = 103; array3[0] = 110; array3[0] = 150; array3[0] = 57; array3[1] = 116; array3[1] = 138; array3[1] = 53; array3[2] = 201; array3[2] = 40; array3[2] = 39; array3[2] = 246; array3[3] = 95; array3[3] = 139; array3[3] = 238; array3[4] = 108; array3[4] = 117; array3[4] = 178; array3[4] = 95; array3[4] = 227; array3[5] = 182; array3[5] = 115; array3[5] = 86; array3[5] = 204; array3[6] = 75; array3[6] = 196; array3[6] = 19; array3[6] = 104; array3[6] = 188; array3[7] = 145; array3[7] = 131; array3[7] = 85; array3[7] = 195; array3[7] = 150; array3[7] = 63; array3[8] = 169; array3[8] = 83; array3[8] = 222; array3[9] = 164; array3[9] = 206; array3[9] = 190; array3[9] = 80; array3[9] = 60; array3[10] = 170; array3[10] = 163; array3[10] = 108; array3[11] = 125; array3[11] = 136; array3[11] = 137; array3[11] = 26; array3[12] = 96; array3[12] = 118; array3[12] = 138; array3[13] = 77; array3[13] = 91; array3[13] = 131; array3[13] = 117; array3[13] = 101; array3[13] = 14; array3[14] = 170; array3[14] = 211; array3[14] = 242; array3[15] = 196; array3[15] = 162; array3[15] = 47; array3[15] = 172; array3[15] = 207; array3[16] = 55; array3[16] = 132; array3[16] = 209; array3[16] = 148; array3[16] = 163; array3[17] = 99; array3[17] = 135; array3[17] = 45; array3[18] = 101; array3[18] = 82; array3[18] = 133; array3[18] = 84; array3[18] = 55; array3[19] = 72; array3[19] = 83; array3[19] = 96; array3[19] = 179; array3[19] = 131; array3[19] = 67; array3[20] = 92; array3[20] = 144; array3[20] = 118; array3[20] = 84; array3[20] = 114; array3[20] = 228; array3[21] = 128; array3[21] = 112; array3[21] = 52; array3[22] = 102; array3[22] = 165; array3[22] = 129; array3[22] = 154; array3[22] = 151; array3[22] = 43; array3[23] = 124; array3[23] = 97; array3[23] = 94; array3[23] = 188; array3[23] = 147; array3[23] = 89; array3[24] = 98; array3[24] = 71; array3[24] = 139; array3[24] = 23; array3[25] = 141; array3[25] = 166; array3[25] = 187; array3[26] = 97; array3[26] = 112; array3[26] = 130; array3[27] = 201; array3[27] = 31; array3[27] = 106; array3[27] = 98; array3[27] = 114; array3[27] = 29; array3[28] = 138; array3[28] = 150; array3[28] = 36; array3[28] = 122; array3[28] = 188; array3[29] = 95; array3[29] = 113; array3[29] = 212; array3[29] = 147; array3[29] = 138; array3[29] = 50; array3[30] = 83; array3[30] = 104; array3[30] = 56; array3[31] = 68; array3[31] = 65; array3[31] = 134; array3[31] = 243; Class1.byte_1 = array3; byte[] array4 = new byte[16]; array4[0] = 122; array4[0] = 163; array4[0] = 33; array4[1] = 54; array4[1] = 122; array4[1] = 107; array4[1] = 96; array4[1] = 122; array4[1] = 8; array4[2] = 104; array4[2] = 142; array4[2] = 131; array4[2] = 121; array4[2] = 13; array4[2] = 214; array4[3] = 164; array4[3] = 101; array4[3] = 157; array4[4] = 12; array4[4] = 132; array4[4] = 66; array4[4] = 129; array4[4] = 31; array4[5] = 137; array4[5] = 93; array4[5] = 112; array4[5] = 156; array4[5] = 107; array4[5] = 119; array4[6] = 160; array4[6] = 151; array4[6] = 146; array4[6] = 61; array4[6] = 86; array4[7] = 109; array4[7] = 146; array4[7] = 227; array4[8] = 134; array4[8] = 116; array4[8] = 147; array4[8] = 84; array4[8] = 133; array4[8] = 80; array4[9] = 136; array4[9] = 130; array4[9] = 96; array4[10] = 100; array4[10] = 117; array4[10] = 212; array4[10] = 124; array4[10] = 6; array4[11] = 49; array4[11] = 141; array4[11] = 144; array4[11] = 126; array4[11] = 154; array4[11] = 223; array4[12] = 108; array4[12] = 2; array4[12] = 152; array4[12] = 131; array4[13] = 139; array4[13] = 141; array4[13] = 139; array4[14] = 121; array4[14] = 119; array4[14] = 88; array4[14] = 23; array4[15] = 162; array4[15] = 156; array4[15] = 113; array4[15] = 190; array4[15] = 250; Class1.byte_2 = array4; if (bool_8) { try { Class1.smethod_5(); Class1.Class3 class2 = null; try { string str = Class1.Class2.string_0; string str2 = Class1.string_3 + "\\"; RegistryKey registryKey = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey = Registry.LocalMachine; } RegistryKey registryKey2 = registryKey.OpenSubKey(str + str2, false); if (registryKey2 != null) { Class1.Class3 class3 = new Class1.Class3(); class3.method_0((string)registryKey2.GetValue("1"), Class1.byte_1, Class1.byte_2); if (class2 == null) { class2 = class3; } if (class3.ulong_0 > class2.ulong_0) { class2 = class3; } } } catch { } try { if (Class0.smethod_5(type_0.Assembly).ToString().Length > 0 && File.Exists(Class0.smethod_5(type_0.Assembly).ToString())) { Class1.Class3 class4 = new Class1.Class3(); class4.method_0(Class1.smethod_8(Path.GetDirectoryName(Class0.smethod_5(type_0.Assembly).ToString()), Class1.string_2), Class1.byte_1, Class1.byte_2); if (class2 == null) { class2 = class4; } if (class4.ulong_0 > class2.ulong_0) { class2 = class4; } } } catch { } try { if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2)) { Class1.Class3 class5 = new Class1.Class3(); class5.method_0(Encoding.Unicode.GetString(Class1.smethod_11(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2)), Class1.byte_1, Class1.byte_2); if (class2 == null) { class2 = class5; } if (class5.ulong_0 > class2.ulong_0) { class2 = class5; } } } catch { } if (class2 == null) { class2 = new Class1.Class3(); } this.method_0(Environment.TickCount); class2.int_3 = this.method_3(10000000, 2147483646); try { string str3 = Class1.Class2.string_0; string str4 = Class1.string_3 + "\\"; RegistryKey registryKey3 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey3 = Registry.LocalMachine; } RegistryKey registryKey4; if (registryKey3.OpenSubKey(str3 + str4, false) == null) { registryKey3 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey3 = Registry.LocalMachine; } registryKey4 = registryKey3.CreateSubKey(str3 + str4); } registryKey3 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey3 = Registry.LocalMachine; } registryKey4 = registryKey3.OpenSubKey(str3 + str4, true); if (registryKey4 != null) { registryKey4.SetValue("1", class2.method_5(Class1.byte_1, Class1.byte_2)); registryKey4.Close(); } } catch { } try { if (Class0.smethod_5(type_0.Assembly).ToString().Length > 0 && File.Exists(Class0.smethod_5(type_0.Assembly).ToString())) { Class1.smethod_7(Path.GetDirectoryName(Class0.smethod_5(type_0.Assembly).ToString()), Class1.string_2, class2.method_5(Class1.byte_1, Class1.byte_2)); } } catch { } try { FileStream fileStream = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2, FileMode.Create, FileAccess.ReadWrite); byte[] bytes = Encoding.Unicode.GetBytes(class2.method_5(Class1.byte_1, Class1.byte_2)); fileStream.Write(bytes, 0, bytes.Length); fileStream.Close(); } catch { } ICryptoTransform transform = new RijndaelManaged { Mode = CipherMode.CBC }.CreateEncryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream = new MemoryStream(); CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write); byte[] array5 = new byte[0]; if (string_10.Length > 0) { array5 = Encoding.ASCII.GetBytes(string_10 + class2.int_3.ToString()); } else { array5 = Encoding.ASCII.GetBytes(Class1.smethod_3(true, false, true, true, false, false) + class2.int_3.ToString()); } cryptoStream.Write(array5, 0, array5.Length); cryptoStream.FlushFinalBlock(); array = memoryStream.ToArray(); License_DeActivator.string_0 = Convert.ToBase64String(array); memoryStream.Close(); cryptoStream.Close(); class2 = null; } catch { } return null; } System.ComponentModel.License result; if (bool_9) { try { Class1.smethod_5(); Class1.Class3 class6 = null; try { string str5 = Class1.Class2.string_0; string str6 = Class1.string_3 + "\\"; RegistryKey registryKey5 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey5 = Registry.LocalMachine; } RegistryKey registryKey6 = registryKey5.OpenSubKey(str5 + str6, false); if (registryKey6 != null) { Class1.Class3 class7 = new Class1.Class3(); class7.method_0((string)registryKey6.GetValue("1"), Class1.byte_1, Class1.byte_2); if (class6 == null) { class6 = class7; } if (class7.ulong_0 > class6.ulong_0) { class6 = class7; } } } catch { } try { if (Class0.smethod_5(type_0.Assembly).ToString().Length > 0 && File.Exists(Class0.smethod_5(type_0.Assembly).ToString())) { Class1.Class3 class8 = new Class1.Class3(); class8.method_0(Class1.smethod_8(Path.GetDirectoryName(Class0.smethod_5(type_0.Assembly).ToString()), Class1.string_2), Class1.byte_1, Class1.byte_2); if (class6 == null) { class6 = class8; } if (class8.ulong_0 > class6.ulong_0) { class6 = class8; } } } catch { } try { if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2)) { Class1.Class3 class9 = new Class1.Class3(); class9.method_0(Encoding.Unicode.GetString(Class1.smethod_11(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2)), Class1.byte_1, Class1.byte_2); if (class6 == null) { class6 = class9; } if (class9.ulong_0 > class6.ulong_0) { class6 = class9; } } } catch { } if (class6.int_3 == 0) { result = new Class1.Class12(this, ""); return result; } byte[] array6 = Convert.FromBase64String(string_10); ICryptoTransform transform2 = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream2 = new MemoryStream(); CryptoStream cryptoStream2 = new CryptoStream(memoryStream2, transform2, CryptoStreamMode.Write); byte[] array7 = array6; cryptoStream2.Write(array7, 0, array7.Length); cryptoStream2.FlushFinalBlock(); array = memoryStream2.ToArray(); memoryStream2.Close(); cryptoStream2.Close(); string @string = Encoding.Unicode.GetString(array, 0, array.Length); if (@string != null && @string.Length > 0 && @string.IndexOf(class6.int_3.ToString()) >= 0) { class6.int_3 = 0; try { string str7 = Class1.Class2.string_0; string str8 = Class1.string_3 + "\\"; RegistryKey registryKey7 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey7 = Registry.LocalMachine; } RegistryKey registryKey8; if (registryKey7.OpenSubKey(str7 + str8, false) == null) { registryKey7 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey7 = Registry.LocalMachine; } registryKey8 = registryKey7.CreateSubKey(str7 + str8); } registryKey7 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey7 = Registry.LocalMachine; } registryKey8 = registryKey7.OpenSubKey(str7 + str8, true); if (registryKey8 != null) { registryKey8.SetValue("1", class6.method_5(Class1.byte_1, Class1.byte_2)); registryKey8.Close(); } } catch { } try { if (Class0.smethod_5(type_0.Assembly).ToString().Length > 0 && File.Exists(Class0.smethod_5(type_0.Assembly).ToString())) { Class1.smethod_7(Path.GetDirectoryName(Class0.smethod_5(type_0.Assembly).ToString()), Class1.string_2, class6.method_5(Class1.byte_1, Class1.byte_2)); } } catch { } try { FileStream fileStream2 = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2, FileMode.Create, FileAccess.ReadWrite); byte[] bytes2 = Encoding.Unicode.GetBytes(class6.method_5(Class1.byte_1, Class1.byte_2)); fileStream2.Write(bytes2, 0, bytes2.Length); fileStream2.Close(); } catch { } result = new Class1.Class12(this, ""); return result; } result = null; return result; } catch { result = null; return result; } } ICryptoTransform transform3 = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream3 = new MemoryStream(); CryptoStream cryptoStream3 = new CryptoStream(memoryStream3, transform3, CryptoStreamMode.Write); cryptoStream3.Write(array2, 0, array2.Length); cryptoStream3.FlushFinalBlock(); array = memoryStream3.ToArray(); memoryStream3.Close(); cryptoStream3.Close(); binaryReader.Close(); if ([email protected]_0(array)) { try { Class1.TerminateProcess(Class1.GetCurrentProcess(), 1); } catch { } return null; } if ([email protected]_1(array)) { try { Class1.TerminateProcess(Class1.GetCurrentProcess(), 1); } catch { } return null; } if ([email protected]_13) { try { Class1.TerminateProcess(Class1.GetCurrentProcess(), 1); } catch { } return null; } if (bool_11) { ICryptoTransform transform4 = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream4 = new MemoryStream(); CryptoStream cryptoStream4 = new CryptoStream(memoryStream4, transform4, CryptoStreamMode.Write); cryptoStream4.Write(byte_3, 0, byte_3.Length); cryptoStream4.FlushFinalBlock(); byte[] array8 = memoryStream4.ToArray(); memoryStream4.Close(); cryptoStream4.Close(); if ([email protected]_0(array8)) { return null; } return new Class1.Class12(this, ""); } else { if (bool_12) { ICryptoTransform transform5 = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream5 = new MemoryStream(); CryptoStream cryptoStream5 = new CryptoStream(memoryStream5, transform5, CryptoStreamMode.Write); cryptoStream5.Write(byte_3, 0, byte_3.Length); cryptoStream5.FlushFinalBlock(); byte[] buffer = memoryStream5.ToArray(); memoryStream5.Close(); cryptoStream5.Close(); MemoryStream memoryStream6 = new MemoryStream(buffer); BinaryReader binaryReader2 = new BinaryReader(memoryStream6); memoryStream6.Position = 0L; byte[] array9 = binaryReader2.ReadBytes(binaryReader2.ReadInt32()); byte[] array10 = binaryReader2.ReadBytes((int)(memoryStream6.Length - 4L - (long)array9.Length)); binaryReader2.Close(); DataSignHelper.byte_0 = array10; return new Class1.Class12(this, ""); } @class.string_2 = ""; @class.int_0 = 5; @class.int_1 = 0; @class.bool_2 = false; @class.bool_4 = false; @class.bool_12 = false; @class.bool_13 = false; @class.bool_3 = false; Class1.Class4 class10 = null; if ([email protected]_16 && [email protected]_15 && [email protected]_17 && [email protected]_18 && [email protected]_19 && [email protected]_20 && [email protected]_21) { Class1.sortedList_0[type_0.Assembly.FullName] = true; Class1.sortedList_1[type_0.Assembly.FullName] = new Class1.Class12(this, ""); return new Class1.Class12(this, ""); } EvaluationMonitor.smethod_0().method_7((LicenseLocation)0); Class1.smethod_5(); bool flag = false; bool flag2 = false; Class1.Class3 class11 = null; try { string str9 = Class1.Class2.string_0; string str10 = Class1.string_3 + "\\"; RegistryKey registryKey9 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey9 = Registry.LocalMachine; } RegistryKey registryKey10 = registryKey9.OpenSubKey(str9 + str10, false); if (registryKey10 != null) { Class1.Class3 class12 = new Class1.Class3(); class12.method_0((string)registryKey10.GetValue("1"), Class1.byte_1, Class1.byte_2); if (class11 == null) { class11 = class12; } if (class12.ulong_0 > class11.ulong_0) { class11 = class12; } } } catch { } try { if (Class0.smethod_5(type_0.Assembly).ToString().Length > 0 && File.Exists(Class0.smethod_5(type_0.Assembly).ToString())) { Class1.Class3 class13 = new Class1.Class3(); class13.method_0(Class1.smethod_8(Path.GetDirectoryName(Class0.smethod_5(type_0.Assembly).ToString()), Class1.string_2), Class1.byte_1, Class1.byte_2); if (class11 == null) { class11 = class13; } if (class13.ulong_0 > class11.ulong_0) { class11 = class13; } } } catch { } try { if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2)) { Class1.Class3 class14 = new Class1.Class3(); class14.method_0(Encoding.Unicode.GetString(Class1.smethod_11(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2)), Class1.byte_1, Class1.byte_2); if (class11 == null) { class11 = class14; } if (class14.ulong_0 > class11.ulong_0) { class11 = class14; } } } catch { } if (class11 == null) { class11 = new Class1.Class3(); } bool flag3 = false; if (class11 != null && class11.int_3 > 0) { EvaluationMonitor.smethod_0().method_1((LicenseStatus)8); EvaluationMonitor.smethod_0().method_3((LicenseStatus)8); EvaluationMonitor.smethod_0().method_5((LicenseStatus)8); flag3 = true; Class1.sortedList_0[type_0.Assembly.FullName] = true; Class1.sortedList_1[type_0.Assembly.FullName] = new Class1.Class12(this, ""); } class11 = null; if (!flag3) { if (bool_7) { byte[] array11 = new byte[0]; if (string_11.Length > 0) { try { array11 = Class1.smethod_11(string_11); goto IL_1904; } catch { goto IL_1904; } } array11 = byte_3; IL_1904: if (array11.Length > 0) { Class1.Class4 class15 = new Class1.Class4(); array = new byte[0]; try { array2 = array11; ICryptoTransform transform6 = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream7 = new MemoryStream(); CryptoStream cryptoStream6 = new CryptoStream(memoryStream7, transform6, CryptoStreamMode.Write); cryptoStream6.Write(array2, 0, array2.Length); cryptoStream6.FlushFinalBlock(); array = memoryStream7.ToArray(); memoryStream7.Close(); cryptoStream6.Close(); } catch { array = new byte[0]; } if (array.Length > 0) { if (class15.method_0(array)) { bool flag4 = true; class15.method_1(array); if (class15.bool_4) { string text = Class1.smethod_3(class15.bool_6, class15.bool_7, class15.bool_11, class15.bool_5, class15.bool_8, class15.bool_9); if (text.Length == 29) { int num = 0; if (class15.bool_8 && class15.string_3.Substring(0, 4) != text.Substring(0, 4)) { num++; } if (class15.bool_6 && class15.string_3.Substring(5, 4) != text.Substring(5, 4)) { num++; } if (class15.bool_7 && class15.string_3.Substring(10, 4) != text.Substring(10, 4)) { num++; } if (class15.bool_11 && class15.string_3.Substring(15, 4) != text.Substring(15, 4)) { num++; } if (class15.bool_5 && class15.string_3.Substring(20, 4) != text.Substring(20, 4)) { num++; } if (class15.bool_9 && class15.string_3.Substring(25, 4) != text.Substring(25, 4)) { num++; } if (class15.int_1 - num < 0) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)5); flag4 = false; flag = true; } } else { flag = true; flag4 = false; EvaluationMonitor.smethod_0().method_5((LicenseStatus)5); } } if (flag4 && licenseContext_0 != null) { if (licenseContext_0.UsageMode == LicenseUsageMode.Runtime && !class15.bool_0) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)0); flag4 = false; } if (licenseContext_0.UsageMode == LicenseUsageMode.Designtime && !class15.bool_1) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)0); flag4 = false; } } if (class15.bool_13) { flag4 = false; } if (flag4) { class10 = class15; } if (flag4) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); bool flag5 = false; int k = 0; while (k < assemblies.Length) { bool flag6 = true; IDictionaryEnumerator enumerator = class10.hashtable_0.GetEnumerator(); while (enumerator.MoveNext()) { string a = enumerator.Key.ToString(); string b = enumerator.Value.ToString(); if (a == Class1.Class2.string_4) { if (this.method_11(assemblies[k], typeof(AssemblyVersionAttribute)) != b) { flag6 = false; } } else if (a == Class1.Class2.string_5) { if (this.method_11(assemblies[k], typeof(AssemblyCopyrightAttribute)) != b) { flag6 = false; } } else if (a == Class1.Class2.string_6) { if (this.method_11(assemblies[k], typeof(AssemblyTrademarkAttribute)) != b) { flag6 = false; } } else if (a == Class1.Class2.string_7) { if (this.method_11(assemblies[k], typeof(AssemblyCompanyAttribute)) != b) { flag6 = false; } } else if (a == Class1.Class2.string_8) { if (this.method_11(assemblies[k], typeof(AssemblyProductAttribute)) != b) { flag6 = false; } } else if (a == Class1.Class2.string_9) { if (this.method_11(assemblies[k], typeof(AssemblyDescriptionAttribute)) != b) { flag6 = false; } } else if (a == Class1.Class2.string_10) { if (this.method_11(assemblies[k], typeof(AssemblyTitleAttribute)) != b) { flag6 = false; } } else if (a == Class1.Class2.string_3 && this.method_11(assemblies[k], typeof(AssemblyName)) != b) { flag6 = false; } } if (!flag6) { k++; } else { flag5 = true; IL_1DBD: if (!flag5) { class10 = null; } if (class10 == null) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)6); flag2 = true; goto IL_1DD6; } goto IL_1DD6; } } goto IL_1DBD; } IL_1DD6: if (flag4 && class10 != null && class15.bool_2) { try { Class1.Class5 class16 = new Class1.Class5(class15.string_2); Random random = new Random(); byte[] array12 = new byte[16]; random.NextBytes(array12); byte[] array13 = new byte[byte_3.Length + 16]; Array.Copy(array12, 0, array13, 0, array12.Length); Array.Copy(byte_3, 0, array13, array12.Length, byte_3.Length); array12 = array13; byte[] array14 = class16.Activate(array12); byte[] buffer2 = new byte[0]; ICryptoTransform transform7 = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream8 = new MemoryStream(); CryptoStream cryptoStream7 = new CryptoStream(memoryStream8, transform7, CryptoStreamMode.Write); cryptoStream7.Write(array14, 0, array14.Length); cryptoStream7.FlushFinalBlock(); buffer2 = memoryStream8.ToArray(); memoryStream8.Close(); cryptoStream7.Close(); if (@class.method_0(buffer2)) { MemoryStream memoryStream9 = new MemoryStream(buffer2); BinaryReader binaryReader3 = new BinaryReader(memoryStream9); memoryStream9.Position = 0L; byte[] array15 = binaryReader3.ReadBytes(binaryReader3.ReadInt32()); byte[] array16 = binaryReader3.ReadBytes((int)(memoryStream9.Length - 4L - (long)array15.Length)); binaryReader3.Close(); if (Convert.ToBase64String(array12, 0, 16) != Convert.ToBase64String(array16, 0, 16)) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)7); class10 = null; } else if (array16[16] == 0) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)7); class10 = null; } } else { EvaluationMonitor.smethod_0().method_5((LicenseStatus)7); class10 = null; } } catch { EvaluationMonitor.smethod_0().method_5((LicenseStatus)7); class10 = null; } } if (class10 != null) { Class1.byte_0 = byte_3; if (class10.bool_10) { Class1.string_0 = class10.string_1; } else { Class1.string_0 = ""; } EvaluationMonitor.smethod_0().method_5((LicenseStatus)0); EvaluationMonitor.smethod_0().method_7((LicenseLocation)2); } } else { EvaluationMonitor.smethod_0().method_5((LicenseStatus)6); flag2 = true; } } } } else { if (class10 == null && @class.bool_23) { EvaluationMonitor.smethod_0().method_3((LicenseStatus)4); ArrayList arrayList = new ArrayList(); try { if (Assembly.GetCallingAssembly() != null) { arrayList.Add(Assembly.GetCallingAssembly()); } } catch { } try { if (Assembly.GetEntryAssembly() != null) { arrayList.Add(Assembly.GetEntryAssembly()); } } catch { } try { if (Assembly.GetExecutingAssembly() != null) { arrayList.Add(Assembly.GetExecutingAssembly()); } } catch { } arrayList.Add(type_0.Assembly); for (int l = 0; l < arrayList.Count; l++) { try { string text2 = @class.string_13.Replace(Class1.Class2.string_32, Class1.Class2.string_33); string[] manifestResourceNames = ((Assembly)arrayList[l]).GetManifestResourceNames(); for (int m = 0; m < manifestResourceNames.Length; m++) { try { if (manifestResourceNames[m].ToUpper().IndexOf(text2.ToUpper()) >= 0) { Class1.Class4 class17 = new Class1.Class4(); array = new byte[0]; byte[] array17 = new byte[0]; try { Stream manifestResourceStream = ((Assembly)arrayList[l]).GetManifestResourceStream(manifestResourceNames[m]); manifestResourceStream.Position = 0L; array2 = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(array2, 0, array2.Length); manifestResourceStream.Close(); array17 = array2; ICryptoTransform transform8 = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream10 = new MemoryStream(); CryptoStream cryptoStream8 = new CryptoStream(memoryStream10, transform8, CryptoStreamMode.Write); cryptoStream8.Write(array2, 0, array2.Length); cryptoStream8.FlushFinalBlock(); array = memoryStream10.ToArray(); memoryStream10.Close(); cryptoStream8.Close(); } catch { array = new byte[0]; } if (array.Length > 0) { if (class17.method_0(array)) { bool flag7 = true; class17.method_1(array); if (class17.bool_4) { string text3 = Class1.smethod_3(class17.bool_6, class17.bool_7, class17.bool_11, class17.bool_5, class17.bool_8, class17.bool_9); if (text3.Length == 29) { int num2 = 0; if (class17.bool_8 && class17.string_3.Substring(0, 4) != text3.Substring(0, 4)) { num2++; } if (class17.bool_6 && class17.string_3.Substring(5, 4) != text3.Substring(5, 4)) { num2++; } if (class17.bool_7 && class17.string_3.Substring(10, 4) != text3.Substring(10, 4)) { num2++; } if (class17.bool_11 && class17.string_3.Substring(15, 4) != text3.Substring(15, 4)) { num2++; } if (class17.bool_5 && class17.string_3.Substring(20, 4) != text3.Substring(20, 4)) { num2++; } if (class17.bool_9 && class17.string_3.Substring(25, 4) != text3.Substring(25, 4)) { num2++; } if (class17.int_1 - num2 < 0) { EvaluationMonitor.smethod_0().method_3((LicenseStatus)5); flag = true; flag7 = false; } } else { EvaluationMonitor.smethod_0().method_3((LicenseStatus)5); flag = true; flag7 = false; } } if (flag7 && licenseContext_0 != null) { if (licenseContext_0.UsageMode == LicenseUsageMode.Runtime && !class17.bool_0) { EvaluationMonitor.smethod_0().method_3((LicenseStatus)0); flag7 = false; } if (licenseContext_0.UsageMode == LicenseUsageMode.Designtime && !class17.bool_1) { EvaluationMonitor.smethod_0().method_3((LicenseStatus)0); flag7 = false; } } if (class17.bool_13) { flag7 = false; } if (flag7) { class10 = class17; } if (flag7) { IDictionaryEnumerator enumerator2 = class10.hashtable_0.GetEnumerator(); while (enumerator2.MoveNext()) { string a2 = enumerator2.Key.ToString(); string b2 = enumerator2.Value.ToString(); if (a2 == Class1.Class2.string_4) { if (this.method_11((Assembly)arrayList[l], typeof(AssemblyVersionAttribute)) != b2) { class10 = null; } } else if (a2 == Class1.Class2.string_5) { if (this.method_11((Assembly)arrayList[l], typeof(AssemblyCopyrightAttribute)) != b2) { class10 = null; } } else if (a2 == Class1.Class2.string_6) { if (this.method_11((Assembly)arrayList[l], typeof(AssemblyTrademarkAttribute)) != b2) { class10 = null; } } else if (a2 == Class1.Class2.string_7) { if (this.method_11((Assembly)arrayList[l], typeof(AssemblyCompanyAttribute)) != b2) { class10 = null; } } else if (a2 == Class1.Class2.string_8) { if (this.method_11((Assembly)arrayList[l], typeof(AssemblyProductAttribute)) != b2) { class10 = null; } } else if (a2 == Class1.Class2.string_9) { if (this.method_11((Assembly)arrayList[l], typeof(AssemblyDescriptionAttribute)) != b2) { class10 = null; } } else if (a2 == Class1.Class2.string_10) { if (this.method_11((Assembly)arrayList[l], typeof(AssemblyTitleAttribute)) != b2) { class10 = null; } } else if (a2 == Class1.Class2.string_3 && this.method_11((Assembly)arrayList[l], typeof(AssemblyName)) != b2) { class10 = null; } } if (class10 == null) { EvaluationMonitor.smethod_0().method_3((LicenseStatus)6); flag2 = true; } } if (flag7 && class10 != null && class17.bool_2) { try { Class1.Class5 class18 = new Class1.Class5(class17.string_2); Random random2 = new Random(); byte[] array18 = new byte[16]; random2.NextBytes(array18); byte[] array19 = new byte[array17.Length + 16]; Array.Copy(array18, 0, array19, 0, array18.Length); Array.Copy(array17, 0, array19, array18.Length, array17.Length); array18 = array19; byte[] array20 = class18.Activate(array18); byte[] buffer3 = new byte[0]; ICryptoTransform transform9 = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream11 = new MemoryStream(); CryptoStream cryptoStream9 = new CryptoStream(memoryStream11, transform9, CryptoStreamMode.Write); cryptoStream9.Write(array20, 0, array20.Length); cryptoStream9.FlushFinalBlock(); buffer3 = memoryStream11.ToArray(); memoryStream11.Close(); cryptoStream9.Close(); if (@class.method_0(buffer3)) { MemoryStream memoryStream12 = new MemoryStream(buffer3); BinaryReader binaryReader4 = new BinaryReader(memoryStream12); memoryStream12.Position = 0L; byte[] array21 = binaryReader4.ReadBytes(binaryReader4.ReadInt32()); byte[] array22 = binaryReader4.ReadBytes((int)(memoryStream12.Length - 4L - (long)array21.Length)); binaryReader4.Close(); if (Convert.ToBase64String(array18, 0, 16) != Convert.ToBase64String(array22, 0, 16)) { EvaluationMonitor.smethod_0().method_3((LicenseStatus)7); class10 = null; } else if (array22[16] == 0) { EvaluationMonitor.smethod_0().method_3((LicenseStatus)7); class10 = null; } } else { EvaluationMonitor.smethod_0().method_3((LicenseStatus)7); class10 = null; } } catch { EvaluationMonitor.smethod_0().method_3((LicenseStatus)7); class10 = null; } } if (class10 != null) { if (class10.bool_10) { Class1.string_0 = class10.string_1; } else { Class1.string_0 = ""; } Class1.byte_0 = array17; EvaluationMonitor.smethod_0().method_3((LicenseStatus)0); EvaluationMonitor.smethod_0().method_7((LicenseLocation)1); break; } } else { EvaluationMonitor.smethod_0().method_3((LicenseStatus)6); flag2 = true; } } } } catch { } } } catch { } } } if (class10 == null && @class.bool_24) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)4); ArrayList arrayList2 = new ArrayList(); if (File.Exists(Class1.smethod_1())) { arrayList2.Add(Path.GetDirectoryName(Class1.smethod_1()) + "\\"); } else if (Class0.smethod_5(type_0.Assembly).ToString().Length > 0 && File.Exists(Class0.smethod_5(type_0.Assembly).ToString())) { arrayList2.Add(Path.GetDirectoryName(Class0.smethod_5(type_0.Assembly).ToString()) + "\\"); } try { if (File.Exists(Class1.smethod_1()) && Class0.smethod_5(type_0.Assembly).ToString().Length > 0 && File.Exists(Class0.smethod_5(type_0.Assembly).ToString()) && Path.GetDirectoryName(Class1.smethod_1()).ToString() != Path.GetDirectoryName(Class0.smethod_5(type_0.Assembly).ToString()).ToString()) { arrayList2.Add(Path.GetDirectoryName(Class0.smethod_5(type_0.Assembly).ToString()) + "\\"); } } catch { } try { if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory) && arrayList2.IndexOf(AppDomain.CurrentDomain.BaseDirectory) < 0) { arrayList2.Add(AppDomain.CurrentDomain.BaseDirectory); } } catch { } try { if (Directory.Exists(AppDomain.CurrentDomain.SetupInformation.PrivateBinPath)) { arrayList2.Add(AppDomain.CurrentDomain.SetupInformation.PrivateBinPath); } } catch { } try { if (AppDomain.CurrentDomain.GetData("DataDirectory") != null) { string text4 = AppDomain.CurrentDomain.GetData("DataDirectory").ToString(); if (Directory.Exists(text4)) { arrayList2.Add(text4 + "\\"); } } } catch { } for (int n = 0; n < arrayList2.Count; n++) { try { string[] files = Directory.GetFiles((string)arrayList2[n], @class.string_13); for (int num3 = 0; num3 < files.Length; num3++) { try { Class1.Class4 class19 = new Class1.Class4(); array = new byte[0]; byte[] array23 = new byte[0]; try { FileStream fileStream3 = new FileStream(files[num3], FileMode.Open, FileAccess.Read); fileStream3.Position = 0L; array2 = new byte[fileStream3.Length]; fileStream3.Read(array2, 0, array2.Length); fileStream3.Close(); array23 = array2; ICryptoTransform transform10 = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream13 = new MemoryStream(); CryptoStream cryptoStream10 = new CryptoStream(memoryStream13, transform10, CryptoStreamMode.Write); cryptoStream10.Write(array2, 0, array2.Length); cryptoStream10.FlushFinalBlock(); array = memoryStream13.ToArray(); memoryStream13.Close(); cryptoStream10.Close(); } catch { array = new byte[0]; } if (array.Length > 0) { if (class19.method_0(array)) { bool flag8 = true; class19.method_1(array); if (class19.bool_4) { string text5 = Class1.smethod_3(class19.bool_6, class19.bool_7, class19.bool_11, class19.bool_5, class19.bool_8, class19.bool_9); if (text5.Length == 29) { int num4 = 0; if (class19.bool_8 && class19.string_3.Substring(0, 4) != text5.Substring(0, 4)) { num4++; } if (class19.bool_6 && class19.string_3.Substring(5, 4) != text5.Substring(5, 4)) { num4++; } if (class19.bool_7 && class19.string_3.Substring(10, 4) != text5.Substring(10, 4)) { num4++; } if (class19.bool_11 && class19.string_3.Substring(15, 4) != text5.Substring(15, 4)) { num4++; } if (class19.bool_5 && class19.string_3.Substring(20, 4) != text5.Substring(20, 4)) { num4++; } if (class19.bool_9 && class19.string_3.Substring(25, 4) != text5.Substring(25, 4)) { num4++; } if (class19.int_1 - num4 < 0) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)5); flag8 = false; flag = true; } } else { flag = true; flag8 = false; EvaluationMonitor.smethod_0().method_5((LicenseStatus)5); } } if (flag8 && licenseContext_0 != null) { if (licenseContext_0.UsageMode == LicenseUsageMode.Runtime && !class19.bool_0) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)0); flag8 = false; } if (licenseContext_0.UsageMode == LicenseUsageMode.Designtime && !class19.bool_1) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)0); flag8 = false; } } if (class19.bool_13) { flag8 = false; } if (flag8) { class10 = class19; } if (flag8) { Assembly[] assemblies2 = AppDomain.CurrentDomain.GetAssemblies(); bool flag9 = false; int num5 = 0; while (num5 < assemblies2.Length) { bool flag10 = true; IDictionaryEnumerator enumerator3 = class10.hashtable_0.GetEnumerator(); while (enumerator3.MoveNext()) { string a3 = enumerator3.Key.ToString(); string b3 = enumerator3.Value.ToString(); if (a3 == Class1.Class2.string_4) { if (this.method_11(assemblies2[num5], typeof(AssemblyVersionAttribute)) != b3) { flag10 = false; } } else if (a3 == Class1.Class2.string_5) { if (this.method_11(assemblies2[num5], typeof(AssemblyCopyrightAttribute)) != b3) { flag10 = false; } } else if (a3 == Class1.Class2.string_6) { if (this.method_11(assemblies2[num5], typeof(AssemblyTrademarkAttribute)) != b3) { flag10 = false; } } else if (a3 == Class1.Class2.string_7) { if (this.method_11(assemblies2[num5], typeof(AssemblyCompanyAttribute)) != b3) { flag10 = false; } } else if (a3 == Class1.Class2.string_8) { if (this.method_11(assemblies2[num5], typeof(AssemblyProductAttribute)) != b3) { flag10 = false; } } else if (a3 == Class1.Class2.string_9) { if (this.method_11(assemblies2[num5], typeof(AssemblyDescriptionAttribute)) != b3) { flag10 = false; } } else if (a3 == Class1.Class2.string_10) { if (this.method_11(assemblies2[num5], typeof(AssemblyTitleAttribute)) != b3) { flag10 = false; } } else if (a3 == Class1.Class2.string_3 && this.method_11(assemblies2[n], typeof(AssemblyName)) != b3) { flag10 = false; } } if (!flag10) { num5++; } else { flag9 = true; IL_2F4D: if (!flag9) { class10 = null; } if (class10 == null) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)6); flag2 = true; goto IL_2F66; } goto IL_2F66; } } goto IL_2F4D; } IL_2F66: if (flag8 && class10 != null && class19.bool_2) { try { Class1.Class5 class20 = new Class1.Class5(class19.string_2); Random random3 = new Random(); byte[] array24 = new byte[16]; random3.NextBytes(array24); byte[] array25 = new byte[array23.Length + 16]; Array.Copy(array24, 0, array25, 0, array24.Length); Array.Copy(array23, 0, array25, array24.Length, array23.Length); array24 = array25; byte[] array26 = class20.Activate(array24); byte[] buffer4 = new byte[0]; ICryptoTransform transform11 = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(Class1.byte_1, Class1.byte_2); MemoryStream memoryStream14 = new MemoryStream(); CryptoStream cryptoStream11 = new CryptoStream(memoryStream14, transform11, CryptoStreamMode.Write); cryptoStream11.Write(array26, 0, array26.Length); cryptoStream11.FlushFinalBlock(); buffer4 = memoryStream14.ToArray(); memoryStream14.Close(); cryptoStream11.Close(); if (@class.method_0(buffer4)) { MemoryStream memoryStream15 = new MemoryStream(buffer4); BinaryReader binaryReader5 = new BinaryReader(memoryStream15); memoryStream15.Position = 0L; byte[] array27 = binaryReader5.ReadBytes(binaryReader5.ReadInt32()); byte[] array28 = binaryReader5.ReadBytes((int)(memoryStream15.Length - 4L - (long)array27.Length)); binaryReader5.Close(); if (Convert.ToBase64String(array24, 0, 16) != Convert.ToBase64String(array28, 0, 16)) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)7); class10 = null; } else if (array28[16] == 0) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)7); class10 = null; } } else { EvaluationMonitor.smethod_0().method_5((LicenseStatus)7); class10 = null; } } catch (Exception) { EvaluationMonitor.smethod_0().method_5((LicenseStatus)7); class10 = null; } } if (class10 != null) { if (class10.bool_10) { Class1.string_0 = class10.string_1; } else { Class1.string_0 = ""; } Class1.byte_0 = array23; EvaluationMonitor.smethod_0().method_5((LicenseStatus)0); EvaluationMonitor.smethod_0().method_7((LicenseLocation)2); break; } } else { EvaluationMonitor.smethod_0().method_5((LicenseStatus)6); flag2 = true; } } } catch { } } } catch { } } } } } bool flag11 = false; bool flag12 = true; if (class10 != null) { flag11 = true; @class.bool_2 = class10.bool_2; @class.string_2 = class10.string_2; @class.bool_3 = class10.bool_3; @class.int_0 = class10.int_0; @class.int_1 = class10.int_1; @class.bool_12 = class10.bool_12; @class.hashtable_0 = class10.hashtable_0; @class.bool_4 = class10.bool_4; @class.string_3 = class10.string_3; @class.bool_6 = class10.bool_6; @class.bool_7 = class10.bool_7; @class.bool_5 = class10.bool_5; @class.bool_11 = class10.bool_11; @class.bool_8 = class10.bool_8; @class.bool_9 = class10.bool_9; if (!class10.bool_16 && !class10.bool_15 && !class10.bool_17 && !class10.bool_18 && !class10.bool_19 && !class10.bool_20 && !class10.bool_21) { flag12 = false; } if (!class10.bool_12) { flag12 = false; } else { @class.bool_21 = class10.bool_21; @class.bool_16 = class10.bool_16; @class.dateTime_0 = class10.dateTime_0; @class.bool_15 = class10.bool_15; @class.int_2 = class10.int_2; @class.bool_17 = class10.bool_17; @class.int_3 = class10.int_3; @class.bool_18 = class10.bool_18; @class.int_4 = class10.int_4; @class.bool_19 = class10.bool_19; @class.int_5 = class10.int_5; @class.bool_20 = class10.bool_20; @class.int_6 = class10.int_6; } } else { @class.bool_4 = false; @class.string_3 = Class1.Class2.string_11; @class.bool_6 = false; @class.bool_7 = false; @class.bool_5 = false; @class.bool_11 = false; @class.bool_8 = false; @class.bool_9 = false; @class.bool_2 = false; @class.string_2 = ""; @class.bool_3 = false; @class.int_0 = 0; @class.int_1 = 0; if ([email protected]_26) { Class1.Class7.timer_0 = new System.Threading.Timer(new TimerCallback(new Class1.Class7().method_0), null, 90000, 30000); if (@class.bool_31) { string message = @class.string_7; try { Class1.EnableWindow(Process.GetCurrentProcess().MainWindowHandle, false); } catch { } Class1.ShowMessage(message); } try { Class1.TerminateProcess(Class1.GetCurrentProcess(), 1); } catch { } return null; } } if (flag12 && @class.bool_21) { @class.bool_16 = false; @class.dateTime_0 = DateTime.Now; @class.bool_15 = false; @class.int_2 = 28; @class.bool_17 = false; @class.int_3 = 20; @class.bool_18 = false; @class.int_4 = 10; @class.bool_19 = false; @class.int_5 = 60; @class.bool_20 = false; @class.int_6 = 1; } if (flag11) { if (flag12) { EvaluationMonitor.smethod_0().method_1((LicenseStatus)2); } else { EvaluationMonitor.smethod_0().method_1((LicenseStatus)1); } } else if (@class.bool_21) { if (flag3) { EvaluationMonitor.smethod_0().method_1((LicenseStatus)8); } else if (flag) { EvaluationMonitor.smethod_0().method_1((LicenseStatus)5); } else if (flag2) { EvaluationMonitor.smethod_0().method_1((LicenseStatus)6); } else { EvaluationMonitor.smethod_0().method_1((LicenseStatus)4); } } else if (flag12) { EvaluationMonitor.smethod_0().method_1((LicenseStatus)2); } else { EvaluationMonitor.smethod_0().method_1((LicenseStatus)0); } if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)2) { EvaluationMonitor.smethod_0().method_5(EvaluationMonitor.smethod_0().method_0()); } if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)1) { EvaluationMonitor.smethod_0().method_3(EvaluationMonitor.smethod_0().method_0()); } EvaluationMonitor.smethod_0().method_43(@class.bool_21); EvaluationMonitor.smethod_0().method_27(@class.bool_17); EvaluationMonitor.smethod_0().method_23(@class.int_3); EvaluationMonitor.smethod_0().method_25(0); EvaluationMonitor.smethod_0().method_15(@class.bool_16); EvaluationMonitor.smethod_0().method_13(@class.dateTime_0); EvaluationMonitor.smethod_0().method_17(@class.bool_15); EvaluationMonitor.smethod_0().method_19(@class.int_2); EvaluationMonitor.smethod_0().method_21(0); EvaluationMonitor.smethod_0().method_33(@class.bool_19); EvaluationMonitor.smethod_0().method_35(@class.int_5); EvaluationMonitor.smethod_0().method_37(0); EvaluationMonitor.smethod_0().method_41(@class.bool_20); EvaluationMonitor.smethod_0().method_39(@class.int_6); EvaluationMonitor.smethod_0().method_29(@class.bool_18); EvaluationMonitor.smethod_0().method_31(@class.int_4); EvaluationMonitor.smethod_0().method_50().Clear(); if (class10 != null) { IDictionaryEnumerator enumerator4 = @class.hashtable_0.GetEnumerator(); while (enumerator4.MoveNext()) { EvaluationMonitor.smethod_0().method_50().Add(enumerator4.Key.ToString(), enumerator4.Value.ToString()); } } EvaluationMonitor.smethod_0().method_9(@class.bool_2); EvaluationMonitor.smethod_0().method_11(@class.string_2); EvaluationMonitor.smethod_0().method_49(@class.string_3); EvaluationMonitor.smethod_0().method_47(@class.bool_4); EvaluationMonitor.smethod_0().method_57(@class.bool_6); EvaluationMonitor.smethod_0().method_59(@class.bool_7); EvaluationMonitor.smethod_0().method_55(@class.bool_5); EvaluationMonitor.smethod_0().method_53(@class.bool_11); EvaluationMonitor.smethod_0().method_61(@class.bool_9); EvaluationMonitor.smethod_0().method_63(@class.bool_8); EvaluationMonitor.smethod_0().method_67(@class.int_1); EvaluationMonitor.smethod_0().method_65(@class.bool_12); Class1.smethod_5(); class11 = new Class1.Class3(); if (flag12) { if (@class.bool_34) { string string_12 = @class.string_11; Class1.ShowMessage(string_12); } if (@class.bool_21) { Class1.sortedList_0[type_0.Assembly.FullName] = true; Class1.sortedList_1[type_0.Assembly.FullName] = new Class1.Class12(this, ""); return new Class1.Class12(this, ""); } if (@class.bool_20) { try { string processName = Process.GetCurrentProcess().ProcessName; Process[] processesByName = Process.GetProcessesByName(processName); if (processesByName.Length > @class.int_6) { if (@class.bool_32) { string text6 = @class.string_8; text6 = text6.Replace(Class1.Class2.string_21, @class.int_6.ToString()); if (@class.bool_25) { try { Class1.EnableWindow(Process.GetCurrentProcess().MainWindowHandle, false); } catch { } } Class1.ShowMessage(text6); } if (@class.bool_25) { try { Class1.TerminateProcess(Class1.GetCurrentProcess(), 1); } catch { } result = null; return result; } } } catch { } } Class1.smethod_5(); class11 = null; try { string str11 = Class1.Class2.string_0; string str12 = Class1.string_3 + "\\"; RegistryKey registryKey11 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey11 = Registry.LocalMachine; } RegistryKey registryKey12 = registryKey11.OpenSubKey(str11 + str12, false); if (registryKey12 != null) { Class1.Class3 class21 = new Class1.Class3(); class21.method_0((string)registryKey12.GetValue("1"), Class1.byte_1, Class1.byte_2); if (class11 == null) { class11 = class21; } if (class21.ulong_0 > class11.ulong_0) { class11 = class21; } } } catch { } try { if (Class0.smethod_5(type_0.Assembly).ToString().Length > 0 && File.Exists(Class0.smethod_5(type_0.Assembly).ToString())) { Class1.Class3 class22 = new Class1.Class3(); class22.method_0(Class1.smethod_8(Path.GetDirectoryName(Class0.smethod_5(type_0.Assembly).ToString()), Class1.string_2), Class1.byte_1, Class1.byte_2); if (class11 == null) { class11 = class22; } if (class22.ulong_0 > class11.ulong_0) { class11 = class22; } } } catch { } try { if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2)) { Class1.Class3 class23 = new Class1.Class3(); class23.method_0(Encoding.Unicode.GetString(Class1.smethod_11(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2)), Class1.byte_1, Class1.byte_2); if (class11 == null) { class11 = class23; } if (class23.ulong_0 > class11.ulong_0) { class11 = class23; } } } catch { } if (class11 == null) { class11 = new Class1.Class3(); } try { class11.ulong_0 += 1uL; } catch { class11.ulong_0 = 0uL; } DateTime dateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); if (@class.bool_15) { class11.int_2 += Math.Abs(dateTime.Subtract(class11.dateTime_1).Days); } class11.dateTime_1 = dateTime; if (@class.bool_16) { if (DateTime.Compare(dateTime, class11.dateTime_0) >= 0) { class11.dateTime_0 = dateTime; } } else { class11.dateTime_0 = dateTime; } if (@class.bool_17) { class11.int_0++; } int num6 = 0; int num7 = 0; bool flag13 = false; bool flag14 = false; bool flag15 = false; bool flag16 = false; if (@class.bool_18 && @class.bool_22) { num6++; } if (@class.bool_19) { num6++; if (class11.int_1 >= @class.int_5) { num7++; flag16 = true; } } if (@class.bool_17) { num6++; if (class11.int_0 > @class.int_3) { num7++; flag15 = true; } } if (@class.bool_15) { num6++; if (class11.int_2 > @class.int_2) { num7++; flag14 = true; } } if (@class.bool_16) { num6++; if (class11.dateTime_0 >= @class.dateTime_0) { num7++; flag13 = true; } } if (@class.bool_17 && flag15 && class11.int_0 > @class.int_3 + 1 && ((@class.bool_22 && num6 == num7) || ([email protected]_22 && num7 > 0))) { EvaluationMonitor.smethod_0().method_1((LicenseStatus)3); if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)2) { EvaluationMonitor.smethod_0().method_5(EvaluationMonitor.smethod_0().method_0()); } if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)1) { EvaluationMonitor.smethod_0().method_3(EvaluationMonitor.smethod_0().method_0()); } if (@class.bool_25) { class11.int_0--; } } EvaluationMonitor.smethod_0().method_25(class11.int_0); EvaluationMonitor.smethod_0().method_21(class11.int_2); EvaluationMonitor.smethod_0().method_37(class11.int_1); try { string str13 = Class1.Class2.string_0; string str14 = Class1.string_3 + "\\"; RegistryKey registryKey13 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey13 = Registry.LocalMachine; } RegistryKey registryKey14; if (registryKey13.OpenSubKey(str13 + str14, false) == null) { registryKey13 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey13 = Registry.LocalMachine; } registryKey14 = registryKey13.CreateSubKey(str13 + str14); } registryKey13 = Registry.CurrentUser; if (Class1.smethod_0()) { registryKey13 = Registry.LocalMachine; } registryKey14 = registryKey13.OpenSubKey(str13 + str14, true); if (registryKey14 != null) { registryKey14.SetValue("1", class11.method_5(Class1.byte_1, Class1.byte_2)); registryKey14.Close(); } } catch { } try { if (Class0.smethod_5(type_0.Assembly).ToString().Length > 0 && File.Exists(Class0.smethod_5(type_0.Assembly).ToString())) { Class1.smethod_7(Path.GetDirectoryName(Class0.smethod_5(type_0.Assembly).ToString()), Class1.string_2, class11.method_5(Class1.byte_1, Class1.byte_2)); } } catch { } try { FileStream fileStream4 = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Class1.Class2.string_2 + Class1.string_2, FileMode.Create, FileAccess.ReadWrite); byte[] bytes3 = Encoding.Unicode.GetBytes(class11.method_5(Class1.byte_1, Class1.byte_2)); fileStream4.Write(bytes3, 0, bytes3.Length); fileStream4.Close(); } catch { } if ((@class.bool_22 && num6 == num7) || ([email protected]_22 && num7 > 0)) { if (flag13) { try { EvaluationMonitor.smethod_0().method_1((LicenseStatus)3); if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)2) { EvaluationMonitor.smethod_0().method_5(EvaluationMonitor.smethod_0().method_0()); } if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)1) { EvaluationMonitor.smethod_0().method_3(EvaluationMonitor.smethod_0().method_0()); } if (@class.bool_28) { string text7 = @class.string_5; text7 = text7.Replace(Class1.Class2.string_16, @class.dateTime_0.ToString()); text7 = text7.Replace(Class1.Class2.string_17, DateTime.Now.ToString()); if (@class.bool_25) { try { Class1.EnableWindow(Process.GetCurrentProcess().MainWindowHandle, false); } catch { } } Class1.ShowMessage(text7); } if (@class.bool_25) { try { Class1.TerminateProcess(Class1.GetCurrentProcess(), 1); } catch { } result = null; return result; } goto IL_43AF; } catch { goto IL_43AF; } } if (flag14) { try { EvaluationMonitor.smethod_0().method_1((LicenseStatus)3); if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)2) { EvaluationMonitor.smethod_0().method_5(EvaluationMonitor.smethod_0().method_0()); } if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)1) { EvaluationMonitor.smethod_0().method_3(EvaluationMonitor.smethod_0().method_0()); } if (@class.bool_27) { int num8 = @class.int_2 - class11.int_2; if (num8 < 0) { num8 = 0; } string text8 = @class.string_4; text8 = text8.Replace(Class1.Class2.string_12, class11.int_2.ToString()); text8 = text8.Replace(Class1.Class2.string_15, @class.int_2.ToString()); text8 = text8.Replace(Class1.Class2.string_13, num8.ToString()); if (@class.bool_25) { try { Class1.EnableWindow(Process.GetCurrentProcess().MainWindowHandle, false); } catch { } } Class1.ShowMessage(text8); } if (@class.bool_25) { try { Class1.TerminateProcess(Class1.GetCurrentProcess(), 1); } catch { } result = null; return result; } goto IL_43AF; } catch { goto IL_43AF; } } if (flag15) { try { EvaluationMonitor.smethod_0().method_1((LicenseStatus)3); if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)2) { EvaluationMonitor.smethod_0().method_5(EvaluationMonitor.smethod_0().method_0()); } if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)1) { EvaluationMonitor.smethod_0().method_3(EvaluationMonitor.smethod_0().method_0()); } if (@class.bool_29) { int num9 = @class.int_3 - class11.int_0; if (num9 < 0) { num9 = 0; } string text9 = @class.string_6; text9 = text9.Replace(Class1.Class2.string_18, class11.int_0.ToString()); text9 = text9.Replace(Class1.Class2.string_19, @class.int_3.ToString()); text9 = text9.Replace(Class1.Class2.string_20, num9.ToString()); if (@class.bool_25) { try { Class1.EnableWindow(Process.GetCurrentProcess().MainWindowHandle, false); } catch { } } Class1.ShowMessage(text9); } if (@class.bool_25) { try { Class1.TerminateProcess(Class1.GetCurrentProcess(), 1); } catch { } result = null; return result; } goto IL_43AF; } catch { goto IL_43AF; } } if (flag16) { try { EvaluationMonitor.smethod_0().method_1((LicenseStatus)3); if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)2) { EvaluationMonitor.smethod_0().method_5(EvaluationMonitor.smethod_0().method_0()); } if (EvaluationMonitor.smethod_0().method_6() == (LicenseLocation)1) { EvaluationMonitor.smethod_0().method_3(EvaluationMonitor.smethod_0().method_0()); } if (@class.bool_33) { int num10 = @class.int_5 - class11.int_1; if (num10 < 0) { num10 = 0; } string text10 = @class.string_9; text10 = text10.Replace(Class1.Class2.string_22, class11.int_1.ToString()); text10 = text10.Replace(Class1.Class2.string_23, @class.int_5.ToString()); text10 = text10.Replace(Class1.Class2.string_14, num10.ToString()); if (@class.bool_25) { try { Class1.EnableWindow(Process.GetCurrentProcess().MainWindowHandle, false); } catch { } } Class1.ShowMessage(text10); } if ([email protected]_25) { goto IL_43AF; } try { Class1.TerminateProcess(Class1.GetCurrentProcess(), 1); } catch { } result = null; } catch { goto IL_43AF; } return result; } } else { if (@class.bool_19) { Class1.Class10 class24 = new Class1.Class10(@class, class11, type_0, Class1.byte_1, Class1.byte_2); class24.timer_0 = new System.Threading.Timer(new TimerCallback(class24.method_0), null, 60000, 60000); } if (@class.bool_18) { Class1.Class6 class25 = new Class1.Class6(@class, type_0.Assembly); class25.timer_0 = new System.Threading.Timer(new TimerCallback(class25.method_0), null, @class.int_4 * 60000, @class.int_4 * 60000); } if (@class.bool_16 || @class.bool_15) { Class1.Class9 class26 = new Class1.Class9(@class, class11, type_0, Class1.byte_1, Class1.byte_2); Class1.Class8 class27 = new Class1.Class8(@class, class11, type_0, Class1.byte_1, Class1.byte_2); class26.class8_0 = class27; class27.class9_0 = class26; class26.int_1 = num7; class26.int_0 = num6; class27.int_1 = num7; class27.int_0 = num6; if (@class.bool_16 && !flag13) { class27.timer_0 = new System.Threading.Timer(new TimerCallback(class27.method_0), null, 60000, 60000); } if (@class.bool_15 && !flag14) { class26.timer_0 = new System.Threading.Timer(new TimerCallback(class26.method_0), null, 60000, 60000); } } } } IL_43AF: Class1.sortedList_0[type_0.Assembly.FullName] = true; Class1.sortedList_1[type_0.Assembly.FullName] = new Class1.Class12(this, ""); return new Class1.Class12(this, ""); } return result; }
// Organizes all sprites by associating them with the // material they use. Returns an array list of // MaterialSpriteLists: List<MaterialSpriteList> OrganizeByMaterial(ArrayList sprites) { string errString = ""; // A list of all materials ArrayList materials = new ArrayList(); // The map of materials to sprites List<MaterialSpriteList> map = new List<MaterialSpriteList>(); // The material of the sprite: Material mat; ISpriteAggregator sprite; MaterialSpriteList matSpriteList; int index; for (int i = 0; i < sprites.Count; ++i) { sprite = (ISpriteAggregator)sprites[i]; mat = sprite.GetPackedMaterial(out errString); if(mat == null) { if (haltOnNullMaterial) { EditorUtility.DisplayDialog("ERROR", errString, "Ok"); Selection.activeGameObject = sprite.gameObject; return null; } else { Debug.LogError(errorString); continue; } } index = materials.IndexOf(mat); // See if the material is already in our list: if (index >= 0) { matSpriteList = (MaterialSpriteList)map[index]; matSpriteList.sprites.Add(sprite); } else { materials.Add(mat); matSpriteList = new MaterialSpriteList(); matSpriteList.material = mat; matSpriteList.sprites.Add(sprite); map.Add(matSpriteList); } } return map; }
private void CompareObjects(ArrayList good, ArrayList bad, Hashtable hsh1) { DoIListTests(good, bad, hsh1); good.Clear(); for(int i=0; i<100; i++) good.Add(i); if(fVerbose) Console.WriteLine("CopyTo()"); Int32[] iArr1 = null; Int32[] iArr2 = null; iArr1 = new Int32[100]; iArr2 = new Int32[100]; good.CopyTo(iArr1); bad.CopyTo(iArr2); for(int i=0; i<100; i++) { if(iArr1[i] != iArr2[i]) hsh1["CopyTo"] = "()"; } iArr1 = new Int32[100]; iArr2 = new Int32[100]; good.CopyTo(0, iArr1, 0, 100); try { bad.CopyTo(0, iArr2, 0, 100); for(int i=0; i<100; i++) { if(iArr1[i] != iArr2[i]) hsh1["CopyTo"] = "()"; } } catch { hsh1["CopyTo"] = "(Int32, Array, Int32, Int32)"; } iArr1 = new Int32[200]; iArr2 = new Int32[200]; for(int i=0; i<200; i++) { iArr1[i]=50; iArr2[i]=50; } good.CopyTo(50, iArr1, 100, 20); try { bad.CopyTo(50, iArr2, 100, 20); for(int i=0; i<200; i++) { if(iArr1[i] != iArr2[i]) hsh1["CopyTo"] = "(Array, Int32, Int32)"; } } catch { hsh1["CopyTo"] = "(Int32, Array, Int32, Int32)"; } if(fVerbose) Console.WriteLine("Clone()"); ArrayList alstClone = (ArrayList)bad.Clone(); if(alstClone.Count != bad.Count) hsh1["Clone"] = "Count"; for(int i=0; i<bad.Count; i++) { if(alstClone[i] != bad[i]) hsh1["Clone"] = "[]"; } if(fVerbose) Console.WriteLine("GetEnumerator()"); IEnumerator ienm1 = null; IEnumerator ienm2 = null; ienm1 = good.GetEnumerator(0, 100); try { ienm2 = bad.GetEnumerator(0, 100); DoIEnumerableTest(ienm1, ienm2, hsh1, false); } catch { hsh1["GetEnumerator"] = "(Int32, Int32)"; } ienm1 = good.GetEnumerator(50, 50); try { ienm2 = bad.GetEnumerator(50, 50); DoIEnumerableTest(ienm1, ienm2, hsh1, false); } catch { hsh1["GetEnumerator"] = "(Int32, Int32)"; } try { bad.GetEnumerator(50, 150); hsh1["GetEnumerator"] = "(Int32, Int32)"; } catch(Exception) { } ienm1 = good.GetEnumerator(0, 100); try { ienm2 = bad.GetEnumerator(0, 100); good.RemoveAt(0); DoIEnumerableTest(ienm1, ienm2, hsh1, true); } catch { hsh1["GetEnumerator"] = "(Int32, Int32)"; } good.Clear(); for(int i=0; i<100; i++) good.Add(i); if(fVerbose) Console.WriteLine("GetRange()"); ArrayList alst1 = good.GetRange(0, good.Count); try { ArrayList alst2 = bad.GetRange(0, good.Count); for(int i=0; i<good.Count; i++) { if(alst1[i] != alst2[i]) hsh1["GetRange"] = i; } } catch { hsh1["Range"] = "(Int32, Int32)"; } if(bad.Count>0) { if(fVerbose) Console.WriteLine("IndexOf()"); for(int i=0; i<good.Count; i++) { if(good.IndexOf(good[i], 0) != bad.IndexOf(good[i], 0)) { Console.WriteLine(good .Count + " " + bad.Count + " " + good[i] + " " + bad[i] + " " + good.IndexOf(good[i], 0) + " " + bad.IndexOf(good[i], 0)); hsh1["IndexOf"] = "(Object, Int32)"; } if(good.IndexOf(good[i], i) != bad.IndexOf(good[i], i)) { Console.WriteLine("2" + good.IndexOf(good[i], i) + " " + bad.IndexOf(good[i], i)); hsh1["IndexOf"] = "(Object, Int32)"; } if(i<(good.Count-1)) { if(good.IndexOf(good[i], i+1) != bad.IndexOf(good[i], i+1)) { Console.WriteLine("3" + good.IndexOf(good[i], i+1) + " " + bad.IndexOf(good[i], i+1)); hsh1["IndexOf"] = "(Object, Int32)"; } } } try { bad.IndexOf(1, -1); } catch(ArgumentException) { } catch(Exception ex) { hsh1["IndexOf"] = ex; } try { bad.IndexOf(1, bad.Count); } catch(ArgumentException) { } catch(Exception ex) { hsh1["IndexOf"] = ex; } for(int i=0; i<good.Count; i++) { if(good.IndexOf(good[i], 0, good.Count-1) != bad.IndexOf(good[i], 0, good.Count-1)) { hsh1["IndexOf"] = "(Object, Int32, Int32)"; } if(good.IndexOf(good[i], i, good.Count-i) != bad.IndexOf(good[i], i, good.Count-i)) { hsh1["IndexOf"] = "(Object, Int32)"; } if(good.IndexOf(good[i], i, 0) != bad.IndexOf(good[i], i, 0)) { hsh1["IndexOf"] = "(Object, Int32)"; } if(i<(good.Count-1)) { if(good.IndexOf(good[i], i+1, good.Count-(i+1)) != bad.IndexOf(good[i], i+1, good.Count-(i+1))) { hsh1["IndexOf"] = "(Object, Int32)"; } } } try { bad.IndexOf(1, 0, -1); } catch(ArgumentException) { } catch(Exception ex) { hsh1["IndexOf"] = ex; } try { bad.IndexOf(1, 0, bad.Count); } catch(ArgumentException) { } catch(Exception ex) { hsh1["IndexOf"] = ex; } try { bad.IndexOf(1, bad.Count-1, bad.Count-2); } catch(ArgumentException) { } catch(Exception ex) { hsh1["IndexOf"] = ex; } if(fVerbose) Console.WriteLine("LastIndexOf(), " + good.Count + " " + bad.Count); for(int i=0; i<good.Count; i++) { if(good.LastIndexOf(good[i]) != bad.LastIndexOf(good[i])) { hsh1["LastIndexOf"] = "(Object)"; } if(good.LastIndexOf(i+1000) != bad.LastIndexOf(i+1000)) { hsh1["LastIndexOf"] = "(Object)"; } } try { bad.LastIndexOf(null); } catch(ArgumentException) { } catch(Exception ex) { hsh1["LastIndexOf"] = ex; } if(fVerbose) Console.WriteLine("LastIndexOf(Object, Int32)"); for(int i=0; i<good.Count; i++) { if(good.LastIndexOf(good[i], good.Count-1) != bad.LastIndexOf(good[i], good.Count-1)) { hsh1["LastIndexOf"] = "(Object, Int32)"; } if(good.LastIndexOf(good[i], 0) != bad.LastIndexOf(good[i], 0)) { hsh1["LastIndexOf"] = "(Object, Int32)"; } if(good.LastIndexOf(good[i], i) != bad.LastIndexOf(good[i], i)) { hsh1["LastIndexOf"] = "(Object, Int32)"; } if(i<(good.Count-1)) { if(good.LastIndexOf(good[i], i+1) != bad.LastIndexOf(good[i], i+1)) { hsh1["LastIndexOf"] = "(Object, Int32)"; } } } try { bad.LastIndexOf(1, -1); } catch(ArgumentException) { } catch(Exception ex) { hsh1["LastIndexOf"] = ex; } try { bad.LastIndexOf(1, bad.Count); } catch(ArgumentException) { } catch(Exception ex) { hsh1["LastIndexOf"] = ex; } for(int i=0; i<good.Count; i++) { if(good.LastIndexOf(good[i], good.Count-1, 0) != bad.LastIndexOf(good[i], good.Count-1, 0)) { hsh1["LastIndexOf"] = "(Object, Int32, Int32)"; } if(good.LastIndexOf(good[i], good.Count-1, i) != bad.LastIndexOf(good[i], good.Count-1, i)) { hsh1["LastIndexOf"] = "(Object, Int32)"; } if(good.LastIndexOf(good[i], i, i) != bad.LastIndexOf(good[i], i, i)) { hsh1["LastIndexOf"] = "(Object, Int32)"; } if(i<(good.Count-1)) { if(good.LastIndexOf(good[i], good.Count-1, i+1) != bad.LastIndexOf(good[i], good.Count-1, i+1)) { hsh1["LastIndexOf"] = "(Object, Int32)"; } } } try { bad.LastIndexOf(1, 1, -1); } catch(ArgumentException) { } catch(Exception ex) { hsh1["LastIndexOf"] = ex; } try { bad.LastIndexOf(1, bad.Count-2, bad.Count-1); } catch(ArgumentException) { } catch(Exception ex) { hsh1["LastIndexOf"] = ex; } } if(fVerbose) Console.WriteLine("ReadOnly()"); ArrayList alst3 = ArrayList.ReadOnly(bad); if(!alst3.IsReadOnly) hsh1["ReadOnly"] = "Not"; IList ilst1 = ArrayList.ReadOnly((IList)bad); if(!ilst1.IsReadOnly) hsh1["ReadOnly"] = "Not"; if(fVerbose) Console.WriteLine("Synchronized()"); alst3 = ArrayList.Synchronized(bad); if(!alst3.IsSynchronized) hsh1["Synchronized"] = "Not"; ilst1 = ArrayList.Synchronized((IList)bad); if(!ilst1.IsSynchronized) hsh1["Synchronized"] = "Not"; if(good.Count == bad.Count) { if(fVerbose) Console.WriteLine("ToArray()"); Object[] oArr1 = good.ToArray(); Object[] oArr2 = bad.ToArray(); for(int i=0; i<good.Count; i++) { if((Int32)oArr1[i] != (Int32)oArr2[i]) hsh1["ToArray"] = "()"; } iArr1 = (Int32[])good.ToArray(typeof(Int32)); iArr2 = (Int32[])bad.ToArray(typeof(Int32)); for(int i=0; i<good.Count; i++) { if(iArr1[i] != iArr2[i]) hsh1["ToArray"] = "(Type)"; } } if(fVerbose) Console.WriteLine("Capacity()"); if(good.Capacity != bad.Capacity) { hsh1["Capacity"] = "get"; } if(!hsh1.ContainsKey("IsReadOnly")) { good.Clear(); for(int i=100; i>0; i--) good.Add(i); if(fVerbose) Console.WriteLine("Sort() & BinarySearch()"); bad.Sort(); for(int i=0; i<bad.Count-1; i++) { if((Int32)bad[i] > (Int32)bad[i+1]) hsh1["Sort"] = "()"; } for(int i=0; i<bad.Count; i++) { if(bad.BinarySearch(bad[i]) != i) hsh1["BinarySearch"] = "(Object)"; } bad.Reverse(); if(bad.Count>0) { for(int i=0; i<99; i++) { if((Int32)bad[i] < (Int32)bad[i+1]) hsh1["Reverse"] = "()"; } good.Clear(); for(int i=100; i>0; i--) good.Add(i.ToString()); } good.Clear(); for(int i=90; i>64; i--) good.Add(((Char)i).ToString()); try { bad.Sort(new CaseInsensitiveComparer()); if(bad.Count>0) { for(int i=0; i<(bad.Count-1); i++) { if(((String)bad[i]).CompareTo(((String)bad[i+1])) >= 0) hsh1["Sort"] = "(IComparer)"; } for(int i=0; i<bad.Count; i++) { if(bad.BinarySearch(bad[i], new CaseInsensitiveComparer()) != i) hsh1["BinarySearch"] = "(Object, IComparer)"; } } bad.Reverse(); good.Clear(); for(int i=65; i<91; i++) good.Add(((Char)i).ToString()); if(bad.Count>0) { for(int i=0; i<good.Count; i++) { if(bad.BinarySearch(0, bad.Count, bad[i], new CaseInsensitiveComparer()) != i) hsh1["BinarySearch"] = "(Int32, Int32, Object, IComparer)"; } } } catch(Exception) { } good.Clear(); for(int i=0; i<100; i++) good.Add(i); if(fVerbose) Console.WriteLine("SetRange()"); Queue que = new Queue(); for(int i=0; i<100; i++) que.Enqueue(i+5000); try { bad.SetRange(0, que); } catch(Exception ex) { hsh1["SetRange"] = "Copy_ExceptionType, " + ex.GetType().Name; } for(int i=bad.Count; i<bad.Count; i++) { if((Int32)bad[i] != (i + 5000)) { hsh1["SetRange"] = i; } } } else { good.Clear(); for(int i=100; i>0; i--) good.Add(i); try { bad.Sort(); hsh1["Sort"] = "Copy"; } catch(NotSupportedException) { } catch(Exception) { hsh1["Sort"] = "Copy_ExceptionType"; } try { bad.Reverse(); hsh1["Reverse"] = "Copy"; } catch(NotSupportedException) { } catch(Exception ex) { hsh1["Reverse"] = "Copy_ExceptionType, " + ex.GetType().Name; } try { bad.Sort(new CaseInsensitiveComparer()); hsh1["Sort"] = "Copy - Icomparer"; } catch(NotSupportedException) { } catch(Exception) { hsh1["Sort"] = "Copy_ExceptionType"; } try { bad.Sort(0, 0, new CaseInsensitiveComparer()); hsh1["Sort"] = "Copy - Int32, Int32, IComparer"; } catch(NotSupportedException) { } catch(Exception) { hsh1["Sort"] = "Copy_ExceptionType"; } try { for(int i=0; i<bad.Count; i++) { if(bad.BinarySearch(bad[i]) != i) hsh1["BinarySearch"] = "(Object)"; } hsh1["BinarySearch"] = "(Object)"; } catch(NotSupportedException) { } catch(Exception ex) { hsh1["BinarySearch"] = ex.GetType().Name; } try { for(int i=0; i<bad.Count; i++) { if(bad.BinarySearch(bad[i], new CaseInsensitiveComparer()) != i) hsh1["BinarySearch"] = "(Object)"; } hsh1["BinarySearch"] = "Exception not thrown, (Object, IComparer)"; } catch(NotSupportedException) { } catch(Exception ex) { hsh1["BinarySearch"] = ex.GetType().Name; } try { for(int i=0; i<bad.Count; i++) { if(bad.BinarySearch(0, bad.Count, bad[i], new CaseInsensitiveComparer()) != i) hsh1["BinarySearch"] = "(Object)"; } hsh1["BinarySearch"] = "Exception not thrown, (Object, IComparer)"; } catch(NotSupportedException) { } catch(Exception ex) { hsh1["BinarySearch"] = ex.GetType().Name; } good.Clear(); for(int i=0; i<100; i++) good.Add(i); Queue que = new Queue(); for(int i=0; i<100; i++) que.Enqueue(i+5000); try { bad.SetRange(0, que); hsh1["Sort"] = "Copy - Int32, Int32, IComparer"; } catch(NotSupportedException) { } catch(Exception) { hsh1["Sort"] = "Copy_ExceptionType"; } } if(!hsh1.ContainsKey("IsReadOnly") && !hsh1.ContainsKey("Fixed")) { good.Clear(); for(int i=0; i<100; i++) good.Add(i); if(fVerbose) Console.WriteLine("InsertRange()"); Queue que = new Queue(); for(int i=0; i<100; i++) que.Enqueue(i+5000); bad.InsertRange(0, que); for(int i=0; i<100; i++) { if((Int32)bad[i] != i + 5000) { hsh1["InsertRange"] = i; } } if(fVerbose) Console.WriteLine("AddRange()"); que = new Queue(); for(int i=0; i<100; i++) que.Enqueue(i+2222); bad.AddRange(que); for(int i=bad.Count-100; i<bad.Count; i++) { if((Int32)bad[i] != (i-(bad.Count-100)) + 2222) { hsh1["AddRange"] = i + " " + (Int32)bad[i]; } } if(fVerbose) Console.WriteLine("RemoveRange()"); bad.RemoveRange(0, que.Count); for(int i=0; i<100; i++) { if((Int32)bad[i] != i) { hsh1["RemoveRange"] = i + " " + (Int32)bad[i]; } } try { bad.Capacity = bad.Capacity*2; } catch(Exception ex) { hsh1["Capacity"] = ex.GetType().Name; } try { bad.Capacity = -1; hsh1["Capacity"] = "No_Exception_Thrown, -1"; } catch(ArgumentException) { } catch(Exception ex) { hsh1["Capacity"] = ex.GetType().Name; } Int32 iMakeSureThisDoesNotCause = 0; while(bad.Capacity == bad.Count) { if(iMakeSureThisDoesNotCause++>100) break; bad.Add(bad.Count); } if(iMakeSureThisDoesNotCause>100) hsh1["TrimToSize"] = "Monekeyed, " + bad.Count + " " + bad.Capacity; try { bad.TrimToSize(); if(bad.Capacity != bad.Count) { hsh1["TrimToSize"] = "Problems baby"; } } catch(Exception ex) { hsh1["TrimToSize"] = ex.GetType().Name; } } else { Queue que = new Queue(); for(int i=0; i<100; i++) que.Enqueue(i+5000); try { bad.AddRange(que); hsh1["AddRange"] = "Copy"; } catch(NotSupportedException) { } catch(Exception) { hsh1["AddRange"] = "Copy_ExceptionType"; } try { bad.InsertRange(0, que); hsh1["InsertRange"] = "Copy"; } catch(NotSupportedException) { } catch(Exception) { hsh1["InsertRange"] = "Copy_ExceptionType"; } good.Clear(); for(int i=0; i<10; i++) good.Add(i); try { bad.RemoveRange(0, 10); hsh1["RemoveRange"] = "Copy"; } catch(NotSupportedException) { } catch(Exception ex) { hsh1["RemoveRange"] = "Copy_ExceptionType, " + ex.GetType().Name; } try { bad.Capacity = bad.Capacity*2; hsh1["Capacity"] = "No_Exception_Thrown, bad.Capacity*2"; } catch(NotSupportedException) { } catch(Exception ex) { hsh1["Capacity"] = ex.GetType().Name; } try { bad.TrimToSize(); hsh1["TrimToSize"] = "No_Exception_Thrown"; } catch(NotSupportedException) { } catch(Exception ex) { hsh1["TrimToSize"] = ex.GetType().Name; } } }
private string CheckDup_Chan_NO() { string strMsg = ""; int iDup = 0; ArrayList arrDupData = new ArrayList(); for (int i = 0; i < Repeater1.Items.Count; i++) { iDup = 0; string strCHAN_NO1 = ((Label)Repeater1.Items[i].FindControl("lblCHAN_NO")).Text; if (arrDupData.IndexOf(strCHAN_NO1) == -1) { for (int j = 0; j < Repeater1.Items.Count; j++) { string strCHAN_NO2 = ((Label)Repeater1.Items[j].FindControl("lblCHAN_NO")).Text; if (strCHAN_NO1 == strCHAN_NO2) iDup++; } if (iDup > 1) { arrDupData.Add(strCHAN_NO1); strMsg += "配本通路[" + strCHAN_NO1 + "]有重複資料<br/>"; } } } return strMsg; }
public static ArrayList arreglar_dato(string texto, ref List<string> x, ref double [] y) { //Retorna palabras clave y cantidad en total en documento bool eliminar_numeros = true; bool contar_misma_frase_misma_palabra = true; //Tokenizacion texto = texto.Replace('"', ' ').Replace('-', ' ').Replace('(', ' ').Replace(')', ' '); string pattern = ""; string replacement = " "; pattern = "[!'$%&/=?¡¿><_*.:]"; texto = Regex.Replace(texto, pattern, replacement); texto = texto.Replace("\r\n", "enterenterenter"); texto = texto.Replace(",enterenterenter", ""); pattern = "\\s+"; texto = Regex.Replace(texto, pattern, replacement); string consignos = "áàäéèëíìïóòöúùuñÁÀÄÉÈËÍÌÏÓÒÖÚÙÜÑçÇ"; string sinsignos = "aaaeeeiiiooouuunAAAEEEIIIOOOUUUNcC"; for (int v = 0; v < sinsignos.Length; v++) { string i = consignos.Substring(v, 1); string j = sinsignos.Substring(v, 1); texto = texto.Replace(i, j); } texto = texto.ToLower(); MatchCollection m1 = Regex.Matches(texto, "enterenterenter"); String[] stringSeparators = { "enterenterenter" }; // txtchar.Text = m1.Count.ToString(); string[] valores = texto.Split(stringSeparators, m1.Count, StringSplitOptions.RemoveEmptyEntries); //Borrar Stopwords ArrayList arrpalabras_descartadas = new ArrayList(new[] { "de","se","a","en","del","este","a","la","para","al","ya","lo" ,"que","sin","es","cual","e","m","le","el","con","por","ante","bajo","de", "sobre","tras","las","esta","si", "de","la","que","el","en","y","a","los","del","se","las","por","un","para","con","no","una","su","al","es","lo","como","más","pero","sus","le","ya","o","fue","este","ha","sí","porque","esta","cuando","muy","sín","sobre","ser","tíene","también","me","hasta","hay","donde","han","quien","están","estado","desde","todo","nos","durante","estados","todos","uno","les","ní","contra","otros","fueron","ese","eso","Habá","ante","ellos","e","esto","mí","antes","algunos","qué","unos","yo","otro","otras","otra","él","tanto","esa","estos","mucho","quienes","nada","sea","poco","ella","estar","haber","estas","estaba","estamos","algunas","algo","nosotros","mi","mis","Tú","te","tí","tu","tus","ellas","nosotras","vosotros","vosotas","os","mío","míos","mías","tuyo","tuya","tuyos","tuyas","nuestro","nuestra","nuestros","nuestras","vuestro","vuestra","vuestros","vuestras","esos","esas", "estoy","estás","estamos","estais","están","esté","estés","estemos","estéis","estén","estaré","estarás","estará","estaremos","estaréis","estarán","estaría","estarías","estaríamos","estaríais","estarían","estaba","estabas","estabamos","estabais","estaban","estuve","estuviste","estuvo","estuvimos","estuvisteis","estuvieron","estuviera","estuvieras","estuvieramos","estuvierais","estuvieran","estuviese","estuvieses","estuviésemos","estuvieseis","estuviesen","estando","estada","estados","estadas","estad", "he","has","ha","hemos","habeís","hay","haya","hayas","hayamos","hayáis","hayan","habre","habrás","habrá","habremos","habréis","habrán","habría","habrías","habríamos","habríais","habrían","había","habías","habíamos","habíais","habían","hube","hubiste","hubo","hubimos","hubisteis","hubieron","hubiera","hubieras","hubiéramos","hubieraís","hubiesen","habiendo","habido","habidos","habidas", "soy","eres","es","somos","soís","son","seas","seamos","seáis","será","seremos","seréis","serán","sería","serías","seríamos","seríais","serían","era","eras","éramos","erais","eran","fuí","fusite","fue","fuimos","fuisteis","fueron","fuera","fueras","fuéramos","fuerais","fueran","fuese","sueses","fuésemos","fuesen","siendo","sido", "tengo","tienes","tiene","tenemos","tenéis","tienen","tenga","tengas","tengamos","tengáis","tengan","tendre","tendrás","tendrá","tendremos","tendréis","tendrán","tendría","tendrías","tendríamos","tendríais","tendrían","tenía","tenías","teníamos","tenían","tuve","tuviste","tuvo","tuvimos","tuvisteis","tuvieron","tuviera","tuvieras","tuviéramos","tuvierais","tuvieran","tuviese","tuvieses","tuviésemos","tuvieseis","tuviesen","teniendo","tenido","tenida","tenidos","tenidas","tened" }); //Fin Tokenizacion ArrayList arrdatos = new ArrayList(); SortedList hs1 = new SortedList(); ArrayList arrpalabras_clave = new ArrayList(); int n = 0; int cantidad_sumados = 0; int cantidad_maxima = 0; ArrayList arrvalores_indice = new ArrayList(); string objetivo = ""; ArrayList arrobjetivo = new ArrayList(); arrobjetivo.Add("*****palabraclave*****"); arrpalabras_clave.Add("*****palabraclave*****"); ArrayList arrvalores_ind_objetivo = new ArrayList(); y = new double[valores.Length]; while (n < valores.Length) { string[] arrtmp = valores[n].Replace("enterenterenter","").Split(','); objetivo = arrtmp[arrtmp.Length-1]; int indice_objetivo=0; indice_objetivo = arrobjetivo.IndexOf(objetivo); if (indice_objetivo==-1) { indice_objetivo = arrobjetivo.Count; arrobjetivo.Add(objetivo); } arrvalores_ind_objetivo.Add(indice_objetivo); y[n] = indice_objetivo; arrtmp[arrtmp.Length - 1] = ""; string temp = String.Join("", arrtmp); temp = temp.Replace(",", "").Replace(".", ""); Hashtable hs2 = new Hashtable(); hs2["dato"] = temp; arrdatos.Add(hs2); string[] arr1 = temp.Split(' '); ArrayList arragregados = new ArrayList(); //Por frase SortedList srpalabras = new SortedList(); int m = 0; while (m < arr1.Length) { if (arr1[m].Trim() != "") { bool agrega = false; if (((arragregados.IndexOf(arr1[m]) == -1) || (contar_misma_frase_misma_palabra == true)) && (arrpalabras_descartadas.IndexOf(arr1[m]) == -1) && (arr1[m].Length != 1) ) agrega = true; Int64 int64Val; if (eliminar_numeros == true) { if (Int64.TryParse(arr1[m], NumberStyles.Number, null, out int64Val)) { agrega = false; } } if (agrega == true) { arragregados.Add(arr1[m]); int indice_palabra = arrpalabras_clave.IndexOf(arr1[m]); if (indice_palabra == -1) { indice_palabra = arrpalabras_clave.Count; arrpalabras_clave.Add(arr1[m]); hs1[arr1[m]] = 1; cantidad_sumados++; } else { hs1[arr1[m]] = Convert.ToInt32(hs1[arr1[m]].ToString()) + 1; cantidad_sumados++; } if(srpalabras[indice_palabra]==null) { srpalabras[indice_palabra] = 1; } else { srpalabras[indice_palabra] = (int)srpalabras[indice_palabra] + 1; } if (Convert.ToInt32(hs1[arr1[m]].ToString()) > cantidad_maxima) { cantidad_maxima = Convert.ToInt32(hs1[arr1[m]].ToString()); } } } m++; } arrvalores_indice.Add(srpalabras); string consolidado = ""; foreach (int llave_ind in srpalabras.Keys) { consolidado=consolidado+llave_ind+":"+srpalabras[llave_ind].ToString()+ " "; } if (consolidado.Length > 0) consolidado = consolidado.Substring(0, consolidado.Length - 1); x.Add(consolidado); n++; } return arrvalores_indice; //texto = Regex.Replace(texto, pattern, replacement); // txttemp.Text = texto; }
public static void Optimize(ArrayList list) { for (int i = 1; i < list.Count; i++) { X86Code x0 = list[i] as X86Code; if (x0 == null || x0.ignore || x0.IsBrTarget) continue; ArrayList listx = new ArrayList(); listx.Add(x0); for (int j = 1;; j++) { X86Code xx = GetPrevious(list, i, j); if (xx == null) break; listx.Add(xx); } if (listx.Count < 2) continue; X86Code[] x = listx.ToArray(typeof(X86Code)) as X86Code[]; if (IsMovEtc(x[0].Mnemonic) && !IsXS(x[0].Operand1) && IsXX(x[0].Operand2) && x[0].Operand1 != x[0].Operand2) { for (int j = 1; j < x.Length; j++) { if (x[j].Mnemonic == "mov" && x[j].Operand1 == x[0].Operand2 && !IsXS(x[j].Operand2) && !(IsAddr(x[0].Operand1) && IsAddr(x[j].Operand2))) { if (x[0].Operand1 != x[j].Operand2 && (IsXX(x[0].Operand1) || IsXX(x[j].Operand2))) { x[j].Ignore(); x[0].Ignore(); X86Code xx = new X86Code(x[0].Mnemonic, x[0].Operand1, x[j].Operand2); xx.Notes = "[optimize] add"; list.Insert(i + 1, xx); } } else if (IsMovEtc(x[j].Mnemonic) && x[j].Operand1 != x[0].Operand2) { continue; } break; } if (x[0].ignore) continue; } switch (x[0].Mnemonic) { case "pop": { Hashtable t = new Hashtable(); for (int j = 1; j < x.Length; j++) { if (x[j].Mnemonic == "push") { if (!t.Contains(x[j].Operand1)) { if (x[j].Operand1 == x[0].Operand1) { x[j].Ignore(); x[0].Ignore(); } else if (IsXX(x[j].Operand1) || IsXX(x[0].Operand1)) { x[j].Ignore(); x[0].Ignore(); X86Code xx = new X86Code("mov", x[0].Operand1, x[j].Operand1); xx.Notes = "[optimize] add"; list.Insert(i + 1, xx); } } else if (!t.Contains(x[0].Operand1)) { if (IsXX(x[j].Operand1) || IsXX(x[0].Operand1)) { x[j].Ignore(); x[0].Ignore(); X86Code xx = new X86Code("mov", x[0].Operand1, x[j].Operand1); xx.Notes = "[optimize] add"; i = list.IndexOf(x[j]); list.Insert(i + 1, xx); } } } else if (IsMovEtc(x[j].Mnemonic)) { t[x[j].Operand1] = true; continue; } break; } break; } case "cmp": if (IsXX(x[0].Operand1) && IsDigit(x[0].Operand2)) { for (int j = 1; j < x.Length; j++) { if (x[j].Mnemonic == "mov" && x[j].Operand1 == x[0].Operand1) { x[j].Ignore(); x[0].Ignore(); X86Code xx = new X86Code("cmp", x[j].Operand2, x[0].Operand2); xx.Notes = "[optimize] add"; list.Insert(i + 1, xx); } else if (IsMovEtc(x[j].Mnemonic) && x[j].Operand1 != x[0].Operand1) { continue; } break; } } break; case "je": case "jne": case "jz": case "jnz": if (x[1].Mnemonic == "cmp" && IsXX(x[1].Operand1) && !IsDigit(x[1].Operand2)) { for (int j = 2; j < x.Length; j++) { if (x[j].Mnemonic == "mov" && x[j].Operand1 == x[1].Operand1) { x[j].Ignore(); x[1].Ignore(); X86Code xx = new X86Code("cmp", x[1].Operand2, x[j].Operand2); xx.Notes = "[optimize] add"; i = list.IndexOf(x[1]); list.Insert(i + 1, xx); } else if (IsMovEtc(x[j].Mnemonic) && x[j].Operand1 != x[1].Operand1) { continue; } break; } } break; case "mov": if (x.Length > 2 && IsAddEtc(x[1].Mnemonic) && x[2].Mnemonic == "mov" && x[0].Operand2 == x[1].Operand1 && x[1].Operand1 == x[2].Operand1) { if (x[1].Mnemonic == "inc" || x[1].Mnemonic == "dec") { x[2].Ignore(); x[1].Ignore(); x[0].Ignore(); X86Code xx = new X86Code(x[1].Mnemonic, x[0].Operand1); xx.Notes = "[optimize] add"; list.Insert(i + 1, xx); } else if (x[0].Operand1 == x[1].Operand2 && !IsAddr(x[2].Operand2)) { x[2].Ignore(); x[1].Ignore(); x[0].Ignore(); X86Code xx = new X86Code(x[1].Mnemonic, x[0].Operand1, x[2].Operand2); xx.Notes = "[optimize] add"; list.Insert(i + 1, xx); } else if (x[0].Operand1 == x[2].Operand2 && !IsAddr(x[1].Operand2)) { x[2].Ignore(); x[1].Ignore(); x[0].Ignore(); X86Code xx = new X86Code(x[1].Mnemonic, x[0].Operand1, x[1].Operand2); xx.Notes = "[optimize] add"; list.Insert(i + 1, xx); } } break; case "add": if (x[0].Operand2 == "1") { x[0].Ignore(); X86Code xx = new X86Code("inc", x[0].Operand1); xx.Notes = "[Optimize] add"; list.Insert(i + 1, xx); } break; case "sub": if (x[0].Operand2 == "1") { x[0].Ignore(); X86Code xx = new X86Code("dec", x[0].Operand1); xx.Notes = "[Optimize] add"; list.Insert(i + 1, xx); } break; } } StringCollection jmp = new StringCollection(); for (int i = 0; i < list.Count; i++) { X86Code x = list[i] as X86Code; if (x == null || x.ignore) continue; if (x.Mnemonic == "mov" && X86Code.IsXX(x.Operand1) && x.Operand2 == "0") { x.Ignore(); X86Code xx = new X86Code("xor", x.Operand1, x.Operand1); xx.Notes = "[optimize] add"; list.Insert(i + 1, xx); } else if (x.Mnemonic == "mov" && x.Operand1 == x.Operand2) { x.Ignore(); } else if (x.Mnemonic.StartsWith("j")) { jmp.Add(x.Operand1); } } for (int i = 0; i < list.Count; i++) { X86Code x = list[i] as X86Code; if (x == null) continue; if (x.IsBrTarget && !jmp.Contains(x.Label)) x.IsBrTarget = false; } }
public void mineria_texto(string texto) { bool eliminar_numeros = true; int cantidad_grupos_calculos_frecuencia = 10; int cantidad_iteraciones_grupos_calculos_frecuencia = 500; //Tokenizacion texto = texto.Replace('"', ' ').Replace('-', ' ').Replace('(', ' ').Replace(')', ' '); string pattern = ""; string replacement = " "; pattern = "[!'$%&/=?¡¿><_*.:]"; texto = Regex.Replace(texto, pattern, replacement); texto = texto.Replace("\r\n", "enterenterenter"); pattern = "\\s+"; texto = Regex.Replace(texto, pattern, replacement); string consignos = "áàäéèëíìïóòöúùuñÁÀÄÉÈËÍÌÏÓÒÖÚÙÜÑçÇ"; string sinsignos = "aaaeeeiiiooouuunAAAEEEIIIOOOUUUNcC"; for (int v = 0; v < sinsignos.Length; v++) { string i = consignos.Substring(v, 1); string j = sinsignos.Substring(v, 1); texto = texto.Replace(i, j); } texto = texto.ToLower(); MatchCollection m1 = Regex.Matches(texto, "enterenterenter"); String[] stringSeparators = { "enterenterenter" }; // txtchar.Text = m1.Count.ToString(); string[] valores = texto.Split(stringSeparators, m1.Count, StringSplitOptions.RemoveEmptyEntries); //Borrar Stopwords ArrayList arrpalabras_descartadas = new ArrayList(new[] { "de","se","a","en","del","este","a","la","para","al","ya","lo" ,"que","sin","es","cual","e","m","le","el","con","por","ante","bajo","de", "sobre","tras","las","esta","si", "de","la","que","el","en","y","a","los","del","se","las","por","un","para","con","no","una","su","al","es","lo","como","más","pero","sus","le","ya","o","fue","este","ha","sí","porque","esta","cuando","muy","sín","sobre","ser","tíene","también","me","hasta","hay","donde","han","quien","están","estado","desde","todo","nos","durante","estados","todos","uno","les","ní","contra","otros","fueron","ese","eso","Habá","ante","ellos","e","esto","mí","antes","algunos","qué","unos","yo","otro","otras","otra","él","tanto","esa","estos","mucho","quienes","nada","sea","poco","ella","estar","haber","estas","estaba","estamos","algunas","algo","nosotros","mi","mis","Tú","te","tí","tu","tus","ellas","nosotras","vosotros","vosotas","os","mío","míos","mías","tuyo","tuya","tuyos","tuyas","nuestro","nuestra","nuestros","nuestras","vuestro","vuestra","vuestros","vuestras","esos","esas", "estoy","estás","estamos","estais","están","esté","estés","estemos","estéis","estén","estaré","estarás","estará","estaremos","estaréis","estarán","estaría","estarías","estaríamos","estaríais","estarían","estaba","estabas","estabamos","estabais","estaban","estuve","estuviste","estuvo","estuvimos","estuvisteis","estuvieron","estuviera","estuvieras","estuvieramos","estuvierais","estuvieran","estuviese","estuvieses","estuviésemos","estuvieseis","estuviesen","estando","estada","estados","estadas","estad", "he","has","ha","hemos","habeís","hay","haya","hayas","hayamos","hayáis","hayan","habre","habrás","habrá","habremos","habréis","habrán","habría","habrías","habríamos","habríais","habrían","había","habías","habíamos","habíais","habían","hube","hubiste","hubo","hubimos","hubisteis","hubieron","hubiera","hubieras","hubiéramos","hubieraís","hubiesen","habiendo","habido","habidos","habidas", "soy","eres","es","somos","soís","son","seas","seamos","seáis","será","seremos","seréis","serán","sería","serías","seríamos","seríais","serían","era","eras","éramos","erais","eran","fuí","fusite","fue","fuimos","fuisteis","fueron","fuera","fueras","fuéramos","fuerais","fueran","fuese","sueses","fuésemos","fuesen","siendo","sido", "tengo","tienes","tiene","tenemos","tenéis","tienen","tenga","tengas","tengamos","tengáis","tengan","tendre","tendrás","tendrá","tendremos","tendréis","tendrán","tendría","tendrías","tendríamos","tendríais","tendrían","tenía","tenías","teníamos","tenían","tuve","tuviste","tuvo","tuvimos","tuvisteis","tuvieron","tuviera","tuvieras","tuviéramos","tuvierais","tuvieran","tuviese","tuvieses","tuviésemos","tuvieseis","tuviesen","teniendo","tenido","tenida","tenidos","tenidas","tened" }); //Fin Tokenizacion ArrayList arrdatos = new ArrayList(); Hashtable hs1 = new Hashtable(); ArrayList arrvalores = new ArrayList(); int n = 0; int cantidad_sumados = 0; int cantidad_maxima = 0; while (n < valores.Length) { string temp = valores[n].Replace(",", "").Replace(".", ""); Hashtable hs2 = new Hashtable(); hs2["dato"] = temp; arrdatos.Add(hs2); string[] arr1 = temp.Split(' '); ArrayList arragregados = new ArrayList(); int m = 0; while (m < arr1.Length) { if (arr1[m].Trim() != "") { bool agrega = false; if ((arragregados.IndexOf(arr1[m]) == -1) && (arrpalabras_descartadas.IndexOf(arr1[m]) == -1) && (arr1[m].Length != 1) ) agrega = true; Int64 int64Val; if (eliminar_numeros == true) { if (Int64.TryParse(arr1[m], NumberStyles.Number, null, out int64Val)) { agrega = false; } } if (agrega == true) { arragregados.Add(arr1[m]); if (hs1[arr1[m]] == null) { hs1[arr1[m]] = 1; cantidad_sumados++; } else { hs1[arr1[m]] = Convert.ToInt32(hs1[arr1[m]].ToString()) + 1; cantidad_sumados++; } if (Convert.ToInt32(hs1[arr1[m]].ToString()) > cantidad_maxima) { cantidad_maxima = Convert.ToInt32(hs1[arr1[m]].ToString()); } } } m++; } n++; } ArrayList arrvaloresconteo = new ArrayList(); double promedio = 0; foreach (string llave in hs1.Keys) { promedio = promedio + Convert.ToInt32(hs1[llave].ToString()); arrvaloresconteo.Add(Convert.ToInt32(hs1[llave].ToString())); } promedio = promedio / hs1.Count; double vz = 0; double desv = desviacion_estandar_varianza(arrvaloresconteo, promedio, ref vz); Hashtable hscolumnas = new Hashtable(); foreach (string llave in hs1.Keys) { if (Convert.ToInt32(hs1[llave].ToString()) > desv) hscolumnas[llave] = Convert.ToInt32(hs1[llave].ToString()); } ArrayList arrcalculado = new ArrayList(); ArrayList arrdatos2 = new ArrayList(); n = 0; while (n < arrdatos.Count) { Hashtable hsfil = (Hashtable)arrdatos[n]; string[] arrpalabras = hsfil["dato"].ToString().Split(' '); Hashtable hs2 = new Hashtable(); hs2["0texto"] = hsfil["dato"].ToString(); foreach (string llave in hscolumnas.Keys) { //Algoritmo ID double dato = 0; if (Array.IndexOf(arrpalabras, llave) != -1) dato = Math.Log10(Convert.ToDouble(arrdatos.Count) / Convert.ToDouble(hscolumnas[llave].ToString())); if (dato != 0) arrcalculado.Add(dato); hs2[llave] = dato; } arrdatos2.Add(hs2); n++; } //arrcalculado.Clear(); //arrcalculado.Add(1); //arrcalculado.Add(5); //arrcalculado.Add(8); //arrcalculado.Add(15); //arrcalculado.Add(99); //arrcalculado.Add(1); //arrcalculado.Add(3); //arrcalculado.Add(1500); //arrcalculado.Add(2); ArrayList arrreferencias = new ArrayList(); ArrayList arr3 = kmeans_1d(cantidad_grupos_calculos_frecuencia, arrcalculado, 500, ref arrreferencias); arrreferencias.Sort(); var ob1 = new { respuesta = hscolumnas, cantidad_total = desv, //datos = arrdatos2 }; var s1 = new JavaScriptSerializer(); s1.MaxJsonLength = 100000000; string s2 = s1.Serialize(ob1); hdddatos.Value = s2; //texto = Regex.Replace(texto, pattern, replacement); // txttemp.Text = texto; }
static void Main(string[] args) { #region Random r = new Random(); ArrayList arrlist = new ArrayList(); for (int i = 0; i < 5; i++) { arrlist.Add(r.Next(0, 10)); } foreach (object o in arrlist) { Console.WriteLine(o); } Console.WriteLine("/////////////////////"); arrlist.Add("asdsdgfh"); arrlist.RemoveAt(0); foreach (object o in arrlist) { Console.WriteLine(o); } Console.WriteLine("/////////////////////"); Console.WriteLine("Введите элемент массива"); int c = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Element:" + arrlist[arrlist.IndexOf(c)]); #endregion List <float> list1 = new List <float>(); list1.Add(4.5F); list1.Add(1); list1.Add(1.2F); list1.Add(3.1F); list1.Add(8.5F); foreach (object item in list1) { Console.WriteLine("Elements of list:" + item); } Console.WriteLine("Введите кол-во удаляемых элементов"); int key = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < list1.Count; i++) { while (key > 0) { list1.RemoveAt(i); key--; } } foreach (object item in list1) { Console.WriteLine("Elements of list:" + item); } Console.WriteLine(); Stack <float> s1 = new Stack <float>(); for (int i = 0; i < list1.Count; i++) { s1.Push(list1[i]); } foreach (object item in s1) { Console.WriteLine("Elements of stack:" + item); } Console.WriteLine("Введите элемент массива"); Console.ReadLine(); Console.WriteLine("Введенный элемент: " + s1.Peek()); List <Plant> p = new List <Plant>(); p.Add(new Plant("dsgf", 123)); p.Add(new Plant("dsgfdgfhf", 333)); p.Add(new Plant("dsdfxggf", 444)); foreach (var item in p) { Console.WriteLine("Price and Color : " + item.Price + " " + item.Color); } p.RemoveAt(0); Console.WriteLine("///////////////////////"); foreach (var item in p) { Console.WriteLine("Price and Color : " + item.Price + " " + item.Color); } Stack <Plant> s2 = new Stack <Plant>(); for (int i = 0; i < p.Count; i++) { s2.Push(p[i]); } foreach (var item in s2) { Console.WriteLine("Price and Color : " + item.Price + " " + item.Color); } Console.WriteLine("Last zadanie"); ObservableCollection <Plant> obc = new ObservableCollection <Plant>(); obc.CollectionChanged += Plant_CollectionChanged; obc.Add(new Plant("Kseniya", 23435)); obc.RemoveAt(0); }
//======= 前三分布图 public DataTable HN11X5_Q3FBT(int DaySpan, int Type, ref int ReturnValue, ref string returnDescription) { DataSet ds = null; DataTable dt = null; DataTable dtall = null; DateTime Date = System.DateTime.Now; dt = Shove._Web.Cache.GetCacheAsDataTable("HN11X5_Q3FBT"); if (dt == null) { DAL.Procedures.P_TrendChart_11YDJ_WINNUM(ref ds, Date, 77, ref ReturnValue, ref returnDescription); if (ds == null) { return dt; } dt = ds.Tables[0]; for (int i = 1; i <= 11; i++) { dt.Columns.Add("b" + i.ToString(), typeof(int)); } for (int i = 1; i <= 8; i++) { dt.Columns.Add("bb" + i.ToString(), typeof(int)); } for (int i = 1; i <= 8; i++) { dt.Columns.Add("bc" + i.ToString(), typeof(int)); } for (int i = 0; i < dt.Rows.Count; i++) { if (i == 0) { for (int j = 1; j <= 11; j++) { if (j == Convert.ToInt32(dt.Rows[i][1]) || j == Convert.ToInt32(dt.Rows[i][2]) || j == Convert.ToInt32(dt.Rows[i][3])) { dt.Rows[i][j + 7] = -1; } else { dt.Rows[i][j + 7] = 1; } } ArrayList a = new ArrayList(); a.Add("111"); a.Add("110"); a.Add("101"); a.Add("011"); a.Add("100"); a.Add("010"); a.Add("001"); a.Add("000"); for (int j = 1; j <= 8; j++) { if ((j - 1) == a.IndexOf(Convert.ToString(Convert.ToInt32(dt.Rows[i][1]) % 2) + Convert.ToString(Convert.ToInt32(dt.Rows[i][2]) % 2) + Convert.ToString(Convert.ToInt32(dt.Rows[i][3]) % 2))) { dt.Rows[i][j + 18] = -1; } else { dt.Rows[i][j + 18] = 1; } } for (int j = 1; j <= 8; j++) { if ((8 - j) == a.IndexOf(Convert.ToString(Convert.ToInt32(dt.Rows[i][1]) > 5 ? "1" : "0") + Convert.ToString(Convert.ToInt32(dt.Rows[i][2]) > 5 ? "1" : "0") + Convert.ToString(Convert.ToInt32(dt.Rows[i][3]) > 5 ? "1" : "0"))) { dt.Rows[i][j + 26] = -1; } else { dt.Rows[i][j + 26] = 1; } } } else { for (int j = 1; j <= 11; j++) { if (j == Convert.ToInt32(dt.Rows[i][1]) || j == Convert.ToInt32(dt.Rows[i][2]) || j == Convert.ToInt32(dt.Rows[i][3])) { if (Convert.ToInt32(dt.Rows[i - 1][j + 7]) > 0) { dt.Rows[i][j + 7] = -1; } else { dt.Rows[i][j + 7] = Convert.ToInt32(dt.Rows[i - 1][j + 7]) - 1; } } else { if (Convert.ToInt32(dt.Rows[i - 1][j + 7]) < 0) { dt.Rows[i][j + 7] = 1; } else { dt.Rows[i][j + 7] = Convert.ToInt32(dt.Rows[i - 1][j + 7]) + 1; } } } ArrayList a = new ArrayList(); a.Add("111"); a.Add("110"); a.Add("101"); a.Add("011"); a.Add("100"); a.Add("010"); a.Add("001"); a.Add("000"); for (int j = 1; j <= 8; j++) { if ((j - 1) == a.IndexOf(Convert.ToString(Convert.ToInt32(dt.Rows[i][1]) % 2) + Convert.ToString(Convert.ToInt32(dt.Rows[i][2]) % 2) + Convert.ToString(Convert.ToInt32(dt.Rows[i][3]) % 2))) { if (Convert.ToInt32(dt.Rows[i - 1][j + 18]) > 0) { dt.Rows[i][j + 18] = -1; } else { dt.Rows[i][j + 18] = Convert.ToInt32(dt.Rows[i - 1][j + 18]) - 1; } } else { if (Convert.ToInt32(dt.Rows[i - 1][j + 18]) < 0) { dt.Rows[i][j + 18] = 1; } else { dt.Rows[i][j + 18] = Convert.ToInt32(dt.Rows[i - 1][j + 18]) + 1; } } } for (int j = 1; j <= 8; j++) { if ((8 - j) == a.IndexOf(Convert.ToString(Convert.ToInt32(dt.Rows[i][1]) > 5 ? "1" : "0") + Convert.ToString(Convert.ToInt32(dt.Rows[i][2]) > 5 ? "1" : "0") + Convert.ToString(Convert.ToInt32(dt.Rows[i][3]) > 5 ? "1" : "0"))) { if (Convert.ToInt32(dt.Rows[i - 1][j + 26]) > 0) { dt.Rows[i][j + 26] = -1; } else { dt.Rows[i][j + 26] = Convert.ToInt32(dt.Rows[i - 1][j + 26]) - 1; } } else { if (Convert.ToInt32(dt.Rows[i - 1][j + 26]) < 0) { dt.Rows[i][j + 26] = 1; } else { dt.Rows[i][j + 26] = Convert.ToInt32(dt.Rows[i - 1][j + 26]) + 1; } } } } } Shove._Web.Cache.SetCache("HN11X5_Q3FBT", dt, 600); } dtall = dt.Clone(); DataRow[] dr = null; if (Type == 1) { dr = dt.Select("DaySpan <=" + DaySpan, "ID ASC"); } else { dr = dt.Select("DaySpan =" + DaySpan, "ID ASC"); } foreach (DataRow d in dr) { dtall.Rows.Add(d.ItemArray); } dtall.Columns.Remove("ID"); dtall.Columns.Remove("DaySpan"); return dtall; }
/// <summary> /// Searches for the specified PropertySpec and returns the zero-based index of the first /// occurrence within the entire PropertySpecCollection. /// </summary> /// <param name="value">The PropertySpec to locate in the PropertySpecCollection.</param> /// <returns>The zero-based index of the first occurrence of value within the entire PropertySpecCollection, /// if found; otherwise, -1.</returns> public int IndexOf(PropertySpec value) { return(_innerArray.IndexOf(value)); }
void uc_Btn_RecPre() { if (ViewState["MODE"].ToString() == "EDIT") if (Session["ITM071_SortKey" + ViewState["SSID"].ToString()] != null) { ArrayList arl_Key = new ArrayList(); arl_Key = (ArrayList)Session["ITM071_SortKey" + ViewState["SSID"].ToString()]; if (arl_Key.Count > 1) { int iIndex = arl_Key.IndexOf(ViewState["ITEM"].ToString() + "XX" + ViewState["PERIOD"].ToString()); if (iIndex != 0) { string strData = arl_Key[iIndex - 1].ToString(); JumpUrl(strData); } } } }
void Update() { Debug.Log("Entered Update on Server."); // Accept any incoming connections! ArrayList listenList = new ArrayList(); listenList.Add(m_Socket); Socket.Select(listenList, null, null, 1000); for (int i = 0; i < listenList.Count; i++) { Socket newSocket = ((Socket)listenList[i]).Accept(); m_Connections.Add(newSocket); m_ByteBuffer.Add(new ArrayList()); Debug.Log("Did connect"); } // Read data from the connections! if (m_Connections.Count != 0) { Debug.Log("There's a connection with the server, processing on the server."); ArrayList connections = new ArrayList(m_Connections); Socket.Select(connections, null, null, 1000); // Go through all sockets that have data incoming! foreach (Socket socket in connections) { byte[] receivedbytes = new byte[512]; ArrayList buffer = (ArrayList)m_ByteBuffer[m_Connections.IndexOf(socket)]; int read = socket.Receive(receivedbytes); for (int i = 0; i < read; i++) { buffer.Add(receivedbytes[i]); } while (true && buffer.Count > 0) { int length = (byte)buffer[0]; if (length < buffer.Count) { ArrayList thismsgBytes = new ArrayList(buffer); thismsgBytes.RemoveRange(length + 1, thismsgBytes.Count - (length + 1)); thismsgBytes.RemoveRange(0, 1); if (thismsgBytes.Count != length) { Debug.Log("Bug"); } buffer.RemoveRange(0, length + 1); byte[] readbytes = (byte[])thismsgBytes.ToArray(typeof(byte)); MessageData readMsg = MessageData.FromByteArray(readbytes); m_Buffer.Add(readMsg); //Debug.Log(System.String.Format("Message {0}: {1}, {2}", readMsg.stringData, readMsg.mousex, readMsg.mousey)); if (singleton != this) { Debug.Log("Bug"); } } else { break; } } // string output = Encoding.UTF8.GetString(bytes); } } }
public virtual bool runTest() { int iCountErrors = 0; int iCountTestcases = 0; Console.Error.WriteLine( strName + ": " + strTest + " runTest started..." ); ArrayList arrList = null; int ndx = -1; String [] strHeroes = { "Aquaman", "Atom", "Batman", "Black Canary", "Captain America", "Captain Atom", "Batman", "Catwoman", "Cyborg", "Flash", "Green Arrow", "Batman", "Green Lantern", "Hawkman", "Huntress", "Ironman", "Nightwing", "Batman", "Robin", "SpiderMan", "Steel", "Superman", "Thor", "Batman", "Wildcat", "Wonder Woman", "Batman", }; do { ++iCountTestcases; Console.Error.WriteLine( "[] Construct ArrayList" ); try { arrList = new ArrayList( (ICollection) strHeroes ); if ( arrList == null ) { Console.WriteLine( strTest+ "E_101: Failed to construct new ArrayList" ); ++iCountErrors; break; } } catch (Exception ex) { Console.WriteLine( strTest+ "E_10001: Unexpected Exception: " + ex.ToString() ); ++iCountErrors; break; } ++iCountTestcases; Console.Error.WriteLine( "[] Obtain index of \"Batman\" items" ); try { while ( ( ndx = arrList.IndexOf( "Batman", ++ndx, (arrList.Count-ndx) ) ) != -1 ) { if ( strHeroes[ndx].CompareTo( (String)arrList[ndx] ) != 0 ) { String strInfo = strTest + " error: "; strInfo = strInfo + "On IndexOf==" + ndx + " "; strInfo = strInfo + "Expected hero <"+ strHeroes[ndx] + "> "; strInfo = strInfo + "Returned hero <"+ (String)arrList[ndx] + "> "; Console.WriteLine( strTest+ "E_202: " + strInfo ); ++iCountErrors; break; } } } catch (Exception ex) { Console.WriteLine( strTest+ "E_10002: Unexpected Exception: " + ex.ToString() ); ++iCountErrors; break; } ++iCountTestcases; Console.Error.WriteLine( "[] Attempt to find null object" ); try { ndx = arrList.IndexOf( null, 0, arrList.Count ); if ( ndx != -1 ) { String strInfo = strTest + " error: "; strInfo = strInfo + "Expected index <-1> "; strInfo = strInfo + "Returned index <"+ ndx + "> "; Console.WriteLine( strTest+ "E_303: " + strInfo ); ++iCountErrors; break; } } catch (Exception ex) { Console.WriteLine( strTest+ "E_10003: Unexpected Exception: " + ex.ToString() ); ++iCountErrors; break; } ++iCountTestcases; Console.Error.WriteLine( "[] Attempt bogus IndexOf using negative index" ); try { arrList.IndexOf( "Batman", -1000, arrList.Count ); Console.WriteLine( strTest+ "E_404: Expected ArgumentException" ); ++iCountErrors; break; } catch (ArgumentException) { } catch (Exception ex) { Console.WriteLine( strTest+ "E_10004: Unexpected Exception: " + ex.ToString() ); ++iCountErrors; break; } ++iCountTestcases; Console.Error.WriteLine( "[] Attempt bogus IndexOf using out of range index" ); try { arrList.IndexOf( "Batman", 1000, arrList.Count ); if ( ndx != -1 ) { String strInfo = strTest + " error: "; strInfo = strInfo + "Expected index <-1> "; strInfo = strInfo + "Returned index <"+ ndx + "> "; Console.WriteLine( strTest+ "E_505: " + strInfo ); ++iCountErrors; break; } } catch (ArgumentOutOfRangeException) { } catch (Exception ex) { Console.WriteLine( strTest+ "E_10005: Unexpected Exception: " + ex.ToString() ); ++iCountErrors; break; } ++iCountTestcases; Console.Error.WriteLine( "[] Attempt bogus IndexOf using endIndex greater than the size" ); try { arrList.IndexOf( "Batman", 3, arrList.Count + 10 ); Console.WriteLine( strTest+ "E_606: Expected ArgumentException" ); ++iCountErrors; break; } catch (ArgumentException) { } catch (Exception ex) { Console.WriteLine( strTest+ "E_10006: Unexpected Exception: " + ex.ToString() ); ++iCountErrors; break; } ++iCountTestcases; arrList = new ArrayList(); for(int i=0; i<10; i++) arrList.Add(i); if(arrList.IndexOf(50, 0, arrList.Count) != -1) { ++iCountErrors; Console.WriteLine("Err_7342dvs! This is clearly wrong, "); } if(arrList.IndexOf(0, 1, arrList.Count-1) != -1) { ++iCountErrors; Console.WriteLine("Err_7342dvs! This is clearly wrong, "); } } while ( false ); Console.Error.Write( strName ); Console.Error.Write( ": " ); if ( iCountErrors == 0 ) { Console.Error.WriteLine( strTest + " iCountTestcases==" + iCountTestcases + " paSs" ); return true; } else { Console.WriteLine( strTest+ strPath ); Console.WriteLine( strTest+ "FAiL" ); Console.Error.WriteLine( strTest + " iCountErrors==" + iCountErrors ); return false; } }
int IList.IndexOf(object value) { return(items.IndexOf(value)); }
public ArrayList GenerateCellNoList(int CellNoLength, string FirstPartNumber, int CellGeneratedCount) { string static_number = FirstPartNumber; int all_count = CellNoLength; int result_count = all_count - static_number.Length; int generatecount = CellGeneratedCount; string from = "", _to = ""; for (int i = 0; i < result_count; i++) { from = from + "0"; _to = _to + "9"; } Random rnd = new Random(); ArrayList al = new ArrayList(); string no = ""; for (int i = 0; i < generatecount; i++) { no = rnd.Next(Convert.ToInt32(from), Convert.ToInt32(_to)).ToString(); int len = result_count - no.Length; for (int l = 0; l < len; l++) { no = "0" + no; } if (al.IndexOf(static_number + no) > 0) { al.Remove(static_number + no); i = i - 1; } al.Add(static_number + no); } return al; }
/// <summary> /// Function to make a twelve leads signals object. /// </summary> /// <returns>returns twelve leads signals object or null</returns> public Signals CalculateTwelveLeads() { LeadType[] lt = new LeadType[] { LeadType.I, LeadType.II, LeadType.III, LeadType.aVR, LeadType.aVL, LeadType.aVF, LeadType.V1, LeadType.V2, LeadType.V3, LeadType.V4, LeadType.V5, LeadType.V6 }; int nrSim = NrSimultaneosly(); if (nrSim != _Lead.Length) { return(null); } Signal[] leads = null; if (nrSim == 12) { ArrayList pos_list = new ArrayList(lt); int check_one = 0; ArrayList check_two = new ArrayList(lt); Signal[] pos = new Signal[12]; for (int i = 0; i < nrSim; i++) { if (_Lead[i].Type == lt[i]) { check_one++; } int temp = check_two.IndexOf(_Lead[i].Type); if (temp < 0) { return(null); } check_two.RemoveAt(temp); pos[pos_list.IndexOf(_Lead[i].Type)] = _Lead[i]; } if (check_one == 12) { return(this); } if (check_two.Count == 0) { for (int i = 0; i < pos.Length; i++) { if (pos[i] != null) { pos[i] = pos[i].Clone(); } } leads = pos; } } else { short[][] tempRhythm = null, tempMedian = null; Signal[] pos = new Signal[12]; if (nrSim == 8) { ArrayList pos_list = new ArrayList(lt); ArrayList check = new ArrayList( new LeadType[] { LeadType.I, LeadType.II, LeadType.V1, LeadType.V2, LeadType.V3, LeadType.V4, LeadType.V5, LeadType.V6 }); for (int i = 0; i < nrSim; i++) { int temp = check.IndexOf(_Lead[i].Type); if (temp < 0) { return(null); } check.RemoveAt(temp); pos[pos_list.IndexOf(_Lead[i].Type)] = _Lead[i]; } if (check.Count == 0) { for (int i = 0; i < pos.Length; i++) { if (pos[i] != null) { pos[i] = pos[i].Clone(); } } tempRhythm = new short[2][]; tempRhythm[0] = pos[0].Rhythm; tempRhythm[1] = pos[1].Rhythm; tempMedian = new short[2][]; tempMedian[0] = pos[0].Median; tempMedian[1] = pos[1].Median; } } else if (nrSim == 9) { ArrayList pos_list = new ArrayList(lt); ArrayList check = new ArrayList( new LeadType[] { LeadType.I, LeadType.II, LeadType.III, LeadType.V1, LeadType.V2, LeadType.V3, LeadType.V4, LeadType.V5, LeadType.V6 }); for (int i = 0; i < nrSim; i++) { int temp = check.IndexOf(_Lead[i].Type); if (temp < 0) { return(null); } check.RemoveAt(temp); pos[pos_list.IndexOf(_Lead[i].Type)] = _Lead[i]; } if (check.Count == 0) { for (int i = 0; i < pos.Length; i++) { if (pos[i] != null) { pos[i] = pos[i].Clone(); } } tempRhythm = new short[3][]; tempRhythm[0] = pos[0].Rhythm; tempRhythm[1] = pos[1].Rhythm; tempRhythm[2] = pos[2].Rhythm; tempMedian = new short[3][]; tempMedian[0] = pos[0].Median; tempMedian[1] = pos[1].Median; tempMedian[2] = pos[2].Median; } } if ((tempRhythm != null) || (tempMedian != null)) { short[][] calcLeads; if ((tempRhythm != null) && (tempRhythm[0] != null) && ECGTool.CalculateLeads(tempRhythm, tempRhythm[0].Length, out calcLeads) == 0) { for (int i = 0; i < calcLeads.Length; i++) { Signal sig = new Signal(); sig.Type = lt[i + tempRhythm.Length]; sig.RhythmStart = pos[0].RhythmStart; sig.RhythmEnd = pos[0].RhythmEnd; sig.Rhythm = calcLeads[i]; pos[i + tempRhythm.Length] = sig; } if ((tempMedian != null) && (tempMedian[0] != null) && (ECGTool.CalculateLeads(tempMedian, tempMedian[0].Length, out calcLeads) == 0)) { for (int i = 0; i < calcLeads.Length; i++) { pos[i + tempRhythm.Length].Median = calcLeads[i]; } } leads = pos; } } } if (leads != null) { Signals sigs = this.Clone(); sigs.NrLeads = (byte)leads.Length; for (int i = 0; i < leads.Length; i++) { sigs._Lead[i] = leads[i]; } return(sigs); } return(null); }
private void WriteDataToResourceFile(String fileFormat, ResourceWriter resWriter, CultureInfo culture){ ArrayList xmlTable; ArrayList xmlList; Int32 ielementCount; String elementName; StringBuilder resourceHolder; String resourceName; XmlTextReader reader; xmlTable = new ArrayList(); xmlList = new ArrayList(); reader = new XmlTextReader(xmlSchemaFile + "_" + fileFormat + ".xml"); ielementCount=0; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.HasAttributes) { if(++ielementCount>2){ xmlTable.Add(String.Empty); xmlList.Add(reader[0]); } } break; } } reader.Close(); reader = new XmlTextReader(xmlDataFile + "_" + fileFormat + "_" + culture.ToString() + ".xml"); elementName = String.Empty; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: elementName = reader.Name; break; case XmlNodeType.Text: if(xmlList.Contains(elementName)){ xmlTable[xmlList.IndexOf(elementName)] = (String)xmlTable[xmlList.IndexOf(elementName)] + reader.Value + separator; } break; } } reader.Close(); resourceHolder = new StringBuilder(); foreach(String str111 in xmlList){ resourceHolder.Append((String)xmlTable[xmlList.IndexOf(str111)] + EOL); } resourceName = baseFileName + fileFormat + culture.ToString(); resWriter.AddResource(resourceName, resourceHolder.ToString()); }
/// <include file='doc\AutoCompleteStringCollection.uex' path='docs/doc[@for="AutoCompleteStringCollection.IndexOf"]/*' /> /// <devdoc> /// <para>Returns the index of the first occurrence of a string in /// the <see cref='System.Collections.Specialized.AutoCompleteStringCollection'/> .</para> /// </devdoc> public int IndexOf(string value) { return(data.IndexOf(value)); }
/// <summary> /// 除了指定的控制項設定TabIndex外 其他控制項的TabIndex都設成最後一個TabIndex+1 /// </summary> private void ResetTabIndex(Control c, short iNextIndex, ArrayList arl_TabIndex) { //iNextIndex 會把所有相符的TABINDEX設成一樣的 if (arl_TabIndex.IndexOf(c) == -1) { if (c is Button) { ((Button)c).TabIndex = iNextIndex; } else if (c is TextBox) { ((TextBox)c).TabIndex = iNextIndex; } else if (c is RadioButton) { ((RadioButton)c).TabIndex = iNextIndex; } else if (c is RadioButtonList) { ((RadioButtonList)c).TabIndex = iNextIndex; } else if (c is DropDownList) { ((DropDownList)c).TabIndex = iNextIndex; } } foreach (Control child in c.Controls) ResetTabIndex(child, iNextIndex, arl_TabIndex);
/// <summary> /// Gets the index of the specified item. /// </summary> /// <param name="listItem">The item.</param> /// <returns>The zero-based index.</returns> public int ItemIndex(CustomListItem listItem) { // Allows CustomListItem to requery its index, as it can change. return(itemsArray.IndexOf(listItem)); }