当前位置: 首页>>代码示例>>C#>>正文


C# System.Collections.ArrayList.Contains方法代码示例

本文整理汇总了C#中System.Collections.ArrayList.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.ArrayList.Contains方法的具体用法?C# System.Collections.ArrayList.Contains怎么用?C# System.Collections.ArrayList.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.ArrayList的用法示例。


在下文中一共展示了System.Collections.ArrayList.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MultiFormatOneDReader

 public MultiFormatOneDReader(System.Collections.Hashtable hints)
 {
     System.Collections.ArrayList possibleFormats = hints == null ? null : (System.Collections.ArrayList) hints[DecodeHintType.POSSIBLE_FORMATS];
     readers = new System.Collections.ArrayList();
     if (possibleFormats != null) {
       if (possibleFormats.Contains(BarcodeFormat.EAN_13) ||
           possibleFormats.Contains(BarcodeFormat.UPC_A) ||
           possibleFormats.Contains(BarcodeFormat.EAN_8) ||
           possibleFormats.Contains(BarcodeFormat.UPC_E))
       {
         readers.Add(new MultiFormatUPCEANReader(hints));
       }
       if (possibleFormats.Contains(BarcodeFormat.CODE_39)) {
           readers.Add(new Code39Reader());
       }
       if (possibleFormats.Contains(BarcodeFormat.CODE_128))
       {
           readers.Add(new Code128Reader());
       }
       if (possibleFormats.Contains(BarcodeFormat.ITF))
       {
           readers.Add(new ITFReader());
       }
     }
     if (readers.Count==0) {
         readers.Contains(new MultiFormatUPCEANReader(hints));
         readers.Contains(new Code39Reader());
         readers.Contains(new Code128Reader());
       // TODO: Add ITFReader once it is validated as production ready, and tested for performance.
       //readers.addElement(new ITFReader());
     }
 }
开发者ID:andrejpanic,项目名称:win-mobile-code,代码行数:32,代码来源:MultiFormatOneDReader.cs

示例2: Config

        public Config()
        {
            InitializeComponent();
            BindFrequency();
            BindPixelFormat();
             cbxAutoRun.Checked = IsSubValueExist();

               // ControlCollection cols = new ControlCollection(this);
            GetChildControl(this);
            System.Collections.ArrayList excludedControls = new System.Collections.ArrayList();
            excludedControls.Add(cbxAutoRun);
            foreach (object o in array)
            {
                Control c = (Control)o;

                if (excludedControls.Contains(c))
                {
                    continue;
                }
                if (c.GetType().Equals(typeof(TextBox)))
                {
                    c.TextChanged +=new EventHandler(SaveControlValue);
                    string propValue=(string) Properties.Settings.Default[c.Name.TrimStart("tbx".ToCharArray())];
                    if (c.Name.ToLower().IndexOf("password") >= 0)
                    {
                        if (!string.IsNullOrEmpty(propValue))
                        {
                            PHComponents.SCCrypto scc = new PHComponents.SCCrypto();
                            propValue = scc.Decrypting(propValue);
                        }
                    }
                    c.Text = propValue;

                }
                if (c.GetType().Equals(typeof(CheckBox)))
                {
                    ((CheckBox)c).CheckedChanged += new EventHandler(SaveControlValue);
                    ((CheckBox)c).Checked=Convert.ToBoolean(Properties.Settings.Default[c.Name.TrimStart("cbx".ToCharArray())]);
                }

            }
        }
开发者ID:kakapi,项目名称:ShotLifeSln,代码行数:42,代码来源:Config.cs

示例3: parse

        /// <summary> Populates the given group object with data from the given group element, ignoring 
        /// any unrecognized nodes.  
        /// </summary>
        private void parse(ca.uhn.hl7v2.model.Group groupObject, System.Xml.XmlElement groupElement)
        {
            System.String[] childNames = groupObject.Names;
            System.String messageName = groupObject.Message.getStructureName();

            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList allChildNodes = groupElement.ChildNodes;
            System.Collections.ArrayList unparsedElementList = new System.Collections.ArrayList();
            for (int i = 0; i < allChildNodes.Count; i++)
            {
                System.Xml.XmlNode node = allChildNodes.Item(i);
                System.String name = node.Name;
                if (System.Convert.ToInt16(node.NodeType) == (short) System.Xml.XmlNodeType.Element && !unparsedElementList.Contains(name))
                {
                    unparsedElementList.Add(name);
                }
            }

            //we're not too fussy about order here (all occurances get parsed as repetitions) ...
            for (int i = 0; i < childNames.Length; i++)
            {
                SupportClass.ICollectionSupport.Remove(unparsedElementList, childNames[i]);
                parseReps(groupElement, groupObject, messageName, childNames[i], childNames[i]);
            }

            for (int i = 0; i < unparsedElementList.Count; i++)
            {
                System.String segName = (System.String) unparsedElementList[i];
                System.String segIndexName = groupObject.addNonstandardSegment(segName);
                parseReps(groupElement, groupObject, messageName, segName, segIndexName);
            }
        }
开发者ID:snosrap,项目名称:nhapi,代码行数:35,代码来源:DefaultXMLParser.cs

示例4: GenerateSummaryTable

		/// <summary>
		/// Generates a Summary Table Outlining the Provider Charges and Revenues
		/// Illustrating Unearned Income
		/// use MinDate and MaxDate to flag all dates
		/// </summary>
		public static DataTable GenerateSummaryTable(int Guarantor,DateTime dtFrom, DateTime dtTo)
		{
			DataTable rValReturnTable = null;
			DataTable dtProviderBalance = Db.GetTableOld(ProviderRevenueByGuarantor(Guarantor,dtFrom,dtTo));
			DataTable dtProvAbbr = Db.GetTableOld("SELECT ProvNum, Abbr FROM Provider");
			if (dtProviderBalance != null && dtProviderBalance.Rows.Count != 0)
			{
				// Get Provider Abbreviations
				System.Collections.Hashtable htAllProvs = new System.Collections.Hashtable();
				for (int i = 0; i < dtProvAbbr.Rows.Count; i++)
					if (!htAllProvs.ContainsKey(dtProvAbbr.Rows[i][0].ToString()))
						htAllProvs[dtProvAbbr.Rows[i][0].ToString()] = dtProvAbbr.Rows[i][1].ToString();
				if (!htAllProvs.ContainsKey("0"))
					htAllProvs["0"] = "Unearned";
				// First establish a list of providers
				System.Collections.ArrayList alProvs = new System.Collections.ArrayList();
				for (int i = 0; i < dtProviderBalance.Rows.Count; i++)
					if (!alProvs.Contains(dtProviderBalance.Rows[i][0].ToString()))
						alProvs.Add(dtProviderBalance.Rows[i][0].ToString());

				// Fill and Create DataTable
				DataTable dtBalancesTable = new DataTable();
				dtBalancesTable.Columns.Add(new DataColumn("Provider", typeof(string)));
				dtBalancesTable.Columns.Add(new DataColumn("Charges", typeof(string)));
				dtBalancesTable.Columns.Add(new DataColumn("Adjustments", typeof(string)));
				dtBalancesTable.Columns.Add(new DataColumn("Revenue", typeof(string)));
				dtBalancesTable.Columns.Add(new DataColumn("Balance", typeof(string)));
				DataRow drWorkingRow = null;
				int ColumnIndex = -1;

				try
				{
					System.Collections.Hashtable htAllProvs_Indexes = new System.Collections.Hashtable();
					for (int i = 0; i < alProvs.Count; i++) // For Each Provider add a Row in the Balances Table
					{
						dtBalancesTable.Rows.Add(dtBalancesTable.NewRow());
						dtBalancesTable.Rows[i][0] = alProvs[i].ToString();
					}

					for (int i = 0; i < dtProviderBalance.Rows.Count; i++)
					{
						drWorkingRow = dtBalancesTable.Rows[alProvs.IndexOf(dtProviderBalance.Rows[i][0].ToString())];
						drWorkingRow[0] = htAllProvs[dtProviderBalance.Rows[i][0].ToString()].ToString(); // the abbreviation

						// Which Column of the Row to add the number to?  Find the column
						// stated in the query's column 2
						string ColumnName_FromQuery = dtProviderBalance.Rows[i][2].ToString();
						ColumnIndex = dtBalancesTable.Columns.IndexOf(ColumnName_FromQuery);
						if (ColumnIndex > 0)
							drWorkingRow[ColumnIndex] = dtProviderBalance.Rows[i][1].ToString(); // note is not cast as number so numeric specifies cannot apply //ToString("F2");
						else
							drWorkingRow[4] = "ERROR!";


						ColumnIndex = -1;
					}
					decimal[] Totals = new decimal[4];
					// Fill in Null and Empty Entries
					for (int j = 0; j < dtBalancesTable.Rows.Count; j++)
						for (int k = 1; k < dtBalancesTable.Columns.Count; k++)
						{
							if (dtBalancesTable.Rows[j][k] == null || dtBalancesTable.Rows[j][k].ToString().Trim() == "")
								dtBalancesTable.Rows[j][k] = "0.00";
							if (k == dtBalancesTable.Columns.Count - 1)
							{
								decimal Balance = decimal.Parse(dtBalancesTable.Rows[j][1].ToString())
								+ decimal.Parse(dtBalancesTable.Rows[j][2].ToString())
								+ decimal.Parse(dtBalancesTable.Rows[j][3].ToString());
								dtBalancesTable.Rows[j][4] = Balance.ToString("F2");
							}
							// Add to the Totals to be placed at the bottom of the Table
							Totals[k - 1] += decimal.Parse(dtBalancesTable.Rows[j][k].ToString());
							// Format the Numbers Better
							dtBalancesTable.Rows[j][k] = decimal.Parse(dtBalancesTable.Rows[j][k].ToString()).ToString("F2");
						}
					DataRow TotalRow = dtBalancesTable.NewRow();
					TotalRow[0] = "Totals-->";
					for (int i = 1; i < dtBalancesTable.Columns.Count; i++)
						TotalRow[i] = Totals[i - 1].ToString("F2");
					dtBalancesTable.Rows.Add(TotalRow);
				}
				catch
				{
				}
				rValReturnTable =  dtBalancesTable; // Set this first becuase SummaryTable_as_Strings() will check for _SummaryTable != null
			//	_SummaryTableHeader = SummaryTable_as_Strings();
			}
			return rValReturnTable;
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:94,代码来源:Report1_GuarantorAllocation.cs

示例5: RetainAll

            /// <summary>
            /// Retains the elements in the target collection that are contained in the specified collection
            /// </summary>
            /// <param gridTemplateName="target">Collection where the elements will be removed.</param>
            /// <param gridTemplateName="c">Elements to be retained in the target collection.</param>
            /// <returns>true</returns>
            public static bool RetainAll(System.Collections.ICollection target, System.Collections.ICollection c)
            {
                System.Collections.IEnumerator e = new System.Collections.ArrayList(target).GetEnumerator();
                System.Collections.ArrayList al = new System.Collections.ArrayList(c);

                //Reflection. Invoke "retainAll" method for proprietary classes or "Remove" for each element in the collection
                System.Reflection.MethodInfo method;
                try
                {
                method = c.GetType().GetMethod("retainAll");

                if (method != null)
                    method.Invoke(target, new System.Object[] {c});
                else
                {
                    method = c.GetType().GetMethod("Remove");

                    while (e.MoveNext() == true)
                    {
                        if (al.Contains(e.Current) == false)
                            method.Invoke(target, new System.Object[] {e.Current});
                    }
                }
                }
                catch (System.Exception ex)
                {
                throw ex;
                }

                return true;
            }
开发者ID:soho737,项目名称:NGribCS,代码行数:37,代码来源:SupportClass.cs

示例6: MakeRand

 private System.Collections.ArrayList MakeRand(int intLower, int intUpper, int intNum)
 {
     System.Collections.ArrayList arrayRand = new System.Collections.ArrayList();
     Random random = new Random((int)DateTime.Now.Ticks);
     int intRnd;
     while (arrayRand.Count < intNum)
     {
         intRnd = random.Next(intLower, intUpper + 1);
         if (!arrayRand.Contains(intRnd))
         {
             arrayRand.Add(intRnd);
         }
     }
     return arrayRand;
 }
开发者ID:iceyhs,项目名称:Hearthstone,代码行数:15,代码来源:Deck.cs

示例7: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Images();

            // Load the source PDF file
            Document doc = new Document(dataDir+ "ImageInformation.pdf");

            // Define the default resolution for image
            int defaultResolution = 72;
            System.Collections.Stack graphicsState = new System.Collections.Stack();
            // Define array list object which will hold image names
            System.Collections.ArrayList imageNames = new System.Collections.ArrayList(doc.Pages[1].Resources.Images.Names);
            // Insert an object to stack
            graphicsState.Push(new System.Drawing.Drawing2D.Matrix(1, 0, 0, 1, 0, 0));

            // Get all the operators on first page of document
            foreach (Operator op in doc.Pages[1].Contents)
            {
                // Use GSave/GRestore operators to revert the transformations back to previously set
                Operator.GSave opSaveState = op as Operator.GSave;
                Operator.GRestore opRestoreState = op as Operator.GRestore;
                // Instantiate ConcatenateMatrix object as it defines current transformation matrix.
                Operator.ConcatenateMatrix opCtm = op as Operator.ConcatenateMatrix;
                // Create Do operator which draws objects from resources. It draws Form objects and Image objects
                Operator.Do opDo = op as Operator.Do;

                if (opSaveState != null)
                {
                    // Save previous state and push current state to the top of the stack
                    graphicsState.Push(((System.Drawing.Drawing2D.Matrix)graphicsState.Peek()).Clone());
                }
                else if (opRestoreState != null)
                {
                    // Throw away current state and restore previous one
                    graphicsState.Pop();
                }
                else if (opCtm != null)
                {
                    System.Drawing.Drawing2D.Matrix cm = new System.Drawing.Drawing2D.Matrix(
                       (float)opCtm.Matrix.A,
                       (float)opCtm.Matrix.B,
                       (float)opCtm.Matrix.C,
                       (float)opCtm.Matrix.D,
                       (float)opCtm.Matrix.E,
                       (float)opCtm.Matrix.F);

                    // Multiply current matrix with the state matrix
                    ((System.Drawing.Drawing2D.Matrix)graphicsState.Peek()).Multiply(cm);

                    continue;
                }
                else if (opDo != null)
                {
                    // In case this is an image drawing operator
                    if (imageNames.Contains(opDo.Name))
                    {
                        System.Drawing.Drawing2D.Matrix lastCTM = (System.Drawing.Drawing2D.Matrix)graphicsState.Peek();
                        // Create XImage object to hold images of first pdf page
                        XImage image = doc.Pages[1].Resources.Images[opDo.Name];

                        // Get image dimensions
                        double scaledWidth = Math.Sqrt(Math.Pow(lastCTM.Elements[0], 2) + Math.Pow(lastCTM.Elements[1], 2));
                        double scaledHeight = Math.Sqrt(Math.Pow(lastCTM.Elements[2], 2) + Math.Pow(lastCTM.Elements[3], 2));
                        // Get Height and Width information of image
                        double originalWidth = image.Width;
                        double originalHeight = image.Height;

                        // Compute resolution based on above information
                        double resHorizontal = originalWidth * defaultResolution / scaledWidth;
                        double resVertical = originalHeight * defaultResolution / scaledHeight;

                        // Display Dimension and Resolution information of each image
                        Console.Out.WriteLine(
                                string.Format(dataDir + "image {0} ({1:.##}:{2:.##}): res {3:.##} x {4:.##}",
                                             opDo.Name, scaledWidth, scaledHeight, resHorizontal,
                                             resVertical));
                    }
                }
            }
            
            
        }
开发者ID:joyang1,项目名称:Aspose_Pdf_NET,代码行数:83,代码来源:ImageInformation.cs

示例8: queEtapasEnRevaluo

        public System.Collections.ArrayList queEtapasEnRevaluo()
        {
            TimeSpan ts = TimeSpan.FromSeconds(2);
            DateTime inicio = DateTime.Now;
            byte auxEtapa = 255;

            System.Collections.ArrayList etapas = new System.Collections.ArrayList();

            while (((TimeSpan)(DateTime.Now - inicio)).CompareTo(ts) < 0)
            {
                auxEtapa = etapaEnCalculo;
                if (auxEtapa != 255)
                {
                    if (!etapas.Contains(auxEtapa))
                    {
                        etapas.Add(auxEtapa);
                    }
                }
            }
            return etapas;
        }
开发者ID:javiprieto89,项目名称:fea,代码行数:21,代码来源:Multicast.cs

示例9: Process


//.........这里部分代码省略.........
                        //check for an existing contact
                        List<string> contactIdList = cfs.FindContactsByRepCode(
                                                            DataAccess.ReplaceNull<String>(row["DealerCode"])
                                                            , DataAccess.ReplaceNull<String>(row["RepCode"]));

                        //Handle sharing rep codes
                        foreach (string contactId in contactIdList) {

                            cfs.ContactId = contactId;
                            cfs.Owner = "SYST00000001";
                            cfs.DealerCode = DataAccess.ReplaceNull<String>(row["DealerCode"]);
                            cfs.RepCode = DataAccess.ReplaceNull<String>(row["RepCode"]);
                            cfs.Fund = DataAccess.ReplaceNull<String>(row["FundName"]);
                            cfs.FundCode = DataAccess.ReplaceNull<String>(row["FundCode"]);
                            cfs.FundPrice = DataAccess.ReplaceNull<double>(row["Price"]);

                            cfs.Holdings = DataAccess.ReplaceNull<double>(row["MarketValue"]);
                            cfs.NumberOfAccounts = DataAccess.ReplaceNull<int>(row["NumOfAccounts"]);
                            cfs.TotalHoldings = DataAccess.ReplaceNull<double>(row["TotalMarketValue"]);

                            string batchName = DataAccess.ReplaceNull<String>(row["BatchName"]);
                            //cfs.RecordSource = DataAccess.ReplaceNull<String>(row["RecordSource"]);

                            //string sql2 = "Select Count(Distinct h2.AccountNumber) AS TotalnumOfAccounts";
                            //sql2 += " FROM " + this.TableOwner + "." + "ImportHold h2";
                            //sql2 += " Inner Join " + this.TableOwner + "." + "Fund f2 On h2.FundCode = f2.FundCode";
                            //sql2 += " Where h2.BatchName = ?";
                            //sql2 += " AND h2.DealerCode = ? AND h2.RepCode = ?";

                            //int? totalnumofaccount = DataAccess.OLEDB_ExecuteScalar<int?>(OLEDBConnection.ConnectionString
                            //                                , sql2, 180
                            //                                , new OleDbParameter ("BatchName", batchName)
                            //                                , new OleDbParameter ("DealerCode", cfs.DealerCode)
                            //                                , new OleDbParameter ("RepCode", cfs.RepCode));

                            //cfs.TotalNumberOfAccounts = Convert.ToInt32(totalnumofaccount);
                            cfs.TotalNumberOfAccounts = DataAccess.ReplaceNull<int>(row["TotalNumOfAccounts"]);

                            //cfs.YTDGrossSales = cfs.CalculateYTDGrossSales(cfs.FundCode, cfs.DealerCode, cfs.RepCode);
                            cfs.YTDGrossSales = DataAccess.ReplaceNull<double>(row["YTDGrossSales"]);
                            cfs.YTDRedemptions = DataAccess.ReplaceNull<double>(row["YTDRedemptions"]);
                            //cfs.YTDNetSales = cfs.CalculateYTDNetSales(cfs.FundCode, cfs.DealerCode, cfs.RepCode);
                            cfs.YTDNetSales = DataAccess.ReplaceNull<double>(row["YTDNetSales"]);
                            //cfs.TotalYTDGrossSales = cfs.CalculateTotalYTDGrossSales(cfs.DealerCode, cfs.RepCode);
                            cfs.TotalYTDGrossSales = DataAccess.ReplaceNull<double>(row["TotalYTDGrossSales"]);
                            cfs.TotalYTDRedemptions = DataAccess.ReplaceNull<double>(row["TotalYTDRedemptions"]);
                            //cfs.TotalYTDNetSales = cfs.CalculateTotalYTDNetSales(cfs.DealerCode, cfs.RepCode);
                            cfs.TotalYTDNetSales = DataAccess.ReplaceNull<double>(row["TotalYTDNetSales"]);

                            if (!String.IsNullOrEmpty(contactId)) {
                                //Contact found, insert record
                                string contactFundSalesId = cfs.Insert();

                                //check if this batch should be archived
                                //Only archive transaction records, not holdings records
                                if (ArchiveList.Contains(batchName.Substring(0, 8)) ) { //& cfs.RecordSource == "Transaction") {
                                    //Archive date matches, archive this batch
                                    cfs.InsertHistory(batchName);
                                }
                            }
                        }

                        Trace.TraceInformation("Process - " + ClassName + ": Contact Record: (" + i + " of " + TotalRecords + ")");

                    } catch (Exception ex) {
                        Trace.TraceInformation("ERROR Process - " + ClassName + ": " + "Contact Record: " + i + " - " + ex.Message);
                        EventLog.WriteEntry(Application.ProductName, "ERROR Process - " + ClassName + ": " + "Record: " + i + " - " + ex.Message, EventLogEntryType.Error);
                        ErrorLog.Add("ERROR Process - " + ClassName + ": " + "Contact Record: " + i + " - " + ex.Message);
                        //'Move to the next record - record failure will not stop processing of subsequent records
                    }

                    //Move to the next record
                    i += 1;
                } //    Next

                //Mark the data as processed
                var distinctRows = (from DataRow dRow in ds.Tables[SourceTableName].Rows
                                    select dRow["BatchName"]).Distinct();

                foreach (string batch in distinctRows) {
                    string sqlprocess = "Update " + this.TableOwner + "." + "ImportHold Set RepProcessed = 1 Where BatchName = ?";

                    DataAccess.OLEDB_ExecuteNonQuery(OLEDBConnection.ConnectionString, sqlprocess, 15000
                                                        , new OleDbParameter("BatchName", batch));
                }

                i--;
                Trace.TraceInformation("Process - " + ClassName + ": Complete " + i + " of " + TotalRecords + " processed");
                EventLog.WriteEntry(Application.ProductName, "Process - " + ClassName + ": Complete " + i + " of " + TotalRecords + " processed", EventLogEntryType.Information);
                return TotalRecords;

            } catch (Exception ex1) {
                //    Trace.TraceInformation("ERROR Process - " & ClassName & ":" & ex1.Message)
                //    My.Application.Log.WriteException(ex1, TraceEventType.Error, vbCrLf & "ERROR Process - " & ClassName)
                Trace.TraceInformation("ERROR Process - " + ClassName + ": " + "Contact Record: " + i + " - " + ex1.Message);
                EventLog.WriteEntry(Application.ProductName, "ERROR Process - " + ClassName + ": " + "Contact Record: " + i + " - " + ex1.Message, EventLogEntryType.Error);
                ErrorLog.Add("ERROR Process - " + ClassName + ": " + "Contact Record: " + i + " - " + ex1.Message);
                return i;
            }
        }
开发者ID:ssommerfeldt,项目名称:TAC_AH,代码行数:101,代码来源:ImportRepHoldings.cs

示例10: Optimize

		public void Optimize(Directory directory)
		{
			string[] files = directory.List();

			System.Collections.ArrayList segment_names = new System.Collections.ArrayList();

			foreach (SegmentInfo si in this)
				segment_names.Add (si.name);

			foreach (string file in files) {
				string basename = System.IO.Path.GetFileNameWithoutExtension (file);
				if (segment_names.Contains (basename))
					continue;

				// Allowed files deletable, segments, segments.gen, segments_N
				if (basename == IndexFileNames.DELETABLE || basename.StartsWith (IndexFileNames.SEGMENTS))
					continue;

				Console.WriteLine ("WARNING! Deleting stale data {0}", file);
				try {
					directory.DeleteFile (file);
				} catch { /* Could be already deleted. */ }
			}
		}
开发者ID:zweib730,项目名称:beagrep,代码行数:24,代码来源:SegmentInfos.cs

示例11: Astar_start

       /* Standard A* */
       public bool Astar_start(AstarNode startNode, AstarNode targetNode)
       {
           System.Collections.ArrayList closedlist = new System.Collections.ArrayList();
           System.Collections.ArrayList openlist = new System.Collections.ArrayList();

           closedlist.Clear();
           openlist.Clear();
           startNode.fvalue = calcFvalue(startNode); //this sets g and h

           openlist.Add(startNode);

           while (openlist.Count > 0)
           {
               Globals.debugPath = pathNodes;
               AstarNode xNode;
               openlist.Sort();
               xNode = ((AstarNode)openlist[0]);
               if (xNode == targetNode)
               {
                   pathNodes.Add(xNode);
                   return true;
               }
               openlist.Remove(xNode);
               closedlist.Add(xNode);
               pathNodes.Add(xNode);
               findAdjacentNodes(xNode);

               foreach (AstarNode yNode in xNode.adjacentNodes)
               {
                   if (closedlist.Contains(yNode))
                       continue;
                   int tempGScore;
                   bool isBetter = false;

                   //todo add diagonals.
                   tempGScore = xNode.gvalue + HorizontalCost;
                   yNode.fvalue = calcFvalue(yNode);

                   if (openlist.Contains(yNode))
                   {
                       openlist.Add(yNode);
                       isBetter = true;
                   }
                   else if (tempGScore < yNode.gvalue)
                       isBetter = true;

                   else
                       isBetter = false;
                   if (isBetter)
                   {
                       yNode.gvalue = tempGScore;
                       yNode.hvalue = calcHvalue(yNode);
                       yNode.fvalue = yNode.gvalue + yNode.hvalue;
                   }
               }      
           }
           return false;
       }
开发者ID:stephenZh,项目名称:l2net,代码行数:59,代码来源:Astar.cs

示例12: Run

        public void Run()
        {
            System.Collections.ArrayList tradeScrollList = new System.Collections.ArrayList();

            for (int ip = 0; ip < Globals.iprp_spells2da.RowCount; ip++)
            {
                //DebugWindow.PrintDebugMessage("Looking at iprp_spells.2da row: " + ip);
                string tdaSpellId = Globals.iprp_spells2da["SpellIndex"][ip];
                string tdaCasterLevel = Globals.iprp_spells2da["CasterLvl"][ip];
                string icon = Globals.iprp_spells2da["Icon"][ip];
                bool formatOK = true;
                int spellId = -1;
                int casterLevel = -1;
                try
                {
                    spellId = Convert.ToInt32(tdaSpellId);
                    casterLevel = Convert.ToInt32(tdaCasterLevel);
                    DebugWindow.PrintDebugMessage("Creating consumables for spell id " + spellId + ", caster level " + casterLevel + " and scroll icon " + icon + ".");
                }
                catch
                {
                    DebugWindow.PrintDebugMessage("2da format error for iprp_spells.2da line " + ip + ", spell id " + tdaSpellId + ", caster level " + tdaCasterLevel + ".");
                    formatOK = false;
                }

                if (formatOK && !ipHash.Contains(tdaSpellId.ToString() + "_" + tdaCasterLevel.ToString()))
                {

                    NWN2Toolset.NWN2.Rules.CNWSpell spell = Globals.spells.GetSpell(spellId);
                    ipHash.Add(tdaSpellId.ToString() + "_" + tdaCasterLevel.ToString());

                    if (spell != null && spell.IsValid() == 1)
                    {
                        int targets = spell.GetSpellTargetType();
                        int wizardLevel = spell.GetSpellWizardLevel();
                        int clericLevel = spell.GetSpellClericLevel();
                        int druidLevel = spell.GetSpellDruidLevel();
                        int rangerLevel = spell.GetSpellRangerLevel();
                        int paladinLevel = spell.GetSpellPaladinLevel();
                        int bardLevel = spell.GetSpellBardLevel();

                        // Find the lowest spell level.
                        int lowestSpellLevel = wizardLevel;
                        if (lowestSpellLevel > clericLevel)
                            lowestSpellLevel = clericLevel;
                        if (lowestSpellLevel > druidLevel)
                            lowestSpellLevel = druidLevel;

                        float costLevel = lowestSpellLevel;
                        if (lowestSpellLevel == 0)
                            costLevel = 0.5F;

                        if ((lowestSpellLevel < 255))
                        {
                            if ((targets & 2) != 0 && lowestSpellLevel <= 3 && spell.GetSpellHostile() != 1 && !nonpotion(spellId))
                            {
                                // Can target a creature, ie can be a potion.
                                Potion potion = new Potion(ip, spellId, lowestSpellLevel, casterLevel, spell);
                                Globals.AddBlueprint(potion.blueprint);
                                potionStore.addToPotionItems(potion.blueprint);
                            }

                            if (lowestSpellLevel <= 4)
                            {
                                // Can be a wand.
                                Wand wand = new Wand(ip, spellId, lowestSpellLevel, casterLevel, spell);
                                addClassRestrictions(wand.blueprint, bardLevel, clericLevel, druidLevel, paladinLevel, rangerLevel, wizardLevel);
                                Globals.AddBlueprint(wand.blueprint);
                                wandStore.addToPotionItems(wand.blueprint);
                            }

                            int lowestDivineLevel = clericLevel;
                            if (druidLevel < clericLevel)
                            {
                                lowestDivineLevel = druidLevel;
                            }
                            if (lowestDivineLevel == 255)
                            {
                                lowestDivineLevel = rangerLevel;
                                if (lowestDivineLevel > paladinLevel)
                                    lowestDivineLevel = paladinLevel;
                            }
                            if (lowestDivineLevel < 255)
                            {
                                // Can be a divine scroll.
                                Scroll scroll = new DivineScroll(ip, spellId, lowestSpellLevel, casterLevel, spell, icon);
                                addClassRestrictions(scroll.blueprint, 255, clericLevel, druidLevel, paladinLevel, rangerLevel, 255);
                                Globals.AddBlueprint(scroll.blueprint);
                                scrollStore.addToPotionItems(scroll.blueprint);
                            }

                            int lowestArcaneLevel = wizardLevel;
                            if (wizardLevel == 255)
                            {
                                lowestArcaneLevel = bardLevel;
                            }

                            if (wizardLevel < 255 && !tradeScrollList.Contains(spellId))
                            {
                                // Can be a trade scroll.
//.........这里部分代码省略.........
开发者ID:CastanoALFA,项目名称:ALFA-Base-Resources,代码行数:101,代码来源:ConsumableCreator.cs

示例13: getPathsOfLength

 /// <summary> Get the paths starting from an atom of specified length.
 /// <p/>
 /// This method returns a set of paths. Each path is a <code>List</code> of atoms that
 /// make up the path (ie they are sequentially connected).
 /// 
 /// </summary>
 /// <param name="atomContainer">The molecule to consider
 /// </param>
 /// <param name="start">        The starting atom
 /// </param>
 /// <param name="length">       The length of paths to look for
 /// </param>
 /// <returns> A  <code>List</code> containing the paths found
 /// </returns>
 public static System.Collections.IList getPathsOfLength(IAtomContainer atomContainer, IAtom start, int length)
 {
     System.Collections.ArrayList curPath = new System.Collections.ArrayList();
     System.Collections.ArrayList paths = new System.Collections.ArrayList();
     curPath.Add(start);
     paths.Add(curPath);
     for (int i = 0; i < length; i++)
     {
         System.Collections.ArrayList tmpList = new System.Collections.ArrayList();
         for (int j = 0; j < paths.Count; j++)
         {
             curPath = (System.Collections.ArrayList)paths[j];
             IAtom lastVertex = (IAtom)curPath[curPath.Count - 1];
             System.Collections.IList neighbors = atomContainer.getConnectedAtomsVector(lastVertex);
             for (int k = 0; k < neighbors.Count; k++)
             {
                 System.Collections.ArrayList newPath = new System.Collections.ArrayList(curPath);
                 if (newPath.Contains(neighbors[k]))
                     continue;
                 newPath.Add(neighbors[k]);
                 tmpList.Add(newPath);
             }
         }
         paths.Clear();
         paths.AddRange(tmpList);
     }
     return (paths);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:42,代码来源:PathTools.cs

示例14: RepaceSpilthItem

        /// <summary>
        /// ��������ɾ���ظ�����
        /// tc 08-11-18 
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string[] RepaceSpilthItem(string[] str)
        {
            System.Collections.ArrayList list = new System.Collections.ArrayList();

            string tempStr = "";

            foreach (string s in str)
            {
                tempStr = s.ToLower();

                if (list.Contains(tempStr)) continue;

                list.Add(tempStr);
            }

            return (string[])list.ToArray(typeof(string));
        }
开发者ID:ZhaiQuan,项目名称:Zhai,代码行数:23,代码来源:Utils.cs

示例15: Execute

        /// <summary>
        /// When overridden in a derived class, executes the task.
        /// </summary>
        /// <returns>Returns <see langword="true" /> if the task successfully
        /// executed; otherwise, <see langword="false" />.
        /// </returns>
        public override bool Execute()
        {
            bool success = true;
            this.resultItems = new ITaskItem[items.Length];
            for (int i = 0; i < resultItems.Length; i++)
            {
                ITaskItem newItem = new TaskItem(items[i]);
                this.items[i].CopyMetadataTo(newItem);
                //Need to set this so it is not reset
                newItem.SetMetadata("RecursiveDir", items[i].GetMetadata("RecursiveDir"));

                if (String.IsNullOrEmpty(this.metadataName))
                {
                    IDictionary<string, string> metadataBag = ParseMetadata(this.metadata);
                    foreach (string metadataName in metadataBag.Keys)
                    {
                        newItem.SetMetadata(metadataName, metadataBag[metadataName]);
                    }
                }
                else
                {
                    System.Collections.ArrayList names = new System.Collections.ArrayList(newItem.MetadataNames);
                    string value = String.Empty;
                    if (names.Contains(this.metadataName))
                    {
                        value = String.Format(CultureInfo.InvariantCulture, "{0};{1}", newItem.GetMetadata(this.metadataName), String.Join(";", this.metadata));
                    }
                    else
                    {
                        value = String.Join(";", this.metadata);
                    }
                    newItem.SetMetadata(this.metadataName, value);
                }
                this.resultItems[i] = newItem;
            }

            return success;
        }
开发者ID:scottdorman,项目名称:MSBuildContrib,代码行数:44,代码来源:UpdateItemMetadata.cs


注:本文中的System.Collections.ArrayList.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。