Contains() public method

public Contains ( Object item ) : bool
item Object
return bool
        public void ExecuteAssemblies(
            [UsingFactories("AssemblyNames")] string name,
            [UsingFactories("AssemblyNames")] string secondName,
            [UsingFactories("AssemblyNames")] string thirdName
            )
        {
            int successCount = 0;
            ArrayList names = new ArrayList();
            names.Add(name);
            names.Add(secondName);
            names.Add(thirdName);

            if (names.Contains("ChildAssembly"))
            {
                if (!names.Contains("SickParentAssembly"))
                    successCount++;
            }
            if (names.Contains("ParentAssembly"))
                successCount++;

            string[] files = new string[] { name + ".dll", secondName + ".dll", thirdName + ".dll" };

            using (TestDomainDependencyGraph graph = TestDomainDependencyGraph.BuildGraph(files,null, MbUnit.Core.Filters.FixtureFilters.Any, false))
            {
                ReportResult result = graph.RunTests();
                Assert.AreEqual(successCount, result.Counter.SuccessCount);
            }
        }
        public void ExecuteAssemblies(
            [UsingFactories("AssemblyNames")] string name,
            [UsingFactories("AssemblyNames")] string secondName
            )
        {
            int successCount = 0;
            ArrayList names = new ArrayList();
            names.Add(Path.GetFileNameWithoutExtension(name));
            names.Add(Path.GetFileNameWithoutExtension(secondName));

            if (names.Contains("SickParentAssembly"))
            {
                if (names.Contains("ParentAssembly"))
                    successCount++;
            }
            else
            {
                if (names.Contains("ChildAssembly"))
                    successCount++;

                if (names.Contains("ParentAssembly"))
                    successCount++;
            }
            string[] files = new string[] { name, secondName };

            using (TestDomainDependencyGraph graph = TestDomainDependencyGraph.BuildGraph(files,null, MbUnit.Core.Filters.FixtureFilters.Any, true))
            {
                ReportResult result = graph.RunTests();
                Assert.AreEqual(successCount, result.Counter.SuccessCount);
            }
        }
        /// <summary>
        /// Gets the array of SQL servers that are available on the LAN.
        /// </summary>
        /// <returns>string[] of SQL server names</returns>
        public static string[] GetSQLServers()
        {
            string[] retval = null;
            DataTable dt = null;

            System.Data.Sql.SqlDataSourceEnumerator sds = System.Data.Sql.SqlDataSourceEnumerator.Instance;
            dt = sds.GetDataSources();
            ArrayList al = new ArrayList();
            if (retval != null)
            {
                for (int zz = 0; zz < retval.Length; zz++)
                {
                    if (!al.Contains(retval[zz]))
                    {
                        al.Add(retval[zz]);
                    }
                }
            }
            if (dt != null)
            {
                foreach (DataRow row in dt.Rows)
                {
                    string name = row["ServerName"].ToString() + (row["InstanceName"].ToString().Trim().Length != 0 ? "\\" + row["InstanceName"].ToString() : "");
                    if (!al.Contains(name))
                    {
                        al.Add(name);
                    }
                }
                dt.Dispose();
            }
            al.Sort();
            return (string[])al.ToArray(typeof(string));
        }
		public void MaxSize()
		{
			IKernel kernel = new DefaultKernel();
			kernel.AddComponent("a", typeof(PoolableComponent1));

			ArrayList instances = new ArrayList();

			instances.Add(kernel["a"] as PoolableComponent1);
			instances.Add(kernel["a"] as PoolableComponent1);
			instances.Add(kernel["a"] as PoolableComponent1);
			instances.Add(kernel["a"] as PoolableComponent1);
			instances.Add(kernel["a"] as PoolableComponent1);

			PoolableComponent1 other1 = kernel["a"] as PoolableComponent1;

			Assert.IsNotNull(other1);
			Assert.IsTrue(!instances.Contains(other1));

			foreach(object inst in instances)
			{
				kernel.ReleaseComponent(inst);
			}

			kernel.ReleaseComponent(other1);

			PoolableComponent1 other2 = kernel["a"] as PoolableComponent1;
			Assert.IsNotNull(other2);
			Assert.IsTrue(other1 != other2);
			Assert.IsTrue(instances.Contains(other2));

			kernel.ReleaseComponent(other2);
		}
        public ArrayList ProduceAddEx(int volume, int maxFactor, double fillInBlankPercentage)
        {
            string operation = "+";

            if (fillInBlankPercentage > 1)
                fillInBlankPercentage = 1;
            else if (fillInBlankPercentage < 0)
                fillInBlankPercentage = 0;
            int blankVolume = (int)(volume * fillInBlankPercentage);
            int nonBlankVolume = volume - blankVolume;

            ArrayList exList = new ArrayList();
            if (maxFactor < 1)
            {
                return exList;
            }
            // 如果难度超过20就不出现因子0、1这种简单题目了
            int minFactor = (maxFactor > 20 ? 2 : 0);
            // 减少重复题目,如果发现重复则再试一次
            // 另外如果难度太低可能会导致无法保证不重复的情况下出够题目同时也考虑效率问题,只重试10次
            int repeatedTimes = 0;
            Random random = new Random();
            for (int i = 0; i < nonBlankVolume; )
            {
                int factor1 = random.Next(minFactor, maxFactor - minFactor);
                int factor2 = random.Next(minFactor, Math.Max(minFactor + 1, maxFactor - factor1));
                string equation = factor1 + operation + factor2 + "=";
                if (repeatedTimes > 10 || !exList.Contains(equation))
                {
                    exList.Add(equation);
                    repeatedTimes = 0;
                    i++;
                }
                else
                {
                    repeatedTimes++;
                }
            }
            for (int i = 0; i < blankVolume; )
            {
                int factor1 = random.Next(minFactor, maxFactor - minFactor);
                int factor2 = random.Next(minFactor, Math.Max(minFactor + 1, maxFactor - factor1));
                string equation;
                if (random.Next() % 2 == 0)
                    equation = factor1 + operation + "(   )" + "=" + (factor1 + factor2);
                else
                    equation = "(   )" + operation + factor2 + "=" + (factor1 + factor2);
                if (repeatedTimes > 10 || !exList.Contains(equation))
                {
                    exList.Add(equation);
                    repeatedTimes = 0;
                    i++;
                }
                else
                {
                    repeatedTimes++;
                }
            }
            return exList;
        }
        public static string[] GetWhisperKeywords()
        {
            ArrayList keywords = new ArrayList();
            String whisperKeyword = null;
            foreach (DataRow row in DB.ActionTable.Rows)
            {
                if (row[DB.COL_QUESTPARTACTION_P] is string && ((string)row[DB.COL_QUESTPARTACTION_P]).Contains("["))
                {
                    MatchCollection matches = Regex.Matches((string)row[DB.COL_QUESTPARTACTION_P], "\\[([^\\]])*\\]", RegexOptions.Compiled);

                    foreach (Match match in matches)
                    {
                        whisperKeyword = match.Value.Trim(WHISPER_TRIMS);
                        if (!keywords.Contains(whisperKeyword))
                            keywords.Add(whisperKeyword);
                    }
                }

                if (row[DB.COL_QUESTPARTACTION_Q] is string && ((string)row[DB.COL_QUESTPARTACTION_Q]).Contains("["))
                {
                    MatchCollection matches = Regex.Matches((string)row[DB.COL_QUESTPARTACTION_Q], "\\[([^\\]])*\\]", RegexOptions.Compiled);
                    foreach (Match match in matches)
                    {
                        whisperKeyword = match.Value.Trim(WHISPER_TRIMS);
                        if (!keywords.Contains(whisperKeyword))
                            keywords.Add(whisperKeyword);
                    }
                }
            }
            return (string[])keywords.ToArray(typeof(string));
        }
Example #7
0
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            var todoBD = db.TODOes.ToList().Where(m=>m.done_date == null).OrderBy(m=> m.project_name).OrderBy(m=> m.add_date);

            ArrayList lista_projektow = new ArrayList();
            Hashtable lista_todo_do_zrobienia = new Hashtable();

            if (todoBD != null)
            {
                foreach (TODO todo in todoBD)
                {
                    if (!lista_projektow.Contains(todo.project_name))
                        lista_projektow.Add(todo.project_name);
                }

                foreach (string nazwa_projektu in lista_projektow)
                {
                    ArrayList lista_zadan_do_wykonania = new ArrayList();
                    foreach (TODO todo in todoBD)
                    {
                        if (todo.project_name == nazwa_projektu)
                            lista_zadan_do_wykonania.Add(todo);
                    }

                    lista_todo_do_zrobienia.Add(nazwa_projektu, lista_zadan_do_wykonania);
                }
            }

            todoBD = db.TODOes.ToList().Where(m => m.done_date != null).OrderBy(m => m.project_name).OrderByDescending(m => m.done_date);
            Hashtable lista_todo_zrobione = new Hashtable();

            if (todoBD != null)
            {
                lista_projektow.Clear();

                foreach (TODO todo in todoBD)
                {
                    if (!lista_projektow.Contains(todo.project_name))
                        lista_projektow.Add(todo.project_name);
                }

                foreach (string nazwa_projektu in lista_projektow)
                {
                    ArrayList lista_zadan_wykonanych = new ArrayList();
                    foreach (TODO todo in todoBD)
                    {
                        if (todo.project_name == nazwa_projektu)
                            lista_zadan_wykonanych.Add(todo);
                    }
                    lista_todo_zrobione.Add(nazwa_projektu, lista_zadan_wykonanych);
                }
            }

            ViewData.Add("lista_todo_do_zrobienia", lista_todo_do_zrobienia);
            ViewData.Add("lista_todo_zrobione", lista_todo_zrobione);
        }
Example #8
0
 public void HasMultipleCategories()
 {
     XmlNodeList categories = resultDoc.SelectNodes("//test-case[@name=\"NUnit.Tests.Assemblies.MockTestFixture.MockTest3\"]/categories/category");
     Assert.IsNotNull(categories);
     Assert.AreEqual(2, categories.Count);
     ArrayList names = new ArrayList();
     names.Add( categories[0].Attributes["name"].Value );
     names.Add( categories [1].Attributes["name"].Value);
     Assert.IsTrue( names.Contains( "AnotherCategory" ), "AnotherCategory" );
     Assert.IsTrue( names.Contains( "MockCategory" ), "MockCategory" );
 }
Example #9
0
        public static void EventSink_PlayerDeath( PlayerDeathEventArgs e )
        {
            Mobile m = e.Mobile;

            ArrayList killers = new ArrayList();
            ArrayList toGive = new ArrayList();

            foreach ( AggressorInfo ai in m.Aggressors )
            {
            //bounty system edit
            // orig if ( ai.Attacker.Player && ai.CanReportMurder && !ai.Reported )
                if ( ai.Attacker.Player && ai.CanReportMurder && !ai.Reported &&
                    !BountyBoard.Attackable( ai.Attacker, e.Mobile ) ) // end bounty system edit
                {
                    killers.Add( ai.Attacker );
                    ai.Reported = true;
                }

                if ( ai.Attacker.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Attacker ) )
                    toGive.Add( ai.Attacker );
            }

            foreach ( AggressorInfo ai in m.Aggressed )
            {
                if ( ai.Defender.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Defender ) )
                    toGive.Add( ai.Defender );
            }

            foreach ( Mobile g in toGive )
            {
                int n = Notoriety.Compute( g, m );

                int theirKarma = m.Karma, ourKarma = g.Karma;
                bool innocent = ( n == Notoriety.Innocent );
                bool criminal = ( n == Notoriety.Criminal || n == Notoriety.Murderer );

                int fameAward = m.Fame / 200;
                int karmaAward = 0;

                if ( innocent )
                    karmaAward = ( ourKarma > -2500 ? -850 : -110 - (m.Karma / 100) );
                else if ( criminal )
                    karmaAward = 50;

                Titles.AwardFame( g, fameAward, false );
                Titles.AwardKarma( g, karmaAward, true );
            }

            if ( m is PlayerMobile && ((PlayerMobile)m).NpcGuild == NpcGuild.ThievesGuild )
                return;

            if ( killers.Count > 0 )
                new GumpTimer( m, killers ).Start();
        }
        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="callback">The callback for UI updates.</param>
        public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback)
        {
            TimeSpan baseTime = new TimeSpan(0);
            ArrayList oids = new ArrayList();
            Hashtable bitsByOid = new Hashtable();
            using (StreamWriter s = new StreamWriter(stream))
            {
                foreach (PacketLog log in context.LogManager.Logs)
                {
                    for (int i = 0; i < log.Count; i++)
                    {
                        if (callback != null && (i & 0xFFF) == 0) // update progress every 4096th packet
                            callback(i, log.Count - 1);

                        StoC_0xA1_NpcUpdate npcUpdate = log[i] as StoC_0xA1_NpcUpdate;
                        if (npcUpdate == null) continue;
                        if ((npcUpdate.Temp & 0xF000) == 0) continue;
                        if ((npcUpdate.Temp & 0x0FFF) != 0) continue;

                        s.WriteLine(npcUpdate.ToHumanReadableString(baseTime, true));
                        if (!oids.Contains(npcUpdate.NpcOid))
                            oids.Add(npcUpdate.NpcOid);
                        ArrayList bitsList = (ArrayList) bitsByOid[npcUpdate.NpcOid];
                        if (bitsList == null)
                        {
                            bitsList = new ArrayList();
                            bitsByOid[npcUpdate.NpcOid] = bitsList;
                        }
                        int bits = npcUpdate.Temp >> 12;
                        if (!bitsList.Contains(bits))
                            bitsList.Add(bits);
                    }

                    int regionId;
                    int zoneId;
                    SortedList oidInfo = ShowKnownOidAction.MakeOidList(log.Count - 1, log, out regionId, out zoneId);
                    s.WriteLine("\n\noids for region {0}, zone {1}\n", regionId, zoneId);
                    foreach (DictionaryEntry entry in oidInfo)
                    {
                        ushort oid = (ushort) entry.Key;
                        if (!oids.Contains(oid)) continue;
                        ShowKnownOidAction.ObjectInfo objectInfo = (ShowKnownOidAction.ObjectInfo) entry.Value;
                        s.Write("0x{0:X4}: ", oid);
                        s.Write(objectInfo.ToString());
                        foreach (int bits in (ArrayList) bitsByOid[oid])
                        {
                            s.Write("\t0b{0}", Convert.ToString(bits, 2));
                        }
                        s.WriteLine();
                    }
                }
            }
        }
        public void GetPropertiesTest()
        {
            Collection<PropertyInfo> properties = _objectUtility.GetProperties(typeof(DummyObject));
            ArrayList propertyNames = new ArrayList();
            foreach (PropertyInfo property in properties)
                propertyNames.Add(property.Name);

            Assert.That(propertyNames.Contains("StringProperty"));
            Assert.That(propertyNames.Contains("IntProperty"));
            Assert.That(propertyNames.Contains("DecimalProperty"));
            Assert.That(propertyNames.Contains("ObjectProperty"));
        }
        public void GetSubstitutionsImplicitly()
        {
            XmlNode node = _document.DocumentElement.FirstChild;
            var templater = new XmlTemplater(node);
            string[] substitutions = templater.Substitutions;

            Assert.AreEqual(4, substitutions.Length);
            var list = new ArrayList(substitutions);

            Assert.IsTrue(list.Contains("color"));
            Assert.IsTrue(list.Contains("name"));
            Assert.IsTrue(list.Contains("state"));
            Assert.IsTrue(list.Contains("direction"));
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;
            this.caller = sender.Mobile;

            switch (info.ButtonID)
            {

                case 1:
                    {
                        TextRelay entrySphereAcc = info.GetTextEntry(10);
                        this.textSphereAcc = (entrySphereAcc == null ? "" : entrySphereAcc.Text.Trim());

                        TextRelay entrySphereChar = info.GetTextEntry(11);
                        this.textSphereChar = (entrySphereChar == null ? "" : entrySphereChar.Text.Trim());

                        TextRelay entryRunUOAcc = info.GetTextEntry(12);
                        this.textRunUOAcc = (entryRunUOAcc == null ? "" : entryRunUOAcc.Text.Trim());

                        TextRelay entryRunUOChar = info.GetTextEntry(13);
                        this.textRunUOChar = (entryRunUOChar == null ? "" : entryRunUOChar.Text.Trim());

                        ArrayList Selections = new ArrayList(info.Switches);

                        if (Selections.Contains(20))
                            this.importSkills = true;
                        else
                            this.importSkills = false;

                        if (Selections.Contains(21))
                            this.importItensToPlayer = true;
                        else
                            this.importItensToPlayer = false;

                        if (Selections.Contains(22))
                            this.importItensToStaff = true;
                        else
                            this.importItensToStaff = false;

                        StartImport();

                        break;
                    }

                case 0:
                default:
                    caller.SendMessage("Importacao CANCELADA.");
                    break;
            }
        }
        /// <summary>
        /// Does the passed data object have this format?
        /// </summary>
        /// <param name="dataObject">data object</param>
        /// <returns>true if the data object has the format, otherwise false</returns>
        public bool CanCreateFrom(IDataObject dataObject)
        {
            // GetDataPresent is not always a reliable indicator of what data is
            // actually available. For Outlook Express, if you call GetDataPresent on
            // FileGroupDescriptor it returns false however if you actually call GetData
            // you will get the FileGroupDescriptor! Therefore, we are going to
            // enumerate the available formats and check that list rather than
            // checking GetDataPresent
            ArrayList formats = new ArrayList(dataObject.GetFormats());

            // check for FileContents
            return (formats.Contains(DataFormatsEx.FileGroupDescriptorFormat) ||
                    formats.Contains(DataFormatsEx.FileGroupDescriptorWFormat))
                   && formats.Contains(DataFormatsEx.FileContentsFormat);
        }
        public void GetSubstititionsExplicitly()
        {
            XmlNode node = _document.DocumentElement.FirstChild;
            var element = (XmlElement) node;
            element.SetAttribute(InstanceMemento.SUBSTITUTIONS_ATTRIBUTE, "direction,color");

            var templater = new XmlTemplater(node);
            string[] substitutions = templater.Substitutions;

            Assert.AreEqual(2, substitutions.Length);
            var list = new ArrayList(substitutions);

            Assert.IsTrue(list.Contains("color"));
            Assert.IsTrue(list.Contains("direction"));
        }
Example #16
0
        public Listener( int port )
        {
            m_ThisPort = port;
            m_Disposed = false;
            m_Accepted = new Queue();
            m_OnAccept = new AsyncCallback( OnAccept );

            m_Listener = Bind( IPAddress.Any, port );

            try
            {
                IPHostEntry iphe = Dns.Resolve( Dns.GetHostName() );

                ArrayList list = new ArrayList();
                list.Add( IPAddress.Loopback );

                Console.WriteLine( "Address: {0}:{1}", IPAddress.Loopback, port );

                IPAddress[] ips = iphe.AddressList;

                for ( int i = 0; i < ips.Length; ++i )
                {
                    if ( !list.Contains( ips[i] ) )
                    {
                        list.Add( ips[i] );

                        Console.WriteLine( "Address: {0}:{1}", ips[i], port );
                    }
                }
            }
            catch
            {
            }
        }
		public static string[] Split( string src, char delimiter, params char[] quotedelims )
		{
			ArrayList		strings = new ArrayList();
			StringBuilder	sb = new StringBuilder();
			ArrayList		ar = new ArrayList(quotedelims);
			char			quote_open = Char.MinValue;

			foreach (char c in src) 
			{
				if (c == delimiter && quote_open == Char.MinValue) 
				{
					strings.Add( sb.ToString() );
					sb.Remove( 0, sb.Length );
				}
					
				else if (ar.Contains(c)) 
				{
					if (quote_open == Char.MinValue)
						quote_open = c;
					else if (quote_open == c)
						quote_open = Char.MinValue;
					sb.Append(c);
				}
				else
					sb.Append( c );
			}

			if (sb.Length > 0)
				strings.Add( sb.ToString());

			return (string[])strings.ToArray(typeof(string));
		}
Example #18
0
        static void Main(string[] args)
        {
            IList list1 = new ArrayList();
            list1.Add("Hello, ");
            list1.Add("my ");
            list1.Add("dear ");
            list1.Add("old ");
            list1.Add("friend! ");

            IList list2 = new ArrayList();
            list2.Add("my ");
            list2.Add("dear ");
            list2.Add("old ");

            foreach (var value in list2)
            {
                while (list1.Contains(value))
                {
                    list1.Remove(value);
                }
            }

            foreach (var v in list1)
            {
                Console.Write(v);
            }
        }
Example #19
0
		public void ReentrantConstructors ()
		{
			ArrayList user_ids = new ArrayList (4);
			IList users = UnixUserInfo.GetLocalUsers ();
			foreach (UnixUserInfo user in users) {
				try {
					UnixUserInfo byName = new UnixUserInfo (user.UserName);
					Assert.AreEqual (user, byName, "#TRC: construct by name");

					if (! user_ids.Contains (user.UserId))
						user_ids.Add (user.UserId);
				}
				catch (Exception e) {
					Assert.Fail (
						     string.Format ("#TRC: Exception constructing UnixUserInfo (string): {0}",
								    e.ToString()));
				}
			}

			foreach (uint uid in user_ids) {
				try {
					UnixUserInfo byId = new UnixUserInfo (uid);
					Assert.IsTrue (users.Contains (byId), "TRC: construct by uid");
				}
				catch (Exception e) {
					Assert.Fail (
						     string.Format ("#TRC: Exception constructing UnixUserInfo (uint): {0}",
								    e.ToString()));

				}
			}
		}
Example #20
0
        public void CATEGORIES()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\General\CATEGORIES.ics");
            Program.TestCal(iCal);
            Event evt = (Event)iCal.Events[0];

            ArrayList items = new ArrayList();
            items.AddRange(new string[]
            {
                "One", "Two", "Three",
                "Four", "Five", "Six",
                "Seven", "A string of text with nothing less than a comma, semicolon; and a newline\n."
            });

            Hashtable found = new Hashtable();

            foreach (TextCollection tc in evt.Categories)
            {
                foreach (Text text in tc.Values)
                {
                    if (items.Contains(text.Value))
                        found[text.Value] = true;
                }
            }

            foreach (string item in items)
                Assert.IsTrue(found.ContainsKey(item), "Event should contain CATEGORY '" + item + "', but it was not found.");
        }        
 internal void AddRef(ArrayList list, XmlSchemaObject o)
 {
     if (((((o != null) && !this.schemas.IsReference(o)) && (o.Parent is XmlSchema)) && (((XmlSchema) o.Parent).TargetNamespace != "http://www.w3.org/2001/XMLSchema")) && !list.Contains(o))
     {
         list.Add(o);
     }
 }
Example #22
0
        protected void fillDdlMovie()
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
            string sqlSelect = "SELECT * from Program";
            SqlCommand command = new SqlCommand(sqlSelect, conn);
            try
            {
                conn.Open();
                SqlDataReader reader = command.ExecuteReader();
                ddlMovie.Items.Clear();
                ArrayList listaMovie = new ArrayList();

                while (reader.Read())
                {
                    if(!listaMovie.Contains(reader["Name"].ToString()))
                    {
                        listaMovie.Add(reader["Name"].ToString());
                    }
                }
                reader.Close();
                ddlMovie.DataSource = listaMovie;
                ddlMovie.DataBind();
                ddlMovie.Items.Insert(0, new ListItem("--Select Movie--","0"));


            }
            catch (Exception err)
            {
            }
            finally
            {
                conn.Close();
            }
        }
Example #23
0
 private static void IndexOneClassifier(Classifier aCls, string aPrefix)
 {
     if ((aCls != null) && !aCls.IsShortcut())
     {
         ArrayList list = new ArrayList();
         string code = aCls.Code;
         Classifier item = aCls;
         while (true)
         {
             if (list.Contains(item))
             {
                 break;
             }
             list.Add(item);
             PdOOM.BaseObject containerClassifier = item.ContainerClassifier;
             if (containerClassifier == null)
             {
                 break;
             }
             item = (Classifier) containerClassifier;
             code = item.Code + "+" + code;
         }
         if (aPrefix != "")
         {
             code = aPrefix + "." + code;
         }
         TypeMapping.DefineExtraType(code, aCls);
     }
 }
        public String Calculate(DateTime dateCalculate, ref DataTable inputPlan)
        {
            String errMessage = "";

            try
            {
                inputPlan.PrimaryKey = new DataColumn[] { inputPlan.Columns["Date"], inputPlan.Columns["PartNumber"] };
                ArrayList arrSubLine = new ArrayList();
                for (int i = 0; i < inputPlan.Rows.Count; i++)
                {
                    UpdateRowInformation(ref inputPlan, inputPlan.Rows[i], true);
                    String subLineId = Utils.ObjectToString(inputPlan.Rows[i]["SubLine_ID"]);
                    if (!arrSubLine.Contains(subLineId) && !String.IsNullOrEmpty(subLineId))
                    {
                        arrSubLine.Add(subLineId);
                    }
                }

                // for (int i = 0; i < arrSubLine.Count && String.IsNullOrEmpty(errMessage); i++)
                for (int i = 0; i < arrSubLine.Count; i++)
                {
                    errMessage += FillShiftNameFromAndToTime(dateCalculate, arrSubLine[i].ToString(), ref inputPlan);
                }

            }
            catch (Exception ex)
            {
                errMessage += ex.Message;
                Logger.GetInstance().WriteException("Calculate", ex);
            }
            return errMessage;
        }
        private static ArrayList threeSums(int[] numbers)
        {
            var sums = new ArrayList();

            for (int i = 0; i < numbers.Length - 1; i++)
            {
                int j = i + 1; // start from i+1
                int k = numbers.Length - 1; //start from end

                while (j < k) // pointer positions
                {
                    int sum = numbers[i] + numbers[j] + numbers[k];

                    if (sum == 0)
                    {
                        var sumZeroList = new ArrayList {numbers[i], numbers[j], numbers[k]};
                        if (!sums.Contains(sumZeroList)) //duplicates not allowed
                        {
                            sums.Add(sumZeroList);
                        }
                    }

                    if (sum < 0) // core logic
                    {
                        j++; //since sum is less than zero search for higher order number
                    }
                    else
                    {
                        k--; // since sum is greater than zero search for lower order numbers
                    }
                }
            }

            return sums;
        }
Example #26
0
 /// <summary>
 /// 调用LottoNumbers方法,来随机选择数字
 /// </summary>
 /// <returns>6 random numbers </returns>
 private static string LottoNumbers() //static静态方法,方便调用,但效率不高
 {
     ArrayList list = new ArrayList(); //要添加using System.Collections命名空间
     Random r = new Random();
     for (int i = 0; i < 6; i++)
     {
         int lottoInt = r.Next(1, 41);
         if (list.Contains(lottoInt)) //Contains()方法:判断ArrayList数组中是否存在某个元素
         {
             i--; //若数组中存在该元素,则i自动减1,本次循环不算    
         }
         else //数组中不存在该随机数
         {
             list.Add(lottoInt); //把该随机数添加到数组中
         }
     }
     //把该数组从小到大排列
     list.Sort();
     //依次把数组中元素赋值给一个变量,并在每个数字用-连接
     string lottoNumbers = "";
     for (int i = 0; i < list.Count; i++)
     {
         lottoNumbers = lottoNumbers + list[i].ToString() + "-";
     }
     return lottoNumbers.Substring(0, lottoNumbers.Length - 1);
 }
Example #27
0
        private Boolean is_anagram(string word1, string word2)
        {
            int i;
            ArrayList array_word1 = new ArrayList(Convert.ToInt32(word1.Length));
            ArrayList array_word2 = new ArrayList(Convert.ToInt32(word2.Length));
            word1 = word1.ToLower();
            word2 = word2.ToLower();

            if (word1.Length != word2.Length)
                return false;

            for (i = 0; i < word1.Length; i++)
                array_word1.Add(word1[i].ToString());

            for (i = 0; i < word2.Length; i++)
                array_word2.Add(word2[i].ToString());

            foreach (string val in array_word1)
            {
                if (array_word2.Contains(val))
                    array_word2.Remove(val);
            }

            if (array_word2.Count == 0)
                return true;
            else
                return false;
        }
Example #28
0
 private static void CheckLineAreEqualEx(string expectPath, string outputPath, ArrayList ex, string msg)
 {
     if (!File.Exists(expectPath) || !File.Exists(outputPath))
     {
         Assert.Fail(expectPath + " File missing");
     }
     try
     {
         Int32 line = 0;
         StreamReader expectStream = new StreamReader(expectPath);
         StreamReader outputStream = new StreamReader(outputPath);
         while (!expectStream.EndOfStream)
         {
             line += 1;
             var expectLine = expectStream.ReadLine();
             var outputLine = outputStream.ReadLine();
             if (ex != null && ex.Contains(line))
             {
                 if (expectLine != outputLine)
                 {
                     Assert.Fail(msg);
                 }
             }
         }
         if (!outputStream.EndOfStream)
             Assert.Fail(msg);
         expectStream.Close();
         outputStream.Close();
     }
     catch (Exception)
     {
         Assert.Fail(msg);
     }
 }
 //合并
 public void combine(PropertyTypesManager srcPropertyTypesManager, ArrayList ids)
 {
     for (int i = 0; i < srcPropertyTypesManager.getElementCount(); i++)
     {
         if (ids == null || !ids.Contains(i))
         {
             continue;
         }
         PropertyTypeElement srcPropertyTypeElement = (PropertyTypeElement)srcPropertyTypesManager.getElement(i);
         //寻找相同的属性类型单元
         PropertyTypeElement localPropertyTypeElement = null;
         for (int j = 0; j < getElementCount(); j++)
         {
             PropertyTypeElement tempPropertyTypeElement = (PropertyTypeElement)getElement(j);
             if (tempPropertyTypeElement.name.Equals(srcPropertyTypeElement.name))
             {
                 localPropertyTypeElement = tempPropertyTypeElement;
                 break;
             }
         }
         //找到相同名称的本地单元
         if (localPropertyTypeElement != null)
         {
             localPropertyTypeElement.combine(srcPropertyTypeElement);
         }
         else//并入本容器
         {
             srcPropertyTypeElement.combineTo(this);
         }
     }
 }
Example #30
0
        public void scanning()
        {
            processesIds = new ArrayList();
            while (true)
            {
                Process[] processes;
                processes = Process.GetProcesses();

                for (int i = 0; i < processes.Length; i++)
                {
                    if (processes[i].ProcessName == processName)
                    {
                        Cliente cliente = new Cliente(processes[i]);
                        if (cliente.version() == version)
                        {
                            if (!(processesIds.Contains(cliente.id())) || processesIds.Count == 0)
                            {
                                processesIds.Add(cliente.id());

                                BackgroundWorker tibiaWorker = new BackgroundWorker();
                                tibiaWorker.DoWork += new DoWorkEventHandler(tibiaWorker_DoWork);
                                tibiaWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(tibiaWorker_RunWorkerCompleted);
                                tibiaWorker.RunWorkerAsync(cliente);
                            }
                        }
                    }
                }
                Thread.Sleep(15000);
            }
        }