Remove() public method

public Remove ( Object obj ) : void
obj Object
return void
Ejemplo n.º 1
0
 static void Main(string[] args)
 {
     ArrayList al = new ArrayList();
     al.Add("string");
     al.Add('B');
     al.Add(10);
     al.Add(DateTime.Now);
     ArrayList bl = new ArrayList(5);
     al.Remove('B');
     // 从al中删除第一个匹配的对象,如果al中不包含该对象,数组保持不变,不引发异常。
     al.Remove('B');
     al.RemoveAt(0);
     al.RemoveRange(0, 1);
     bl.Add(1);
     bl.Add(11);
     bl.Add(111);
     bl.Insert(4, 1111);
     int[] inttest = (int[])bl.ToArray(typeof(int));
     foreach(int it in inttest)
         Console.WriteLine(it);
     int[] inttest2 = new int[bl.Count];
     bl.CopyTo(inttest2);
     ArrayList cl = new ArrayList();
     cl.Add(1);
     cl.Add("Hello, World!");
     object[] ol = (object[])cl.ToArray(typeof(object));
     // stringp[] os = (string[])cl.ToArray(typeof(string));
     Console.WriteLine("The Capacity of new ArrayList: {0}", al.Capacity);
 }
        public bool Matches(object one, object two)
        {
            var expected = new ArrayList(one.As<ICollection>());
            var actual = new ArrayList(two.As<ICollection>());

            foreach (object o in actual.ToArray())
            {
                if (expected.Contains(o))
                {
                    actual.Remove(o);
                    expected.Remove(o);
                }
            }

            foreach (object o in expected.ToArray())
            {
                if (actual.Contains(o))
                {
                    actual.Remove(o);
                    expected.Remove(o);
                }
            }

            return actual.Count == 0 && expected.Count == 0;
        }
Ejemplo n.º 3
0
        public void crash(Fish fish, Form1 form, ArrayList fishList)
        {
            collision = aquaticAnimal.Bounds.IntersectsWith(fish.aquaticAnimal.Bounds);

             if (collision==true)
             {
                  if ((aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon adulto.png") || aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon hembra.png")) && (fish.aquaticAnimal.ImageLocation.Equals(@"Resources\Dorys.png") || fish.aquaticAnimal.ImageLocation.Equals(@"Resources\Nemo.png")))
                  {
                      fishList.Remove(fish);
                      fish.aquaticAnimal.Hide();
                  }
                  else if ((aquaticAnimal.ImageLocation.Equals(@"Resources\Dorys.png") || aquaticAnimal.ImageLocation.Equals(@"Resources\Nemo.png")) && (fish.aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon adulto.png") || fish.aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon hembra.png")))
                  {
                      fishList.Remove(aquaticAnimal);
                      aquaticAnimal.Hide();
                  }
                  else if ((aquaticAnimal.ImageLocation.Equals(@"Resources\Nemo.png") && fish.aquaticAnimal.ImageLocation.Equals(@"Resources\Nemo.png")))
                  {
                      fishList.Remove(fish);
                      aquaticAnimal.Hide();
                  }
                 else if ((aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon adulto.png") && fish.aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon adulto.png")))
                  {
                      fishList.Remove(aquaticAnimal);
                      aquaticAnimal.Hide();
                  }

             }
        }
Ejemplo n.º 4
0
		public static void CleanThread(ArrayList WorkThreadPool, int Timeout)
		{
			ThreadInfo CurrentThreadInfo;

			for (int index = 0; index < WorkThreadPool.Count; index++)
			{
				CurrentThreadInfo = (ThreadInfo)WorkThreadPool[index];

				// 清除已经结束的线程,不再保存信息
				if (CurrentThreadInfo.ThreadName.ThreadState == ThreadState.Stopped)
				{
					WorkThreadPool.Remove(CurrentThreadInfo);
				}

				// 清除超时没有连接上的线程,强行杀掉,并从池中清除信息
				// 超时按照毫秒计算
				else if (CurrentThreadInfo.LiveTime > Timeout)
				{
					CurrentThreadInfo.ThreadName.Abort();

					if (CurrentThreadInfo.ThreadName.Join(2000))
					{
						WorkThreadPool.Remove(CurrentThreadInfo);
					}
				}

				// 每个活动线程的已生存了的时间增加500毫秒
				else
				{
					CurrentThreadInfo.LiveTime += 500;
				}
			}
		}
Ejemplo n.º 5
0
        private void modificarEstadoVisualizacion(string NombreVisualizacion, string KeyVisualizacion, string KeyEstado, string DescripcionEstado, string Operacion, bool Activo, string Modo)
        {
            int  i               = 0;
            bool exist           = false;
            VisualizacionNueva v = null;

            while (!exist & i < _visualizacionesNuevas.Count)
            {
                v = (VisualizacionNueva)_visualizacionesNuevas[i];
                if (v.KeyVisualizacion.Equals(KeyVisualizacion) & v.KeyEstado.Equals(KeyEstado))
                {
                    exist = true;
                }
                else
                {
                    i++;
                }
            }
            if (exist)
            {
                if (v.Modo.Equals("ADD") & Modo.Equals("DEL"))
                {
                    v.Modo = Modo;
                    _visualizacionesNuevas.Remove(v);
                }
                else if (v.Modo.Equals("ADD") & Modo.Equals("MODIFOP"))
                {
                    v.Operacion = Operacion;
                }
                else if (v.Modo.Equals("DEL") & Modo.Equals("ADD"))
                {
                    if (v.Operacion.Equals(Operacion))
                    {
                        _visualizacionesNuevas.Remove(v);
                        v.Modo = "NOTHING";
                    }
                    else
                    {
                        v.Operacion = Operacion;
                        v.Modo      = "MODIFOP";
                    }
                }
                else if (v.Modo.Equals("MODIFOP") & Modo.Equals("DEL"))
                {
                    v.Modo = Modo;
                }
                else if (v.Modo.Equals("MODIFOP") & Modo.Equals("MODIFOP"))
                {
                    v.Operacion = Operacion;
                }
                _visualizacionModificada = v;
            }
            else
            {
                _visualizacionModificada = new VisualizacionNueva(NombreVisualizacion, KeyVisualizacion, KeyEstado, DescripcionEstado, Operacion, Activo, Modo);
                _visualizacionesNuevas.Add(_visualizacionModificada);
            }
        }
        static void Main(string[] args)
        {
            Microsoft.Win32.SafeHandles.SafeFileHandle h;
            string dEntry = "\\";
            ArrayList entries = new ArrayList();
            entries.Add(dEntry);
            while (entries.Count != 0)
            {
                foreach (String entry in entries)
                {
                    var attr = new Win.OBJECT_ATTRIBUTES(entry, 0);
                    var st = Win.NtOpenDirectoryObject(out h, 1, ref attr);
                    if (st < 0)
                    {
                        h.Dispose();
                        entries.Remove(entry);
                        break;
                    }

                    var bufsz = 1024;
                    var buf = Marshal.AllocHGlobal(bufsz);
                    uint context = 0, len;
                    while (true)
                    {
                        st = Win.NtQueryDirectoryObject(h, buf, bufsz, true, context == 0, ref context, out len);
                        if (st < 0)
                        {
                            entries.Remove(entry);
                            Marshal.FreeHGlobal(buf);
                            h.Dispose();
                            break;
                        }
                        var odi = (Win.OBJECT_DIRECTORY_INFORMATION)
                          Marshal.PtrToStructure(buf, typeof(Win.OBJECT_DIRECTORY_INFORMATION));
                        if (Convert.ToString(odi.TypeName) == "Mutant")
                        {
                            Console.WriteLine("0x{0:X2}:{1,-25}{2}", context, odi.TypeName, odi.Name);
                            parseMutex(Convert.ToString(odi.Name));
                        }
                        if (Convert.ToString(odi.TypeName) == "Directory")
                        {
                            if (entry == "\\")
                            {
                                entries.Add(entry + Convert.ToString(odi.Name));
                            }
                            else
                            {
                                entries.Add(entry + "\\" + Convert.ToString(odi.Name));
                            }
                        }
                    }
                    break;
                }
            }
        }
Ejemplo n.º 7
0
        private static void play()
        {
            Console.WriteLine("Would you prefer what is behind door number 1, 2, or 3?");
            int min = 1;
            int max = 4;

            // Load the random numbers
            ArrayList availableNumbers = new ArrayList();
            for (int i = min; i < max; i++)
                availableNumbers.Add(i);

            // Assign the first number to the car's door number
            int carValue = RandomNumber(min, max);
            availableNumbers.Remove(carValue);
            int boatValue = carValue;
            int catValue;
            string message;

            // Randomly search for a value for the boat's door number
            while (!availableNumbers.Contains(boatValue))
                boatValue = RandomNumber(min, max);
            availableNumbers.Remove(boatValue);

            // Assign the cat value the remaining number
            catValue = (int)availableNumbers[0];

            // DEBUG
            //Console.WriteLine(String.Format("CarValue: {0} BoatValue: {1} CatValue: {2}",carValue,boatValue,catValue));

            // Read the user input
            int userValue = readNumber(min, max);

            // The 'CatValue' variable now only holds debug purposes, due to sufficient validation on the integer input
            if (userValue == carValue)
                message = "You won a new car!";
            else if (userValue == boatValue)
                message = "You won a new boat!";
            else
                message = "You won a new cat!";

            Console.WriteLine(message);

            Console.WriteLine("Do you want to play again? [Y/N]");
            TextInfo ti = new CultureInfo("en-US", false).TextInfo;
            if (String.Compare(ti.ToLower(readString()), "y") == 0)
            {
                // Repeat
                Console.WriteLine("");
                play();
            }
            else
                // Cleanly exit
                Environment.Exit(-1);
        }
Ejemplo n.º 8
0
 private void frmMessageNotify_Closed(object sender, System.EventArgs e)
 {
     if (this.Visible)
     {
         System.Threading.Interlocked.Decrement(ref s_intInstance);
         int intIndex = s_arlForms.IndexOf(this);
         s_arlForms.Remove(this);
         for (int i = intIndex; i < s_arlForms.Count; i++)
         {
             frmMessageNotify frmTemp = ((frmMessageNotify)s_arlForms[i]);
             frmTemp.Location = new Point(frmTemp.Location.X, frmTemp.Location.Y + this.Height);
         }
         ;
     }
 }
Ejemplo n.º 9
0
        private void button3_Click(object sender, EventArgs e)
        {
            ArrayList arr = new ArrayList();
            arr.Add(10);
            arr.Add(20); //To add a new element at the end of collection
            arr.Add(30);
            arr.Add(40);
            arr.Add(50);
            arr.Add(60);
            arr.Add(70);
            arr.Add(80);
            arr.Add(90);
            arr[3] = 400; //To overwrite the value
            MessageBox.Show(arr.Capacity.ToString());
            arr.Insert(3, 1000);//insert in the middle
            //shift the other elements =>index,value
            foreach (object obj in arr)
            {
                listBox3.Items.Add(obj.ToString());
            }

            arr[12] = 10; //Runtime error

            arr.Remove(10);  //remove 10 <=value
            arr.RemoveAt(1); //remove element at index 1 <=index
        }
Ejemplo n.º 10
0
        public void PrintWords()
        {
            var word = _dictionary.GetNextWord(_letterCount);
            var i = 1;
            while (word != null)
            {
                var containsValidLetters = true;
                var tmpAlphabet = new ArrayList(_alphabet);

                foreach (var item in word)
                {
                    if (tmpAlphabet.Contains(item))
                    {
                        // такая буква есть в слове, удаляем её из алфавита, 
                        // чтобы не использовать дважды
                        tmpAlphabet.Remove(item);
                    }
                    else
                    {
                        // DEBUG
                        //Console.WriteLine("***" + word + "***");
                        // END DEBUG
                        containsValidLetters = false;
                        break;
                    }
                }

                if (containsValidLetters)
                {
                    Console.WriteLine("{0} {1}", i++, word);
                }

                word = _dictionary.GetNextWord(_letterCount);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //1. create empty ArrayList
            ArrayList al = new ArrayList();

            //2. add element into array list
            al.Add("Dog");
            al.Add("Cat");
            al.Add("Elephant");
            al.Add("Lion");
            al.Add("Cat");
            al.Add("Platypus");

            //3. bind above arrayList to first list box
            lbOriginal.DataSource = al;
            lbOriginal.DataBind();

            //4. change (insert -> remove ->remove)
            al.Insert(1, "Chicken~~~");
            al.Remove("Cat");
            al.RemoveAt(0);

            //5. bind the result into second list box
            lbChanged.DataSource = al;
            lbChanged.DataBind();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Remove owner window from hook tracing
        /// </summary>
        /// <param name="owner_window">owner window</param>
        static public void RemoveOwnerWindow(IntPtr owner_window)
        {
            lock (static_lock_variable)
            {
                try
                {
                    ICollection a = (ICollection)owner_windows.Clone();
                    ArrayList al = new ArrayList((ICollection)a);
                    al.Remove(owner_window);
                    owner_windows = (IntPtr[])al.ToArray(typeof(IntPtr));

                    owner_window_logs.Remove(owner_window);

                    if (owner_windows.Length < 1 && hook_id != IntPtr.Zero)
                    {
                        Win32.UnhookWindowsHookEx(hook_id);
                        hook_id = IntPtr.Zero;
                    }
                }
                catch (Exception e)
                {
                    Log.Main.Exit(e);
                }
            }
        }
Ejemplo n.º 13
0
 public List(Type type)
 {
     _myType = type;
     _list = new ArrayList();
     _list.Remove(0);
     _index = 0;
 }
        static void Main()
        {
            Console.Write("List 1: ");
            string[] names1 = Console.ReadLine().Split(' ');
            Console.Write("List 2: ");
            string[] names2 = Console.ReadLine().Split(' ');

            ArrayList list1 = new ArrayList(names1);
            ArrayList list2 = new ArrayList(names2);

            for (int i = 0; i < list2.Count; i++)
            {
                while (list1.Contains(list2[i]))
                {
                    list1.Remove(list2[i]);
                }
            }

            for (int i = 0; i < list1.Count; i++)
            {
                Console.Write(list1[i]);
                if (i < list1.Count - 1)
                {
                    Console.Write(" ");
                }
            }

            Console.WriteLine();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Moves the selected items from the origin to the destination.
        /// </summary>
        /// <param name="origin">The origin.</param>
        /// <param name="destination">The destination.</param>
        private static void moveItem(ListBox origin, ListBox destination)
        {
            //Create ArrayList of current items
            var originList = new ArrayList(origin.Items);

            //Create ArrayList of destination items
            var destinationList = new ArrayList(destination.Items);

            //Add selected items from origin listbox to destination list
            foreach (ListBoxItem item in origin.SelectedItems)
            {
                destinationList.Add(item);
            }

            //remove the selected items from the origin list
            foreach (var item in origin.SelectedItems)
            {
                originList.Remove(item);
            }

            //Comparer for sorting
            var comparer = new ListBoxItem();

            //Clear and repopulate origin Listbox sorted
            originList.Sort(comparer);
            origin.Items.Clear();
            origin.Items.AddRange(originList.ToArray());

            //Clear and repopulate destination Listbox sorted
            destinationList.Sort(comparer);
            destination.Items.Clear();
            destination.Items.AddRange(destinationList.ToArray());
        }
Ejemplo n.º 16
0
        public void Test(int arg)
        {
            ArrayList items = new ArrayList();
            items.Add(1);
            items.AddRange(1, 2, 3);
            items.Clear();
            bool b1 = items.Contains(2);
            items.Insert(0, 1);
            items.InsertRange(1, 0, 5);
            items.RemoveAt(4);
            items.RemoveRange(4, 3);
            items.Remove(1);
            object[] newItems = items.GetRange(5, 2);
            object[] newItems2 = items.GetRange(5, arg);

            List<int> numbers = new List<int>();
            numbers.Add(1);
            numbers.AddRange(1, 2, 3);
            numbers.Clear();
            bool b2 = numbers.Contains(4);
            numbers.Insert(1, 10);
            numbers.InsertRange(2, 10, 3);
            numbers.RemoveAt(4);
            numbers.RemoveRange(4, 2);
            int[] newNumbers = items.GetRange(5, 2);
            int[] newNumbers2 = items.GetRange(5, arg);

            string[] words = new string[5];
            words[0] = "hello";
            words[1] = "world";
            bool b3 = words.Contains("hi");
            string[] newWords = words.GetRange(5, 2);
            string[] newWords2 = words.GetRange(5, arg);
        }
        public void fun1()
        {
            ArrayList a1 = new ArrayList();
            a1.Add(1);
            a1.Add('c');
            a1.Add("string1");

            ArrayList al2 = new ArrayList();
            al2.Add('a');
            al2.Add(5);

            int n = (int)a1[0];
            Console.WriteLine(n);
            a1[0] = 20;
            Console.WriteLine(a1.Count);
            Console.WriteLine(a1.Contains(55));
            Console.WriteLine(a1.IndexOf(55));
            //int[] num = (int[])a1.ToArray();

            a1.Add(45);
            a1.Add(12);
            a1.Add(67);

            a1.Insert(1, "new value");
            //a1.AddRange(al2);
            a1.InsertRange(1, al2);
            a1.Remove("string1");
            a1.RemoveAt(2);
            a1.RemoveRange(0, 2);

            foreach (object o in a1)
            {
                Console.WriteLine(o.ToString());
            }
        }
Ejemplo n.º 18
0
        protected void SortUp(Message message)
        {
            Assert.ArgumentNotNull(message, "message");
            if (this.SelectedIndex <= 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
            DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);

            System.Collections.ArrayList renderings = device.Renderings;
            if (renderings == null)
            {
                return;
            }
            RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition;

            if (renderingDefinition == null)
            {
                return;
            }
            renderings.Remove(renderingDefinition);
            renderings.Insert(this.SelectedIndex - 1, renderingDefinition);
            this.SelectedIndex--;
            DeviceEditorForm.SetDefinition(layoutDefinition);
            this.Refresh();
        }
Ejemplo n.º 19
0
 public void Remove(TileListItem value)
 {
     // TODO:  Add ControlListView.Remove implementation
     controlList.Remove(value);
     this.Controls.Remove(value);
     ReCalculateItems();
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Get an invalid string by returning non characters Entry point (and might return invalid Surrogate pair)
        /// </summary>
        /// <param name="stringSize">(int) The size of the string to return </param>
        /// <param name="percentInvalid">(double) The percentage of characters in the string to be invalid (must be bigger than 0.0 and less or equal to 1.0)</param>
        /// <returns>(string) Return an invalid string</returns>
        public static string GetInvalidString(int stringSize, double percentInvalid)
        {
            // check params
            if (percentInvalid <= 0.0 || percentInvalid > 1.0)
            {
                throw new ArgumentOutOfRangeException("percentInvalid", percentInvalid, "percentage must be between 0.0 (excluded) and 1.0 (included)");
            }

            /*
             * System.Collections.Hashtable invalidHash = new System.Collections.Hashtable(m_invalidPoints.Length);
             * for(int t = 0; t < m_invalidPoints.Length; t++)
             * {
             *  invalidHash.Add(m_invalidPoints[t], null);
             * }
             */


            // Compute the number of char to be invalid
            int invalidCharSize = (int)(stringSize * percentInvalid);

            if (invalidCharSize == 0)
            {
                invalidCharSize = 1;
            }


            // build a list of invalid and valid item

/*
 *                  char[] invalidEntries = new char[m_invalidHash.Keys.Count];
 *                  m_invalidHash.Keys.CopyTo(invalidEntries,0);
 */
            System.Collections.ArrayList list = new System.Collections.ArrayList((int)stringSize);
            for (int t = 0; t < invalidCharSize; t++)
            {
//                        list.Add(invalidEntries[ m_rnd.Next(invalidEntries.Length)]);
                list.Add(m_invalidEntries[m_rnd.Next(m_invalidHash.Keys.Count)]);
            }
            for (int t = 0; t < (int)stringSize - invalidCharSize; t++)
            {
                char entryPoint;
                do
                {
                    entryPoint = (char)m_rnd.Next(0x10000);
                } while(m_invalidHash.Contains(entryPoint));
                list.Add(entryPoint);
            }

            // Arrange the string to be random
            int           listSize = list.Count;
            StringBuilder sb       = new StringBuilder(listSize);

            for (int i = 0; i < listSize; i++)
            {
                int index = m_rnd.Next(list.Count);
                sb.Append((char)list[index]);
                list.Remove(list[index]);
            }
            return(sb.ToString());
        }
Ejemplo n.º 21
0
        public void NachrichtAnAlle(ArrayList b, string Nachricht)
        {
            //dringend bearbeiten

            while (true)
            {
                try
                {
                    foreach (Server.extended y in b)
                    {
                        try
                        {
                            NetworkStream clientStream = y.tcp.GetStream();
                            ASCIIEncoding encoder = new ASCIIEncoding();
                            byte[] buffer = encoder.GetBytes(Nachricht);

                            clientStream.Write(buffer, 0, buffer.Length);
                            clientStream.Flush();

                        }
                        catch
                        {
                            b.Remove(y);
                        }

                    }
                    break;
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 22
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);
            }
        }
Ejemplo n.º 23
0
        public ActionResult EditUser(string id, bool approved)
        {
            //Is a list of all the user roles
            ArrayList removeRoleList = new ArrayList(Roles.GetAllRoles());

            //We are requesting the form variables directly from the form
            foreach (string key in Request.Form.Keys)
            {
                if (key.StartsWith("role."))
                {
                    String userRole = key.Substring(5, key.Length - 5);
                    removeRoleList.Remove(userRole);
                    if (!Roles.IsUserInRole(id, userRole))
                    {
                        Roles.AddUserToRole(id, userRole);
                    }
                }
            }

            foreach (string removeRole in removeRoleList)
                Roles.RemoveUserFromRole(id, removeRole);

            MembershipUser membershipUser = Membership.GetUser(id);
            membershipUser.IsApproved = approved;
            Membership.UpdateUser(membershipUser);

            TempData["SuccessMessage"] = "User Information has been updated";
            ViewData["roles"] = (String[])Roles.GetAllRoles();
            ViewData["PageTitle"] = "Edit " + id;
            return View(membershipUser);
        }
Ejemplo n.º 24
0
        public void Verify(ParameterList actualList)
        {
            var expectedKeys = new ArrayList(AllKeys);
            var actualKeys = new ArrayList(actualList.AllKeys);
            var unionKeys = new ArrayList();

            var keys = (string[]) actualKeys.ToArray(typeof (string));

            foreach (string key in keys)
            {
                if (expectedKeys.Contains(key))
                {
                    unionKeys.Add(key);
                    expectedKeys.Remove(key);
                    actualKeys.Remove(key);
                }
            }

            var failureCondition = new ParameterValidationFailureException();

            checkForWrongParameterValues(unionKeys, actualList, failureCondition);
            checkForMissingParameters(expectedKeys, failureCondition);
            checkForUnExpectedParameters(actualList, actualKeys, failureCondition);

            failureCondition.ThrowIfExceptions();
        }
Ejemplo n.º 25
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;
        }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            ArrayList a = new ArrayList();
            a.Add(123);
            a.Add("BARD");
            a.Add(34.689);
            a.Insert(2, 'A');
            a.Remove(123);
            a.RemoveAt(2);
            foreach (Object o in a)
            {
                Console.WriteLine(o.ToString());
            }

            //Student s = new Student();
            //s.GetData();
            //a.Add(s);
            //foreach (Object o in a)
            //{
            //    if (o.GetType().ToString() == "ArrayListSample.Student")
            //    {
            //        Student s1 = (Student)o;
            //        s1.ShowData();
            //    }
            //}
            //Console.WriteLine("No of elements are:" +a.Count);

            Console.Read();
        }
Ejemplo n.º 27
0
        public static void Main(string[] args)
        {
            ArrayList list = new ArrayList();
            Dog[] mas = new Dog[1];

            Dog dog1 = new Dog("no name 0",12,0.1f);

            list.Add(dog1);
            list.Add(new chicken("no name 1",2,0.4f));
            list.Add(new Dog("no name 2",1,0.1f));
            mas[0] = dog1;

            foreach(Dog d in list)
            {
                    list.Remove(d);
                    Console.WriteLine("{0} - убит",d.name);
                    break;
            }

            cow[] muMas = new cow[3];
            muMas[0] = new cow("no name 3",13,0.1f);
            muMas[1] = new cow("no name 4",3,0.2f);
            muMas[2] = new cow("no name 5",11,0.4f);

            list.Add(muMas);

            foreach(object d in list)
            {
                Console.WriteLine(d.ToString());
                if(d.Equals(muMas))
                    foreach(cow c in muMas)
                        Console.WriteLine(c.ToString()+"; индексатор "+c[0]);

            }
        }
Ejemplo n.º 28
0
 /// <summary>Removes previously suspected member from list of currently suspected members </summary>
 public override void  unsuspect(Address mbr)
 {
     if (mbr != null)
     {
         suspected_mbrs.Remove(mbr);
     }
 }
Ejemplo n.º 29
0
 public void CustomAttributes()
 {
     ArrayList expectedValues = new ArrayList(new int[] { 12, 34, 56 });
     MyAttribute[] attributes = (MyAttribute[]) JsonRpcServices.GetClassFromType(typeof(TestService)).GetMethodByName("Foo").GetCustomAttributes(typeof(MyAttribute));
     Assert.AreEqual(3, attributes.Length);
     foreach (MyAttribute attribute in attributes)
         expectedValues.Remove(attribute.TestValue);
     Assert.AreEqual(0, expectedValues.Count);
 }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            Console.WriteLine("Basic Array List Testing:");
            ArrayList al = new ArrayList();
            al.Add("Hello");
            al.Add("World");
            al.Add(5);
            al.Add(new FileStream("deleteme", FileMode.Create));

            Console.WriteLine("The array has " + al.Count + " items");

            foreach (object o in al)
            {
                Console.WriteLine(o.ToString());
            }

            Console.WriteLine("\nRemove, Insert and Sort Testing:");
            al = new ArrayList();
            al.Add("Hello");
            al.Add("World");
            al.Add("this");
            al.Add("is");
            al.Add("a");
            al.Add("test");

            Console.WriteLine("\nBefore:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());


            al.Remove("test");
            al.Insert(4, "not");

            al.Sort();

            Console.WriteLine("\nAfter:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());

            al.Sort(new reverseSorter());
            Console.WriteLine("\nReversed:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());

            al.Reverse();
            Console.WriteLine("\nReversed again, different method:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());

            Console.WriteLine("\nBinary Search Example:");
            al = new ArrayList();
            al.AddRange(new string[] { "Hello", "World", "this", "is", "a", "test" });
            foreach (object s in al)
                Console.Write(s + " ");
            Console.WriteLine("\n\"this\" is at index: " + al.BinarySearch("this"));
        }
        internal SoapParameters(XmlMembersMapping request, XmlMembersMapping response, string[] parameterOrder, CodeIdentifiers identifiers) {
            ArrayList requestList = new ArrayList();
            ArrayList responseList = new ArrayList();

            AddMappings(requestList, request);
            if (response != null) AddMappings(responseList, response);

            if (parameterOrder != null) {
                for (int i = 0; i < parameterOrder.Length; i++) {
                    string elementName = parameterOrder[i];
                    XmlMemberMapping requestMapping = FindMapping(requestList, elementName);
                    SoapParameter parameter = new SoapParameter();
                    if (requestMapping != null) {
                        if (RemoveByRefMapping(responseList, requestMapping))
                            parameter.codeFlags = CodeFlags.IsByRef;
                        parameter.mapping = requestMapping;
                        requestList.Remove(requestMapping);
                        AddParameter(parameter);
                    }
                    else {
                        XmlMemberMapping responseMapping = FindMapping(responseList, elementName);
                        if (responseMapping != null) {
                            parameter.codeFlags = CodeFlags.IsOut;
                            parameter.mapping = responseMapping;
                            responseList.Remove(responseMapping);
                            AddParameter(parameter);
                        }
                    }
                }
            }

            foreach (XmlMemberMapping requestMapping in requestList) {
                SoapParameter parameter = new SoapParameter();
                if (RemoveByRefMapping(responseList, requestMapping))
                    parameter.codeFlags = CodeFlags.IsByRef;
                parameter.mapping = requestMapping;
                AddParameter(parameter);
            }

            if (responseList.Count > 0) {
                if (!((XmlMemberMapping) responseList[0]).CheckSpecified) {
                    ret = (XmlMemberMapping)responseList[0];
                    responseList.RemoveAt(0);
                }
                foreach (XmlMemberMapping responseMapping in responseList) {
                    SoapParameter parameter = new SoapParameter();
                    parameter.mapping = responseMapping;
                    parameter.codeFlags = CodeFlags.IsOut;
                    AddParameter(parameter);
                }
            }

            foreach (SoapParameter parameter in parameters) {
                parameter.name = identifiers.MakeUnique(CodeIdentifier.MakeValid(parameter.mapping.MemberName));
            }
        }
Ejemplo n.º 32
0
        public void Remove(ExifEntry entry)
        {
            Assemble();

            entries.Remove(entry);
            // This call can recurse into this function but it protects
            // itself by checking if it the content already contains the entry
            entry.SetParent(null);
            exif_content_remove_entry(this.handle, entry.Handle);
        }
Ejemplo n.º 33
0
		public static Mnozina operator - (Mnozina a, Mnozina b)
		{
			ArrayList rozdil = new ArrayList();
			rozdil.AddRange(a.seznam);
			foreach(int x in b.seznam)
			{
				rozdil.Remove(x);
			}
			return new Mnozina(rozdil);
		}
        //前回のローカルデータから新規ローカルデータの作成
        public object Apply(object oldValue, NCMBObject obj, string key)
        {
            //前回のローカルデータ(estimatedDataに指定のキーが無い場合)がNullの場合
            if (oldValue == null) {
                //return new List<object> ();
                return new ArrayList ();//追加
            }
            //配列のみリムーブ実行
            if ((oldValue is IList)) {

                //削除処理を行う
                //ArrayList result = new ArrayList ((IList)oldValue);
                //result = NCMBUtility._removeAllFromListMainFunction ((IList)oldValue, this.objects);

                //取り出したローカルデータから今回の引数で渡されたオブジェクトの削除
                ArrayList result = new ArrayList ((IList)oldValue);
                foreach (object removeObj in this.objects) {
                    while (result.Contains(removeObj)) {//removeAllと同等
                        result.Remove (removeObj);
                    }
                }
                //以下NCMBObject重複処理
                //今回引数で渡されたオブジェクトから1.のオブジェクトの削除
                ArrayList objectsToBeRemoved = new ArrayList ((IList)this.objects);

                foreach (object removeObj2 in result) {
                    while (objectsToBeRemoved.Contains(removeObj2)) {//removeAllと同等
                        objectsToBeRemoved.Remove (removeObj2);
                    }
                }

                //結果のリスト(引数)の中のNCMBObjectがすでに保存されている場合はobjectIdを返す
                HashSet<object> objectIds = new HashSet<object> ();
                foreach (object hashSetValue in objectsToBeRemoved) {
                    if (hashSetValue is NCMBObject) {
                        NCMBObject valuesNCMBObject = (NCMBObject)hashSetValue;
                        objectIds.Add (valuesNCMBObject.ObjectId);
                    }

                    //resultの中のNCMBObjectからobjectIdsの中にあるObjectIdと一致するNCMBObjectの削除
                    object resultValue;
                    for (int i = 0; i < result.Count; i++) {
                        resultValue = result [i];
                        if (resultValue is NCMBObject) {
                            NCMBObject resultNCMBObject = (NCMBObject)resultValue;
                            if (objectIds.Contains (resultNCMBObject.ObjectId)) {
                                result.RemoveAt (i);
                            }
                        }
                    }
                }
                return result;
            }
            throw new  InvalidOperationException ("Operation is invalid after previous operation.");
        }
 static void Main(string[] args)
 {
     ArrayList liste = new ArrayList { "Robert", "Markus", "Papa", "Ines" };
     Console.WriteLine("-------------Schreibe Liste-------------");
     PrintListe(liste);
     Console.WriteLine("Liste geschrieben \n\n");
     liste.Remove("Robert");
     Console.WriteLine("-------------Schreibe neue Liste --------------");
     PrintListe(liste);
     Console.ReadLine();
 }
Ejemplo n.º 36
0
        public System.Collections.IEnumerable GetBaseTypeFullNameList(object type)
        {
            TypeDefinition t = (TypeDefinition) type;
            AssemblyDefinition asm = GetAssemblyDefinition (t);

            ArrayList list = new ArrayList ();
            Hashtable visited = new Hashtable ();
            GetBaseTypeFullNameList (visited, list, asm, t);
            list.Remove (t.FullName);
            return list;
        }
Ejemplo n.º 37
0
		private static void AssertArraysAreEqualUnsorted(object[] expected, object[] actual)
		{
			Assert.AreEqual(expected.Length, actual.Length);
			ArrayList actualAsList = new ArrayList(actual);
			foreach(object expectedElement in expected)
			{
				Assert.Contains(expectedElement, actualAsList);
				actualAsList.Remove(expectedElement);
					// need to remove the element after it has been found to guarantee that duplicate elements are handled correctly
			}
		}
Ejemplo n.º 38
0
 /// <summary>
 /// Disconnect this port from another port.
 /// </summary>
 /// <param name="other"></param>
 public void DisconnectFrom(Port other)
 {
     if (other == null)
     {
         return;
     }
     if (this == other)
     {
         return;
     }
     connectedPorts.Remove(other);
     other.connectedPorts.Remove(this);
 }
Ejemplo n.º 39
0
    private DataTable RemoveRow(GridViewRow gvRow, DataTable dt)
    {
        DataRow[] dr = dt.Select("PersonalID = '" + gvRow.Cells[1].Text + "'");
        emailList.Remove(gvRow.Cells[4].Text.Trim());
        if (dr.Length > 0)
        {
            dt.Rows.Remove(dr[0]);
            dt.AcceptChanges();
        }


        return(dt);
    }
 static public int Remove(IntPtr l)
 {
     try {
         System.Collections.ArrayList self = (System.Collections.ArrayList)checkSelf(l);
         System.Object a1;
         checkType(l, 2, out a1);
         self.Remove(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 41
0
 static int Remove(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.CheckObject(L, 1, typeof(System.Collections.ArrayList));
         object arg0 = ToLua.ToVarObject(L, 2);
         obj.Remove(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 42
0
        /* ---------------------------------- Private Methods --------------------------------------- */

        /// <summary> Determines whether this member is the new coordinator given a list of suspected members.  This is
        /// computed as follows: the list of currently suspected members (suspected_mbrs) is removed from the current
        /// membership. If the first member of the resulting list is equals to the local_addr, then it is true,
        /// otherwise false. Example: own address is B, current membership is {A, B, C, D}, suspected members are {A,
        /// D}. The resulting list is {B, C}. The first member of {B, C} is B, which is equal to the
        /// local_addr. Therefore, true is returned.
        /// </summary>
        internal virtual bool wouldIBeCoordinator()
        {
            Address new_coord = null;

            System.Collections.ArrayList mbrs = gms.members.Members;             // getMembers() returns a *copy* of the membership vector

            for (int i = 0; i < suspected_mbrs.Count; i++)
            {
                mbrs.Remove(suspected_mbrs[i]);
            }

            if (mbrs.Count < 1)
            {
                return(false);
            }
            new_coord = (Address)mbrs[0];
            return(gms.local_addr.Equals(new_coord));
        }
Ejemplo n.º 43
0
    private void MSG_CLIENT_EXIT_WORLD_RESPONSE()
    {
        //to do ,读取流信息, 跟新玩家列表与信息
        NetBitStream stream = new NetBitStream();

        stream.BeginRead2(packet);
        string name = "";

        stream.ReadString(out name);
        foreach (Player p in playerList)
        {
            if (p.name.Equals(name))
            {
                playerList.Remove(p);
                CGameManager.Instance.RemovePlayer(name);
                break;
            }
        }
    }
Ejemplo n.º 44
0
        /// <summary>
        /// 初始化
        /// </summary>
        public int Init()
        {
            Neusoft.FrameWork.Management.DataBaseManger dataBaseManager = new Neusoft.FrameWork.Management.DataBaseManger();

            this.OperDept = ((Neusoft.HISFC.Models.Base.Employee)dataBaseManager.Operator).Dept;

            if (this.isOtherDrugDept)
            {
                Neusoft.HISFC.BizProcess.Integrate.Manager integrateManager = new Neusoft.HISFC.BizProcess.Integrate.Manager();
                System.Collections.ArrayList al = integrateManager.GetDepartment(Neusoft.HISFC.Models.Base.EnumDepartmentType.P);
                foreach (Neusoft.HISFC.Models.Base.Department tempDept in al)
                {
                    if (tempDept.ID == this.OperDept.ID)
                    {
                        al.Remove(tempDept);
                        break;
                    }
                }
                Neusoft.FrameWork.Models.NeuObject info = new Neusoft.FrameWork.Models.NeuObject();
                if (Neusoft.FrameWork.WinForms.Classes.Function.ChooseItem(al, ref info) == 0)
                {
                    return(-1);
                }
                else
                {
                    this.OperDept = info;
                }
            }

            this.OperInfo    = dataBaseManager.Operator;
            this.ApproveDept = ((Neusoft.HISFC.Models.Base.Employee)dataBaseManager.Operator).Dept;

            if (this.InitTerminal() == -1)
            {
                return(-1);
            }

            this.InitControlParm();

            return(1);
        }
Ejemplo n.º 45
0
        protected void RemovePlaceholder(Message message)
        {
            Assert.ArgumentNotNull(message, "message");
            if (string.IsNullOrEmpty(this.UniqueId))
            {
                return;
            }
            LayoutDefinition      layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
            DeviceDefinition      device           = layoutDefinition.GetDevice(this.DeviceID);
            PlaceholderDefinition placeholder      = device.GetPlaceholder(this.UniqueId);

            if (placeholder == null)
            {
                return;
            }
            System.Collections.ArrayList placeholders = device.Placeholders;
            if (placeholders != null)
            {
                placeholders.Remove(placeholder);
            }
            DeviceEditorForm.SetDefinition(layoutDefinition);
            this.Refresh();
        }
Ejemplo n.º 46
0
        public override void  handleSuspect(Address mbr)
        {
            System.Collections.ArrayList suspects = null;

            lock (this)
            {
                if (mbr == null)
                {
                    return;
                }
                if (!suspected_mbrs.Contains(mbr))
                {
                    Address sameNode = null;

                    if (gms.isPartReplica)
                    {
                        Membership mbrShip = gms.members.copy();

                        if (mbrShip.contains(mbr))
                        {
                            for (int i = 0; i < mbrShip.size(); i++)
                            {
                                Address other = mbrShip.elementAt(i);
                                if (other != null && !other.Equals(mbr))
                                {
                                    if (other.IpAddress.Equals(mbr.IpAddress))
                                    {
                                        sameNode = other;
                                        break;
                                    }
                                }
                            }
                        }
                    }


                    if (sameNode != null && !sameNode.IpAddress.Equals(gms.local_addr.IpAddress))
                    {
                        if (sameNode.Port > mbr.Port)
                        {
                            suspected_mbrs.Add(sameNode);
                            suspected_mbrs.Add(mbr);
                        }
                        else
                        {
                            suspected_mbrs.Add(mbr);
                            suspected_mbrs.Add(sameNode);
                        }
                    }
                    else
                    {
                        suspected_mbrs.Add(mbr);
                    }
                }



                if (gms.Stack.NCacheLog.IsInfoEnabled)
                {
                    gms.Stack.NCacheLog.Info("suspected mbr=" + mbr + ", suspected_mbrs=" + Global.CollectionToString(suspected_mbrs));
                }

                if (!leaving)
                {
                    if (wouldIBeCoordinator() && !gms.IsCoordinator)
                    {
                        suspects = (System.Collections.ArrayList)suspected_mbrs.Clone();
                        suspected_mbrs.Clear();
                        gms.becomeCoordinator();

                        foreach (Address leavingMbr in suspects)
                        {
                            if (!gms.members.Members.Contains(leavingMbr))
                            {
                                gms.Stack.NCacheLog.Debug("pbcast.PariticipantGmsImpl.handleSuspect()", "mbr " + leavingMbr + " is not a member !");
                                continue;
                            }
                            if (gms.Stack.NCacheLog.IsInfoEnabled)
                            {
                                gms.Stack.NCacheLog.Info("suspected mbr=" + leavingMbr + "), members are " + gms.members + ", coord=" + gms.local_addr + ": I'm the new coord !");
                            }
                            //=====================================================
                            //update gms' subgroupMbrMap.
                            string subGroup = (string)gms._mbrSubGroupMap[leavingMbr];
                            if (subGroup != null)
                            {
                                lock (gms._mbrSubGroupMap.SyncRoot)
                                {
                                    gms._mbrSubGroupMap.Remove(leavingMbr);
                                }
                                lock (gms._subGroupMbrsMap.SyncRoot)
                                {
                                    System.Collections.ArrayList subGroupMbrs = (System.Collections.ArrayList)gms._subGroupMbrsMap[subGroup];
                                    if (subGroupMbrs != null)
                                    {
                                        subGroupMbrs.Remove(leavingMbr);
                                        if (subGroupMbrs.Count == 0)
                                        {
                                            gms._subGroupMbrsMap.Remove(subGroup);
                                        }
                                    }
                                }
                            }
                            //=====================================================
                            ArrayList list = new ArrayList(1);
                            list.Add(leavingMbr);
                            gms.acquireHashmap(list, false, subGroup, false);
                        }
                        gms.castViewChange(null, null, suspects, gms._hashmap);
                    }
                    else
                    {
                        if (gms.IsCoordinator)
                        {
                            sendMemberLeftNotificationToCoordinator(mbr, gms.local_addr);
                        }
                        else
                        {
                            sendMemberLeftNotificationToCoordinator(mbr, gms.determineCoordinator());
                        }
                    }
                }
            }
        }
Ejemplo n.º 47
0
        public int DealSubjob(Neusoft.HISFC.Models.Registration.Register r, System.Collections.ArrayList alFee, ref string errText)
        {
            if (r.Pact.ID == "6" || r.Pact.ID == "7")
            {
                ArrayList NoFeeList = managerIntegrate.QueryConstantList("NOFEESUBJOB");
                if (NoFeeList == null)
                {
                    errText = "查询不收费辅材项目失败!" + managerIntegrate.Err;
                    return(-1);
                }

                //按照组合号分组
                Dictionary <string, List <FeeItemList> > feeList = new Dictionary <string, List <FeeItemList> >();
                foreach (Neusoft.HISFC.Models.Fee.Outpatient.FeeItemList f in alFee)
                {
                    if (!string.IsNullOrEmpty(f.Order.Combo.ID))
                    {
                        if (feeList.ContainsKey(f.Order.Combo.ID))
                        {
                            feeList[f.Order.Combo.ID].Add(f);
                        }
                        else
                        {
                            List <FeeItemList> list = new List <FeeItemList>();
                            list.Add(f);
                            feeList.Add(f.Order.Combo.ID, list);
                        }
                    }
                }
                Neusoft.HISFC.Models.Base.PactItemRate pRate = null;
                foreach (string comboNO in feeList.Keys)
                {
                    List <FeeItemList> list = feeList[comboNO];
                    bool isNofeeSubjob      = true;
                    foreach (FeeItemList f in list)
                    {
                        if (f.Item.ItemType == Neusoft.HISFC.Models.Base.EnumItemType.Drug)
                        {
                            Neusoft.HISFC.Models.Pharmacy.Item item = phaIntegrate.GetItem(f.Item.ID);
                            if (item == null)
                            {
                                errText = "查询药品信息失败!" + phaIntegrate.Err;
                                return(-1);
                            }
                            pRate = pactItemRate.GetOnepPactUnitItemRateByItem(r.Pact.ID, f.Item.ID);
                            //合作医疗药品收取注射费  非合作医疗 不收费注射费
                            if (item.SpecialFlag == "1" && pRate != null && pRate.Rate.PubRate == 1)
                            {
                                isNofeeSubjob = false;
                                break;
                            }
                        }
                    }
                    if (isNofeeSubjob)
                    {
                        foreach (Neusoft.FrameWork.Models.NeuObject obj in NoFeeList)
                        {
                            foreach (FeeItemList f in list)
                            {
                                if (obj.ID == f.Item.ID)
                                {
                                    alFee.Remove(f);
                                }
                            }
                        }
                    }
                }
            }
            return(1);
        }
Ejemplo n.º 48
0
 public void Remove(T obj)
 {
     a.Remove(obj);
 }
Ejemplo n.º 49
0
 public void unregisterStateObserver(FormElementStateListener qsl)
 {
     observers.Remove(qsl);
 }
Ejemplo n.º 50
0
        static void Main(string[] args)
        {
            /* ArrayList类删除元素的四种方法:
             *      1、ArrayList(变量名).Remove(值);
             *      2、ArrayList(变量名).RemoveAt(索引值)
             *      3、ArrayList(变量名).RemoveRange(开始索引值,需要删除的元素个数)
             *      4、ArrayList(变量名).Clear()  //q清除所有元素
             */

            //ArrayList.Remove()
            System.Collections.ArrayList MyArrayList = new System.Collections.ArrayList();
            string[] MyStringArray = { "张三", "李四", "王五", "赵六" };
            MyArrayList.AddRange(MyStringArray);
            MyArrayList.Add(3.14);
            MyArrayList.Add(2298);
            MyArrayList.Add('A');

            //第一遍未进行删除 - 遍历数组
            foreach (object MyEach in MyArrayList)
            {
                Console.WriteLine(MyEach);
            }

            Console.WriteLine("============分割条===========");

            //删除元素
            MyArrayList.Remove("张三");

            //第二遍进行删除元素后 - 遍历数组
            foreach (object MyEach in MyArrayList)
            {
                Console.WriteLine(MyEach);
            }

            Console.WriteLine("============分割条===========");
            //ArrayList(变量名).RemoveAt(索引值)
            //删除元素
            MyArrayList.RemoveAt(0);

            //第三遍进行删除元素后 - 遍历数组
            foreach (object MyEach in MyArrayList)
            {
                Console.WriteLine(MyEach);
            }

            Console.WriteLine("============分割条===========");
            //ArrayList(变量名).RemoveRange(开始索引值,需要删除的元素个数)
            //删除元素
            MyArrayList.RemoveRange(0, 2);

            //第四遍进行删除元素后 - 遍历数组
            foreach (object MyEach in MyArrayList)
            {
                Console.WriteLine(MyEach);
            }

            Console.WriteLine("============分割条===========");
            //ArrayList(变量名).RemoveRange(开始索引值,需要删除的元素个数)
            //删除所有元素
            MyArrayList.Clear();

            //第五遍进行删除元素后 - 遍历数组
            foreach (object MyEach in MyArrayList)
            {
                Console.WriteLine(MyEach);
            }


            Console.ReadKey();
        }
Ejemplo n.º 51
0
 public static bool ImageList_Destroy(HandleRef himl)
 {
     System.Diagnostics.Debug.Assert(validImageListHandles.Contains(himl.Handle), "Invalid ImageList handle");
     validImageListHandles.Remove(himl.Handle);
     return(IntImageList_Destroy(himl));
 }
Ejemplo n.º 52
0
        public ActionResult update_roles_for_user(string UserName, string[] new_roles)
        {
            try
            {
                //PREPARE ALL THE ROLES IN THE SYSTEM
                ArrayList roles_to_delete = new ArrayList(Roles.GetAllRoles());

                //FIRST DELETE ALL ROLES FROM USER EXCEPT ADMINISTRATOR IF USER IS LOGGED IN
                if (User.Identity.Name == UserName)
                {
                    roles_to_delete.Remove(UpdateUtils.ROLE_ADMINISTRATOR);
                }

                //GET THE ROLES FOR THE CURRENT USER

                string[] roles_to_remove = Roles.GetRolesForUser(UserName);

                //REMOVE THE ROLES FOR THE CURRENT USER
                if (roles_to_remove.Count() > 0)
                {
                    Roles.RemoveUserFromRoles(UserName, roles_to_remove);
                }

                //THEN REMOVE ALL ROLES FROM SELECTED USER.
                //This is done freaky becasue the Role manage throws exceptions where user is not in a role and are trying to remove it
                //DetachRoles(UserName, roles_to_delete);

                //PREPARE NEW ROLES ENTERED
                ArrayList roles_to_add      = RoleLogic(new ArrayList(new_roles));
                ArrayList roles_to_add_str2 = new ArrayList();
                foreach (var role in roles_to_add)
                {
                    if (!role.ToString().Equals("false"))
                    {
                        roles_to_add_str2.Add(role);
                    }
                }

                string[] roles_to_add_str = roles_to_add_str2.ToArray(typeof(string)) as string[];

                //ADDING THE ROLES TO THE USER
                Roles.AddUserToRoles(UserName, roles_to_add_str);

                //THEN ADD ROLES TO USER SPECIFIED. AGAIN FREAKY LIKE ABOVE.
                //AttachRoles(UserName,roles_to_add_str);

                //return Content(PrintValues((string[]) roles_to_add_stripped.ToArray(typeof (string))));

                //PREPARE DATA FOR SENDING BACK
                MembershipUser mu = Membership.GetUser(UserName);
                ViewData["user"]      = mu;
                ViewData["roles"]     = Roles.GetRolesForUser(UserName);
                ViewData["all_roles"] = Roles.GetAllRoles();
                TempData["flash"]     = "Roles updated for " + UserName;

                return(RedirectToAction("show", new { controller = "Account", id = mu.ProviderUserKey }));
            }
            catch (Exception exception)
            {
                //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
                TempData["flash"] = "Unable to update roles: " + exception.Message;
            }

            //OUTPUT BASIC FORM WITH NO CHANGES - MUST RELOAD INFORMATION
            MembershipUser mou = Membership.GetUser(UserName);

            ViewData["user"]      = mou;
            ViewData["roles"]     = Roles.GetRolesForUser(UserName);
            ViewData["all_roles"] = Roles.GetAllRoles();

            return(RedirectToAction("show", new { controller = "Account", id = mou.ProviderUserKey }));
        }
Ejemplo n.º 53
0
 internal void RemoveAdapter(WiFiAdapter wifi)
 {
     wifiAdapters.Remove(wifi);
 }
Ejemplo n.º 54
0
        /// <summary>
        /// 接收数据方法
        /// </summary>
        /// <param name="asyn"></param>
        public void OnDataReceived(IAsyncResult asyn)
        {
            SocketPacketRB socketData = null;

            try
            {
                socketData = (SocketPacketRB)asyn.AsyncState;
                //获取异步读取得到的数据包
                int    iRx            = socketData.CurrentSocket.EndReceive(asyn);
                char[] chars          = new char[iRx + 1];
                System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
                int charLen           = d.GetChars(socketData.DataBuffer, 0, iRx, chars, 0);

                System.String szData = new System.String(chars);

                if (DataReceivedByAddress != null)
                {
                    DataReceivedByAddress(szData, ((IPEndPoint)socketData.CurrentSocket.RemoteEndPoint).Address.ToString());

                    ////Czlt-2012-2-24
                    //if (ErrorMessage != null)
                    //{
                    //    ErrorMessage(8033001, "", "[Base_SocketClient:StartClient]", "已连接");
                    //}
                }
            }
            catch (SocketException se)
            {
                if (se.ErrorCode == 10054 && socketData.ErrorShow == false)
                {
                    socketData.ErrorShow = true;

                    //移除
                    if (socketData.CurrentSocket != null)
                    {
                        socketData.CurrentSocket.Close();
                        socketData.CurrentSocket = null;
                    }
                    m_workerSocketList.Remove(socketData);
                    //m_workerSocketList[socketData.m_clientNumber - 1] = null;

                    if (socketData != null && socketData.CurrentSocket != null)
                    {
                        if (ClientConnect != null)
                        {
                            ClientConnect(((IPEndPoint)socketData.CurrentSocket.RemoteEndPoint).Address.ToString(), false);
                        }
                    }

                    try
                    {
                        if (ErrorMessage != null)
                        {
                            ErrorMessage(8033002, se.StackTrace, "[Base_SocketClient:StartClient]", se.Message);
                        }
                    }
                    catch { }
                }
            }
            finally
            {
                if (socketData != null && socketData.CurrentSocket != null)
                {
                    //继续等待数据
                    WaitForData(socketData);
                }
            }
        }
Ejemplo n.º 55
0
 /// <summary>
 /// Remove the instance of the given Map
 /// </summary>
 /// <param name="Map"></param>
 public void Remove(IMap Map)
 {
     pArray.Remove(Map);
 }
 internal void RemoveHighResTimer(HighResTimer timer)
 {
     HighResTimers.Remove(timer);
 }
Ejemplo n.º 57
0
        protected void GenerateMPFDetail(EEmpPersonalInfo empInfo, double payrollAmount, string[] bankFileDetailPaymentRecord, System.Collections.ArrayList contributionList, out string FirstContributionString)
        {
            DateTime PayPeriodStartDate = m_PayPeriodFr, PayPeriodEndDate = m_PayPeriodTo;
            DateTime MPFCommenceDate = new DateTime();
            DateTime TerminationDate = new DateTime();
            DateTime DateOfBirth = empInfo.EmpDateOfBirth;
            DateTime DateAge18 = empInfo.EmpDateOfBirth.AddYears(18);
            DateTime DateAge65 = empInfo.EmpDateOfBirth.AddYears(65);
            DateTime DateJoinCompany = empInfo.EmpDateOfJoin > empInfo.EmpServiceDate ? empInfo.EmpServiceDate : empInfo.EmpDateOfJoin;
            DateTime MPFContributionStartDate = new DateTime(), MPFContributionEndDate = new DateTime();
            double   totalRelevantIncome = 0;
            double   totalBasicSalary = 0;
            double   totalMCER = 0, totalMCEE = 0, totalVCER = 0, totalVCEE = 0;

            FirstContributionString = string.Empty;

            MPFFile.GenericMPFFileDetail lastmMPFDetail = null;

            string defaultPFundType = string.Empty;

            System.Collections.Generic.List <string[]> firstRemittanceStatementList = new System.Collections.Generic.List <string[]>();
            foreach (MPFFile.GenericMPFFileDetail mpfDetail in contributionList)
            {
                if (mpfDetail.EmpID.Equals(empInfo.EmpID))
                {
                    int newJoinRecordCount = 0;
                    bankFileDetailPaymentRecord[2] = mpfDetail.HKIDPassport.PadRight(15).Substring(0, 15);

                    string pFundType = HROne.CommonLib.Utility.GetXMLElementFromXmlString(mpfDetail.EmpMPFPlanExtendXMLString, "EmpMPFPlanExtendData", EmpMPFPlanSCBPFundTypeNodeName);
                    if (!string.IsNullOrEmpty(pFundType.Trim()))
                    {
                        defaultPFundType = pFundType;
                    }

                    lastmMPFDetail = mpfDetail;

                    PayPeriodStartDate = PayPeriodFr;
                    PayPeriodEndDate   = PayPeriodTo;

                    if (PayPeriodStartDate < DateJoinCompany)
                    {
                        PayPeriodStartDate = DateJoinCompany;
                    }

                    MPFCommenceDate = mpfDetail.SchemeJoinDate;
                    if (MPFCommenceDate < DateAge18)
                    {
                        MPFCommenceDate = DateAge18;
                    }

                    if (mpfDetail is MPFFile.GenericExistingEmployeeMPFFileDetail)
                    {
                        TerminationDate = ((MPFFile.GenericExistingEmployeeMPFFileDetail)mpfDetail).LastEmploymentDate;
                    }
                    else if (mpfDetail is MPFFile.GenericNewJoinEmployeeMPFFileDetail)
                    {
                        NewJoinEECount++;
                        foreach (MPFFile.GenericAdditionalEmployeeMPFFileDetail additionalDetail in additionalEEInformation)
                        {
                            if (additionalDetail.EmpID.Equals(empInfo.EmpID))
                            {
                                TerminationDate = additionalDetail.LastEmploymentDate;
                            }
                        }
                    }
                    foreach (MPFFile.GenericMPFFileContributionDetail contributionDetail in mpfDetail.MPFContributionDetailList)
                    {
                        double relevantIncome = 0;
                        double mcER           = 0;
                        double mcEE           = 0;
                        double basicSalary    = 0;
                        double vcER           = 0;
                        double vcEE           = 0;
                        if (MPFContributionStartDate.Ticks.Equals(0) || MPFContributionStartDate > contributionDetail.PeriodFrom)
                        {
                            MPFContributionStartDate = contributionDetail.PeriodFrom;
                        }

                        if (MPFContributionEndDate.Ticks.Equals(0) || MPFContributionEndDate < contributionDetail.PeriodTo)
                        {
                            MPFContributionEndDate = contributionDetail.PeriodTo;
                        }


                        if (contributionDetail.MCEE != 0 || contributionDetail.MCER != 0)
                        {
                            totalRelevantIncome += contributionDetail.RelevantIncome;
                            totalMCER           += contributionDetail.MCER;
                            totalMCEE           += contributionDetail.MCEE;
                            relevantIncome       = contributionDetail.RelevantIncome;
                            mcER = contributionDetail.MCER;
                            mcEE = contributionDetail.MCEE;
                        }
                        if (contributionDetail.VCEE != 0 || contributionDetail.VCER != 0)
                        {
                            totalBasicSalary += contributionDetail.VCRelevantIncome;
                            totalVCER        += contributionDetail.VCER;
                            totalVCEE        += contributionDetail.VCEE;
                            basicSalary       = contributionDetail.VCRelevantIncome;
                            vcER              = contributionDetail.VCER;
                            vcEE              = contributionDetail.VCEE;
                        }

                        if (mpfDetail is MPFFile.GenericNewJoinEmployeeMPFFileDetail)
                        {
                            newJoinRecordCount++;
                            totalFirstContributionAmount += contributionDetail.MCEE
                                                            + contributionDetail.MCER
                                                            + contributionDetail.VCEE
                                                            + contributionDetail.VCER;
                            DateTime activeMPFContributionStartDate = contributionDetail.PeriodFrom;
                            DateTime activeMPFContributionEndDate   = contributionDetail.PeriodTo;

                            if (activeMPFContributionStartDate < MPFCommenceDate && MPFCommenceDate <= activeMPFContributionEndDate)
                            {
                                activeMPFContributionStartDate = MPFCommenceDate;
                            }
                            if (!TerminationDate.Ticks.Equals(0) && activeMPFContributionStartDate <= TerminationDate && TerminationDate < activeMPFContributionEndDate)
                            {
                                activeMPFContributionEndDate = TerminationDate;
                            }
                            if (activeMPFContributionStartDate < DateAge65 && DateAge65 <= activeMPFContributionEndDate)
                            {
                                activeMPFContributionEndDate = DateAge65.AddDays(-1);
                            }

                            string[] firstRemittanceStatement = new string[18];
                            firstRemittanceStatement[0]  = bankFileDetailPaymentRecord[0];
                            firstRemittanceStatement[1]  = NewJoinEECount.ToString("00000");
                            firstRemittanceStatement[2]  = newJoinRecordCount.ToString("00");
                            firstRemittanceStatement[3]  = bankFileDetailPaymentRecord[1];
                            firstRemittanceStatement[4]  = bankFileDetailPaymentRecord[2];
                            firstRemittanceStatement[5]  = DateJoinCompany.ToString("yyyyMMdd");
                            firstRemittanceStatement[6]  = bankFileDetailPaymentRecord[4];
                            firstRemittanceStatement[7]  = activeMPFContributionStartDate.ToString("yyyyMMdd");
                            firstRemittanceStatement[8]  = activeMPFContributionEndDate.ToString("yyyyMMdd");
                            firstRemittanceStatement[9]  = activeMPFContributionStartDate.ToString("yyyyMMdd");
                            firstRemittanceStatement[10] = activeMPFContributionEndDate.ToString("yyyyMMdd");
                            firstRemittanceStatement[11] = relevantIncome.ToString("000000000.00");
                            firstRemittanceStatement[12] = mcER.ToString("000000000.00");
                            firstRemittanceStatement[13] = mcEE.ToString("000000000.00");
                            firstRemittanceStatement[14] = vcER.ToString("000000000.00");
                            firstRemittanceStatement[15] = vcEE.ToString("000000000.00");
                            firstRemittanceStatement[16] = bankFileDetailPaymentRecord[3];
                            firstRemittanceStatement[17] = basicSalary.ToString("000000000.00");
                            firstRemittanceStatementList.Add(firstRemittanceStatement);
                        }
                    }
                    if (!(mpfDetail is MPFFile.GenericBackPaymentEmployeeMPFFileDetail))
                    {
                        if (MPFContributionStartDate < MPFCommenceDate && MPFCommenceDate <= MPFContributionEndDate)
                        {
                            MPFContributionStartDate = MPFCommenceDate;
                        }
                        if (!TerminationDate.Ticks.Equals(0) && MPFContributionStartDate <= TerminationDate && TerminationDate < MPFContributionEndDate)
                        {
                            MPFContributionEndDate = TerminationDate;
                        }
                        if (MPFContributionStartDate < DateAge65 && DateAge65 <= MPFContributionEndDate)
                        {
                            MPFContributionEndDate = DateAge65.AddDays(-1);
                        }
                    }
                    totalFirstContributionRecordCount += newJoinRecordCount;

                    //  Assume that only 1 mpf detail per employee is included in file
                    break;
                }
            }

            if (lastmMPFDetail != null)
            {
                contributionList.Remove(lastmMPFDetail);
            }

            if (!string.IsNullOrEmpty(defaultPFundType))
            {
                bankFileDetailPaymentRecord[3] = defaultPFundType;
            }
            else if (lastmMPFDetail == null && mpfPlanIDSchemeCodeMapping.Count > 0)
            {
                bankFileDetailPaymentRecord[3] = "8";    //  set PFund Type to "Exempt" if there exists MPF Contribution Records in the batch but did not match with EmpID
            }
            bankFileDetailPaymentRecord[5] = PayPeriodStartDate.ToString("yyyyMMdd");
            bankFileDetailPaymentRecord[6] = PayPeriodEndDate.ToString("yyyyMMdd");

            if (!MPFCommenceDate.Ticks.Equals(0))
            {
                bankFileDetailPaymentRecord[7] = MPFCommenceDate.ToString("yyyyMMdd");
            }
            else
            {
                bankFileDetailPaymentRecord[7] = string.Empty.PadRight(8);
            }

            if (!TerminationDate.Ticks.Equals(0))
            {
                bankFileDetailPaymentRecord[8] = TerminationDate.ToString("yyyyMMdd");
            }
            else
            {
                bankFileDetailPaymentRecord[8] = string.Empty.PadRight(8);
            }

            if (!DateOfBirth.Ticks.Equals(0))
            {
                bankFileDetailPaymentRecord[9] = DateOfBirth.ToString("yyyyMMdd");
            }
            else
            {
                bankFileDetailPaymentRecord[9] = string.Empty.PadRight(8);
            }

            if (!DateJoinCompany.Ticks.Equals(0))
            {
                bankFileDetailPaymentRecord[10] = DateJoinCompany.ToString("yyyyMMdd");
            }
            else
            {
                bankFileDetailPaymentRecord[10] = string.Empty.PadRight(8);
            }

            if (!MPFContributionStartDate.Ticks.Equals(0))
            {
                bankFileDetailPaymentRecord[11] = MPFContributionStartDate.ToString("yyyyMMdd");
            }
            else
            {
                bankFileDetailPaymentRecord[11] = string.Empty.PadRight(8);
            }

            if (!MPFContributionEndDate.Ticks.Equals(0))
            {
                bankFileDetailPaymentRecord[12] = MPFContributionEndDate.ToString("yyyyMMdd");
            }
            else
            {
                bankFileDetailPaymentRecord[12] = string.Empty.PadRight(8);
            }
            bankFileDetailPaymentRecord[13] = totalRelevantIncome.ToString("000000000.00");
            bankFileDetailPaymentRecord[14] = totalBasicSalary.ToString("000000000.00");
            bankFileDetailPaymentRecord[15] = ((double)(payrollAmount + totalMCEE + totalVCEE)).ToString("000000000.00");
            bankFileDetailPaymentRecord[16] = payrollAmount.ToString("000000000.00");
            bankFileDetailPaymentRecord[17] = ((double)(totalMCEE + totalMCER + totalVCEE + totalVCER)).ToString("000000000.00");
            bankFileDetailPaymentRecord[18] = totalMCER.ToString("000000000.00");
            bankFileDetailPaymentRecord[19] = totalMCEE.ToString("000000000.00");
            bankFileDetailPaymentRecord[20] = totalVCER.ToString("000000000.00");
            bankFileDetailPaymentRecord[21] = totalVCEE.ToString("000000000.00");

            foreach (string[] firstRemittanceStatement in firstRemittanceStatementList)
            {
                firstRemittanceStatement[16] = bankFileDetailPaymentRecord[3];
                string firstRemittanceStatementString = string.Join(FIELD_DELIMITER, firstRemittanceStatement);
                if (firstRemittanceStatementString.Length != 183)
                {
                    throw new Exception("Incorrect Bank File Detail Length:\r\n" + firstRemittanceStatementString);
                }
                FirstContributionString += firstRemittanceStatementString + RECORD_DELIMITER;
            }
        }