Remove() публичный Метод

public Remove ( string value ) : void
value string
Результат void
 static void Main(string[] args)
 {
     System.Collections.Specialized.StringCollection stringCollection = new System.Collections.Specialized.StringCollection();
     String[] Cities = new String[] { "Hyderabad", "Delhi", "Mumbai", "Banglore", "Chennai", "Kolkatta" };
     stringCollection.AddRange(Cities);
     // Display the contents of the collection using foreach.
     Console.WriteLine("Displays the elements using foreach:");
     foreach (String obj in stringCollection)
     {
         Console.WriteLine("   {0}", obj);
     }
     Console.WriteLine();
     stringCollection.Add("Pune");
     stringCollection.Add("Vizag");
     stringCollection.Remove("Chennai");
     Console.WriteLine("After Updating Collection:");
     foreach (String obj in stringCollection)
     {
         Console.WriteLine("   {0}", obj);
     }
     Console.WriteLine();
     // Copy the collection to a new array starting at index 0.
     String[] CitiesArray = new String[stringCollection.Count];
     stringCollection.CopyTo(CitiesArray, 0);
     Console.WriteLine("The new array contains:");
     for (int i = 0; i < CitiesArray.Length; i++)
     {
         Console.WriteLine("   [{0}] {1}", i, CitiesArray[i]);
     }
     Console.WriteLine();
     Console.ReadLine();
 }
Пример #2
0
 private void UnregisterToCleanup(string artifactName, StringCollection cleanupList)
 {
     lock (_syncObject)
     {
         cleanupList.Remove(artifactName);
     }
 }
Пример #3
0
        /// <summary>
        /// Adds a string to the list and positions it in the recent list
        /// </summary>
        /// <param name="text">The string that should be added</param>
        public void AddString(string text)
        {
            if (m_List.Contains(text))
            {
                m_List.Remove(text);
                m_List.Insert(0, text);
            }
            else
            {
                if (m_List.Count == m_Capacity)
                {
                    m_List.RemoveAt(m_List.Count - 1);
                }

                m_List.Insert(0, text);
            }
        }
Пример #4
0
        public Settings()
        {
            InitializeComponent();
            Closing += PreventTermination;
            planetList = Properties.Settings.Default.planets;
            System.Collections.IEnumerator se = Constraints.PLANETS.GetEnumerator();
            while (se.MoveNext())
            {
                string pl = (string)se.Current;
                CheckBox tmp = new CheckBox();
                tmp.Checked += delegate(object s, RoutedEventArgs e)
                {
                    if(planetList.IndexOf(pl) == -1) planetList.Add(pl);
                };
                tmp.Unchecked += delegate(object s, RoutedEventArgs e)
                {
                    if(planetList.IndexOf(pl) > -1) planetList.Remove(pl);
                };
                tmp.IsChecked = planetList.IndexOf(pl) > -1;
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Children.Add(tmp);
                Label lbl = new Label();
                lbl.Content = pl;
                sp.Children.Add(lbl);
                planets.Children.Add(sp);
            }

            closetaskbar.IsChecked = Properties.Settings.Default.closeToTaskbar;
            mintaskbar.IsChecked = Properties.Settings.Default.minimizeToTaskbar;
            notify.IsChecked = Properties.Settings.Default.notify;
            hasrewards.IsChecked = Properties.Settings.Default.hasRewards;
            reward.Text = Properties.Settings.Default.rewardContains.ToLower();
            credits.Text = Properties.Settings.Default.credits.ToString();
            usefilter.IsChecked = Properties.Settings.Default.useFilter;
        }
 private void OnInferParametersButtonClick(object sender, EventArgs e)
 {
     if (this._commandTextBox.Text.Trim().Length == 0)
     {
         UIServiceHelper.ShowError(base.ServiceProvider, System.Design.SR.GetString("SqlDataSourceQueryEditorForm_InferNeedsCommand"));
     }
     else
     {
         Parameter[] parameterArray = this._sqlDataSourceDesigner.InferParameterNames(this._dataConnection, this._commandTextBox.Text, this._commandType);
         if (parameterArray != null)
         {
             Parameter[] parameters = this._parameterEditorUserControl.GetParameters();
             StringCollection strings = new StringCollection();
             foreach (Parameter parameter in parameters)
             {
                 strings.Add(parameter.Name);
             }
             bool flag = true;
             try
             {
                 flag = SqlDataSourceDesigner.SupportsNamedParameters(SqlDataSourceDesigner.GetDbProviderFactory(this._dataConnection.ProviderName));
             }
             catch
             {
             }
             if (flag)
             {
                 List<Parameter> list = new List<Parameter>();
                 foreach (Parameter parameter2 in parameterArray)
                 {
                     if (!strings.Contains(parameter2.Name))
                     {
                         list.Add(parameter2);
                     }
                     else
                     {
                         strings.Remove(parameter2.Name);
                     }
                 }
                 this._parameterEditorUserControl.AddParameters(list.ToArray());
             }
             else
             {
                 List<Parameter> list2 = new List<Parameter>();
                 foreach (Parameter parameter3 in parameterArray)
                 {
                     list2.Add(parameter3);
                 }
                 foreach (Parameter parameter4 in parameters)
                 {
                     Parameter item = null;
                     foreach (Parameter parameter6 in list2)
                     {
                         if (parameter6.Direction == parameter4.Direction)
                         {
                             item = parameter6;
                             break;
                         }
                     }
                     if (item != null)
                     {
                         list2.Remove(item);
                     }
                 }
                 this._parameterEditorUserControl.AddParameters(list2.ToArray());
             }
         }
     }
 }
Пример #6
0
        public void AddRecentlyUsedFile(FileInfo newFile) {
            StringCollection recent = new StringCollection();
            recent.AddRange(data.RecentOpenedFiles);

            while(recent.IndexOf(newFile.FullName) >= 0) {
                recent.Remove(newFile.FullName);
            }

            recent.Insert(0, newFile.FullName);

            while (recent.Count > 16) {
                recent.RemoveAt(16);
            }

            string[] result = new string[recent.Count];
            recent.CopyTo(result, 0);
            data.RecentOpenedFiles = result;
        }
Пример #7
0
		/// <summary>
		/// This method is called by the ReversalEntriesText virtual handler when text may have changed in the
		/// property, in order to update the actual list of reversal entries appropriately.
		/// </summary>
		/// <param name="tssVal">The new string.</param>
		/// <param name="ws">The ws.</param>
		public void CommitReversalEntriesText(ITsString tssVal, int ws)
		{
			LexSenseReversalEntriesTextHandler vh = BaseVirtualHandler.GetInstalledHandler(m_cache,
				"LexSense", LexSenseReversalEntriesTextHandler.StandardFieldName) as LexSenseReversalEntriesTextHandler;
			Debug.Assert(vh != null, "The 'LexSenseReversalEntriesTextHandler' virtual handler has to be created at application startup now.");

			ITsString tssOld = vh.GetValue(m_hvo, ws);
			// The old and new values could be in another order, and this test won't catch that case.
			// That condition won't be fatal, however, so don't fret about it.
			if (tssOld.Equals(tssVal))
				return; // no change has occurred

			string val = tssVal.Text;
			if (val == null)
				val = ""; // This will effectively cause any extant entries for the given 'ws' to be removed in the end.

			StringCollection formsColl = new StringCollection();
			foreach (string form in val.Split(';'))
			{
				// These strings will be null, if there are two semi-colons together.
				// Or, it may be just whitespace, if it is '; ;'.
				if (form == null || form.Trim().Length == 0)
					continue;
				formsColl.Add(form.Trim());
			}
			int[] senseEntries = ReversalEntriesRC.HvoArray;
			int originalSenseEntriesCount = senseEntries.Length;
			int indexId;
			DbOps.ReadOneIntFromCommand(m_cache, "SELECT id FROM ReversalIndex WHERE WritingSystem=?", ws, out indexId);
			ReversalIndex revIndex;
			if (indexId == 0)
			{
				// Create the missing reversal index instead of crashing.  See LT-10186.
				ILgWritingSystem lgws = LgWritingSystem.CreateFromDBObject(m_cache, ws);
				IReversalIndex newIdx = m_cache.LangProject.LexDbOA.ReversalIndexesOC.Add(new ReversalIndex());
				newIdx.WritingSystemRA = lgws;
				// Copy any and all alternatives from lgws.Name to newIdx.Name
				foreach (ILgWritingSystem lgwsLoop in m_cache.LanguageEncodings)
				{
					string lgsNameAlt = lgws.Name.GetAlternative(lgwsLoop.Hvo);
					if (lgsNameAlt != null && lgsNameAlt.Length > 0)
						newIdx.Name.SetAlternative(lgsNameAlt, lgws.Hvo);
				}
				revIndex = (ReversalIndex)newIdx;
			}
			else
			{
				revIndex = (ReversalIndex)CmObject.CreateFromDBObject(m_cache, indexId, false);
			}

			// We need the list of ReversalIndexEntries that this sense references, but which belong
			// to another reversal index. Those hvos, plus any entry hvos from the given 'ws' that are reused,
			// get put into 'survivingEntries'.
			Set<int> survivingEntries = new Set<int>(originalSenseEntriesCount + formsColl.Count);
			// 'entriesNeedingPropChangeBackRef' will hold the hvos of all ReversalIndexEntry objects that need to have
			// their 'ReferringSenses' virtual property (re)computed.
			// Any reversal index entry that gains or loses a reference will need this (re)computing.
			List<int> entriesNeedingPropChangeBackRef = new List<int>(originalSenseEntriesCount + formsColl.Count);
			foreach (int entryHvo in senseEntries)
			{
				// Use 'cheapo' FDO object maker, since it is supposed to all be in the cache already.
				ReversalIndexEntry rie = (ReversalIndexEntry)CmObject.CreateFromDBObject(m_cache, entryHvo, false);
				int wsIndex = 0;
				int hvoIndex = m_cache.GetOwnerOfObjectOfClass(rie.Hvo, ReversalIndex.kclsidReversalIndex);
				if (hvoIndex != 0)
					wsIndex = m_cache.GetIntProperty(hvoIndex, (int)ReversalIndex.ReversalIndexTags.kflidWritingSystem);
				if (wsIndex == ws)
				{
					string form = rie.LongName;
					if (formsColl.Contains(form))
					{
						// Recycling an entry.
						survivingEntries.Add(rie.Hvo);
						formsColl.Remove(form); // Don't need to mess with it later on.
					}
					else
					{
						// It is being removed from the extant reference property,
						// so needs to recompute its back ref virtual handler.
						entriesNeedingPropChangeBackRef.Add(rie.Hvo);
					}
				}
				else
				{
					// These are all in some other ws, so they certainly must survive (cf. LT-3391).
					// Any entries that are reused will get added to this array later on.
					survivingEntries.Add(rie.Hvo);
				}
			}

			// Start Undoable section of code.
			m_cache.BeginUndoTask(Strings.ksUndoMakeRevEntries, Strings.ksRedoMakeRevEntries);
			ISilDataAccess sda = m_cache.MainCacheAccessor;
			IActionHandler acth = sda.GetActionHandler();
			try
			{
				// add undo actions to reload the virtual handler and send prop changes to update displays
				if (acth != null)
				{
					List<PropChangedInfo> pciList = new List<PropChangedInfo>();
					pciList.Add(new PropChangedInfo(m_hvo, vh.Tag, ws, 0, 0));
					acth.AddAction(new PropChangedUndoAction(m_cache, true, PropChangeType.kpctNotifyAll, pciList));
					acth.AddAction(new ReloadVirtualHandlerUndoAction(m_cache, true, vh, m_hvo, vh.Tag, ws));
				}

				int cOldEntries = revIndex.EntriesOC.Count;
				foreach (string currentForm in formsColl)
				{
					int idRevEntry = revIndex.FindOrCreateReversalEntry(currentForm);
					entriesNeedingPropChangeBackRef.Add(idRevEntry);
					survivingEntries.Add(idRevEntry);
				}

				// Notify everyone, and his brother, about the changes done here.
				// PropChanged (1 of 3) Main: Replace main sense property with current set of entries.
				sda.Replace(m_hvo, (int)LexSense.LexSenseTags.kflidReversalEntries, 0, originalSenseEntriesCount,
					survivingEntries.ToArray(), survivingEntries.Count);
				sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, m_hvo,
					(int)LexSense.LexSenseTags.kflidReversalEntries, 0, survivingEntries.Count, originalSenseEntriesCount);

				// remove entries from the index that are no longer valid
				foreach (int rieHvo in senseEntries)
				{
					if (!survivingEntries.Contains(rieHvo))
					{
						// the entry is no longer a reversal entry for this sense
						ReversalIndexEntry rie = new ReversalIndexEntry(m_cache, rieHvo);
						if (rie.SenseIds.Count == 0)
							// the entry is longer a reversal entry for any sense
							revIndex.EntriesOC.Remove(rie);
					}
				}

				// PropChanged (2 of 3) Affected Entries: (Re)compute
				// on the virtual property of select reversal index entries.
				ReversalIndexEntry.ResetReferringSenses(m_cache, entriesNeedingPropChangeBackRef);

				// PropChanged (3 of 3) Index Entries: Simulate a complete replacement of the entries collection,
				// BUT only if new entries were added in this method.
				int cNewEntries = revIndex.EntriesOC.Count;
				if (cNewEntries > cOldEntries)
				{
					sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, indexId,
						(int)ReversalIndex.ReversalIndexTags.kflidEntries,
						0, cNewEntries, cOldEntries);
				}

				// add redo actions to reload the virtual handler and send prop changes to update displays
				if (acth != null)
				{
					acth.AddAction(new ReloadVirtualHandlerUndoAction(m_cache, false, vh, m_hvo, vh.Tag, ws));
					List<PropChangedInfo> pciList = new List<PropChangedInfo>();
					pciList.Add(new PropChangedInfo(m_hvo, vh.Tag, ws, 0, 0));
					acth.AddAction(new PropChangedUndoAction(m_cache, false, PropChangeType.kpctNotifyAll, pciList));
				}
			}
			finally
			{
				if (acth != null && Marshal.IsComObject(acth))
					Marshal.ReleaseComObject(acth);
			}
			// End undoable section of code.
			m_cache.EndUndoTask();
		}
Пример #8
0
        public void Test01()
        {
            IntlStrings intl;
            StringCollection sc;
            // simple string values
            string[] values =
            {
                "",
                " ",
                "a",
                "aa",
                "text",
                "     spaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            int cnt = 0;            // Count
            // initialize IntStrings
            intl = new IntlStrings();


            // [] StringCollection is constructed as expected
            //-----------------------------------------------------------------

            sc = new StringCollection();

            // [] Remove() from empty collection
            //
            for (int i = 0; i < values.Length; i++)
            {
                sc.Remove(values[i]);
                if (sc.Count != 0)
                {
                    Assert.False(true, string.Format("Error, Remove changed Count for empty collection", i));
                }
            }


            // [] Remove() from collection filled with simple strings
            //

            sc.Clear();
            sc.AddRange(values);
            if (sc.Count != values.Length)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, values.Length));
            }

            for (int i = 0; i < values.Length; i++)
            {
                // verify that collection contains all added items
                //
                if (!sc.Contains(values[i]))
                {
                    Assert.False(true, string.Format("Error, doesn't contain {0} item", i));
                }

                cnt = sc.Count;

                // Remove each item
                //
                sc.Remove(values[i]);

                if (sc.Count != cnt - 1)
                {
                    Assert.False(true, string.Format("Error, didn't remove anything", i));
                }

                if (sc.Contains(values[i]))
                {
                    Assert.False(true, string.Format("Error, removed wrong item", i));
                }
            }

            //
            // Intl strings
            // [] Remove() from collection filled with Intl strings
            //

            string[] intlValues = new string[values.Length];

            // fill array with unique strings
            //
            for (int i = 0; i < values.Length; i++)
            {
                string val = intl.GetRandomString(MAX_LEN);
                while (Array.IndexOf(intlValues, val) != -1)
                    val = intl.GetRandomString(MAX_LEN);
                intlValues[i] = val;
            }

            int len = values.Length;
            Boolean caseInsensitive = false;
            for (int i = 0; i < len; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
                    caseInsensitive = true;
            }


            sc.Clear();
            sc.AddRange(intlValues);
            if (sc.Count != intlValues.Length)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, intlValues.Length));
            }

            for (int i = 0; i < intlValues.Length; i++)
            {
                // verify that collection contains all added items
                //
                if (!sc.Contains(intlValues[i]))
                {
                    Assert.False(true, string.Format("Error, doesn't contain {0} item", i));
                }

                cnt = sc.Count;

                // Remove each item
                //
                sc.Remove(intlValues[i]);

                if (sc.Count != cnt - 1)
                {
                    Assert.False(true, string.Format("Error, didn't remove anything", i));
                }

                if (sc.Contains(intlValues[i]))
                {
                    Assert.False(true, string.Format("Error, removed wrong item", i));
                }
            }


            //
            // duplicate strings
            // [] Remove() from filled collection with duplicate strings
            //
            sc.Clear();
            string intlStr = intlValues[0];

            sc.Add(intlStr);        // index 0
            sc.AddRange(values);
            sc.AddRange(intlValues);        // second index values.Length + 1
            cnt = values.Length + 1 + intlValues.Length;
            if (sc.Count != cnt)
            {
                Assert.False(true, string.Format("Error, count is {1} instead of {2}", sc.Count, cnt));
            }

            // verify Index of newly added item
            //
            if (sc.IndexOf(intlStr) != 0)
            {
                Assert.False(true, string.Format("Error, IndexOf returned {0} instead of {1}", sc.IndexOf(intlStr), 0));
            }

            // remove
            //
            sc.Remove(intlStr);
            if (!sc.Contains(intlStr))
            {
                Assert.False(true, string.Format("Error, removed both duplicates"));
            }
            // second string should still be present
            if (sc.IndexOf(intlStr) != values.Length)
            {
                Assert.False(true, string.Format("Error, IndexOf returned {0} instead of {1}", sc.IndexOf(intlStr), values.Length));
            }

            // verify that items were moved
            //
            for (int i = 0; i < values.Length; i++)
            {
                if (sc.IndexOf(values[i]) != i)
                {
                    Assert.False(true, string.Format("Error, IndexOf {0} item returned {1} ", i, sc.IndexOf(values[i])));
                }

                if (sc.IndexOf(intlValues[i]) != i + values.Length)
                {
                    Assert.False(true, string.Format("Error, IndexOf {1} item returned {2} ", i, i + values.Length, sc.IndexOf(intlValues[i])));
                }
            }


            //
            // [] Case sensitivity: search should be case-sensitive
            //

            sc.Clear();
            sc.Add(intlStr.ToUpper());
            sc.AddRange(values);
            sc.Add(intlStr.ToLower());
            cnt = values.Length + 2;
            if (sc.Count != cnt)
            {
                Assert.False(true, string.Format("Error, count is {1} instead of {2} ", sc.Count, cnt));
            }

            // remove lowercase item
            //
            intlStr = intlStr.ToLower();

            cnt = sc.Count;
            sc.Remove(intlStr);
            if (sc.Count != cnt - 1)
            {
                Assert.False(true, string.Format("Error, didn't remove anything"));
            }

            if (!caseInsensitive && sc.Contains(intlStr))
            {
                Assert.False(true, string.Format("Error, didn't remove lowercase "));
            }

            // but should still contain Uppercase
            if (!sc.Contains(intlValues[0].ToUpper()))
            {
                Assert.False(true, string.Format("Error, removed uppercase "));
            }

            //
            //  remove item that is not in the collection
            //

            sc.Clear();
            sc.AddRange(values);
            cnt = values.Length;
            if (sc.Count != cnt)
            {
                Assert.False(true, string.Format("Error, count is {1} instead of {2} ", sc.Count, cnt));
            }

            // remove non-existing item
            //
            intlStr = "Hello";
            cnt = sc.Count;
            sc.Remove(intlStr);
            if (sc.Count != cnt)
            {
                Assert.False(true, string.Format("Error, removed something"));
            }
        }
Пример #9
0
		/// <summary>
		/// Check for changed (or missing) files in the Extensions subdirectory (as
		/// compared to the corresponding "Available Plugins" subdirectory).
		/// </summary>
		/// <param name="paths"></param>
		/// <param name="pluginBaseDir"></param>
		/// <param name="extensionBaseDir"></param>
		private void UpdateExtensionFilesIfNeeded(StringCollection paths, string pluginBaseDir,
			string extensionBaseDir)
		{
			if (paths.Count == 0)
				return;
			List<string> obsoletePaths = new List<string>();
			foreach (string extensionPath in paths)
			{
				string pluginPathname = Path.Combine(pluginBaseDir, extensionPath);
				pluginPathname = pluginPathname.Replace("Extensions", "Available Plugins");
				if (File.Exists(pluginPathname))
				{
					string extensionPathname = Path.Combine(extensionBaseDir, extensionPath);
					Debug.Assert(File.Exists(extensionPathname));
					if (!FileUtils.AreFilesIdentical(pluginPathname, extensionPathname))
					{
						string extensionDir = Path.GetDirectoryName(extensionPathname);
						Directory.Delete(extensionDir, true);
						Directory.CreateDirectory(extensionDir);
						File.Copy(pluginPathname, extensionPathname);
						File.SetAttributes(extensionPathname, FileAttributes.Normal);
						// plug-ins usually have localization strings-XX.xml files.
						foreach (string pluginFile in Directory.GetFiles(Path.GetDirectoryName(pluginPathname), "strings-*.xml"))
						{
							string extensionFile = Path.Combine(extensionDir, Path.GetFileName(pluginFile));
							File.Copy(pluginFile, extensionFile);
							File.SetAttributes(extensionFile, FileAttributes.Normal);
						}
					}
				}
				else
				{
					obsoletePaths.Add(extensionPath);
				}
			}
			foreach (string badPath in obsoletePaths)
				paths.Remove(badPath);
		}
Пример #10
0
        /// <summary>
        /// Decodes the commands and if necessary (re)starts the Attack.
        /// Works with the Captures from RegEx.
        /// </summary>
        /// <param name="cmds">the CaptureCollection containing a collection of commands</param>
        /// <param name="vals">the CaptureCollection containing a collection of values corresponding to the commands.</param>
        /// <returns>True if the commands were successfully loaded. False in case of any error.</returns>
        private bool parseOLUrlCmd(CaptureCollection cmds, CaptureCollection vals)
        {
            bool ret = false;
            if ((cmds.Count == vals.Count) && (cmds.Count > 0))
            {
                StringCollection defaults = new StringCollection();
                defaults.Add("targetip"); defaults.Add("targethost"); defaults.Add("timeout");
                defaults.Add("subsite"); defaults.Add("message"); defaults.Add("port");
                defaults.Add("method"); defaults.Add("threads"); defaults.Add("wait");
                defaults.Add("random"); defaults.Add("speed"); defaults.Add("sockspthread");
                defaults.Add("useget"); defaults.Add("usegzip");

                int num = 0;
                bool isnum = false;
                bool restart = false;
                bool ctdwndn = false;
                string tval = "";
                string tcmd = "";

                for (int i = 0; i < cmds.Count; i++)
                {
                    tval = vals[i].Value.Trim();
                    tcmd = cmds[i].Value.Trim();
                    defaults.Remove(tcmd);
                    switch (tcmd.ToLowerInvariant())
                    {
                        case "targetip":
                            if (txtTargetIP.Text != tval)
                            {
                                txtTargetIP.Text = tval;
                                LockOnIP(true);
                                restart = true;
                            }
                            ret = true;
                            break;
                        case "targethost":
                            if (txtTargetURL.Text != tval)
                            {
                                txtTargetURL.Text = tval;
                                LockOnURL(true);
                                restart = true;
                            }
                            ret = true;
                            break;
                        case "timeout":
                            isnum = int.TryParse(tval, out num);
                            if (isnum)
                            {
                                if (txtTimeout.Text != num.ToString())
                                {
                                    txtTimeout.Text = num.ToString();
                                    restart = true;
                                }
                            }
                            break;
                        case "subsite":
                            tval = Uri.UnescapeDataString(tval);
                            if (txtSubsite.Text != tval)
                            {
                                txtSubsite.Text = tval;
                                restart = true;
                            }
                            break;
                        case "message":
                            if (txtData.Text != tval)
                            {
                                txtData.Text = tval;
                                restart = true;
                            }
                            break;
                        case "port":
                            if (txtPort.Text != tval)
                            {
                                txtPort.Text = tval;
                                restart = true;
                            }
                            break;
                        case "method":
                            int index = cbMethod.FindString(tval);
                            if (index != -1)
                            {
                                if (cbMethod.SelectedIndex != index)
                                {
                                    cbMethod.SelectedIndex = index;
                                    restart = true;
                                }
                            }
                            break;
                        case "threads":
                            if (Functions.ParseInt(tval, 1, 99, out num))
                            {
                                if (txtThreads.Text != num.ToString())
                                {
                                    txtThreads.Text = num.ToString();
                                    if(cbMethod.SelectedIndex >= 3)
                                        restart = true;
                                }
                            }
                            break;
                        case "wait":
                            if (tval.ToLowerInvariant() == "true")
                            {
                                if (!chkWaitReply.Checked)
                                    restart = true;
                                chkWaitReply.Checked = true;
                            }
                            else if (tval.ToLowerInvariant() == "false")
                            {
                                if (chkWaitReply.Checked)
                                    restart = true;
                                chkWaitReply.Checked = false;
                            }
                            break;
                        case "random":
                            if (tval.ToLowerInvariant() == "true")
                            {
                                if (!chkRandom.Checked || !chkMsgRandom.Checked)
                                    restart = true;
                                chkRandom.Checked = true; //HTTP
                                chkMsgRandom.Checked = true; //TCP_UDP
                            }
                            else if (tval.ToLowerInvariant() == "false")
                            {
                                if (chkRandom.Checked || chkMsgRandom.Checked)
                                    restart = true;
                                chkRandom.Checked = false; //HTTP
                                chkMsgRandom.Checked = false; //TCP_UDP
                            }
                            break;
                        case "speed":
                            if (Functions.ParseInt(tval, tbSpeed.Minimum, tbSpeed.Maximum, out num))
                            {
                                if (tbSpeed.Value != num)
                                {
                                    tbSpeed.Value = num;
                                    restart = true;
                                }
                            }
                            break;
                        case "hivemind":
                            string[] sp = tval.Split(':');
                            if (sp.Length > 1)
                            {
                                txtIRCserver.Text = sp[0];
                                string[] spt = sp[1].Split('#');
                                if (spt.Length > 1)
                                {
                                    txtIRCport.Text = spt[0];
                                    txtIRCchannel.Text = '#' + spt[1];
                                    enableHive.Checked = true;
                                    return true;
                                }
                            }
                            //ret = true;
                            break;
                        case "time": // might be not a bad idea to include a NTP-lookup before this?
                            System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CurrentCulture;
                            DateTime dtGo = DateTime.Parse(tval, ci.DateTimeFormat, System.Globalization.DateTimeStyles.AssumeUniversal);
                            DateTime dtNow = DateTime.UtcNow;
                            long tdiff = dtGo.Ticks - dtNow.Ticks;
                            tdiff /= TimeSpan.TicksPerMillisecond;
                            ret = true;
                            tZergRush.Stop();
                            if (tdiff > 0)
                            {
                                tZergRush.Interval = (int)tdiff;
                                tZergRush.Start();
                                this.Text = String.Format("{0} | U dun goofed | v. {1} | Next Raid: {2}", Application.ProductName, Application.ProductVersion, dtGo.ToString("MM-dd HH:mm"));
                                restart = true;
                            }
                            else
                            {
                                ctdwndn = true;
                                this.Text = String.Format("{0} | U dun goofed | v. {1}", Application.ProductName, Application.ProductVersion);
                            }
                            ret = true;
                            break;
                        case "useget":
                            if (tval.ToLowerInvariant() == "true")
                                chkUseGet.Checked = true;
                            else if (tval.ToLowerInvariant() == "false")
                                chkUseGet.Checked = false;
                            break;
                        case "usegzip":
                            if (tval.ToLowerInvariant() == "true")
                                chkAllowGzip.Checked = true;
                            else if (tval.ToLowerInvariant() == "false")
                                chkAllowGzip.Checked = false;
                            break;
                        case "sockspthread":
                            if (Functions.ParseInt(tval, 1, 99, out num))
                                txtSLSpT.Text = num.ToString();
                            break;
                    }
                }
                // let's reset the other values -.-
                for (int i = 0; i < defaults.Count; i++)
                {
                    switch (defaults[i])
                    {
                        case "targetip":
                            txtTargetIP.Text = "";
                            break;
                        case "targethost":
                            txtTargetURL.Text = "";
                            break;
                        case "timeout":
                            txtTimeout.Text = "30";
                            break;
                        case "subsite":
                            txtSubsite.Text = "/";
                            break;
                        case "message":
                            txtData.Text = "U dun goofed";
                            break;
                        case "port":
                            txtPort.Text = "80";
                            break;
                        case "method":
                            int index = cbMethod.FindString("TCP");
                            if (index != -1) { cbMethod.SelectedIndex = index; }
                            break;
                        case "threads":
                            txtThreads.Text = "10";
                            break;
                        case "wait":
                            chkWaitReply.Checked = true;
                            break;
                        case "random":
                            chkRandom.Checked = false;
                            chkMsgRandom.Checked = false;
                            break;
                        case "speed":
                            tbSpeed.Value = 0;
                            break;
                        case "sockspthread":
                            txtSLSpT.Text = "25";
                            break;
                        case "useget":
                            chkUseGet.Checked = false;
                            break;
                        case "usegzip":
                            chkAllowGzip.Checked = false;
                            break;
                    }
                }
                if (restart)
                {
                    Attack(false, false, true);
                    if(!tZergRush.Enabled)
                        Attack(false, true, true);
                }
                else if (ctdwndn && (cmdAttack.Text == AttackText))
                {
                    Attack(false, true, true);
                }
                if(!tZergRush.Enabled)
                    this.Text = String.Format("{0} | U dun goofed | v. {1}", Application.ProductName, Application.ProductVersion);
            }
            return ret;
        }
        // generic method to add a string to a history item
        private void AddSearchHistoryItem(StringCollection history, string toAdd)
        {
            // add the item to the find history
            if (history.Contains(toAdd)) {
                // remove it so it gets added at the top
                history.Remove(toAdd);
            }
            // make sure there is only 20
            if (history.Count == historyLimit) {
                history.RemoveAt(historyLimit - 1);
            }
            history.Insert(0, toAdd);

            // update the drop down for the combobox
            ListStore store = new ListStore (typeof (string));
            for (int i = 0; i < history.Count; i ++)
                store.AppendValues (history[i]);

            if (history == findHistory)
                searchPatternEntry.Completion.Model = store;
            else if( history == replaceHistory)
                replacePatternEntry.Completion.Model = store;
        }
Пример #12
0
        // subtract existing rights from the ones we want to set
        public static string SubtractRights(string sExistingRights, string sNewRights)
        {
            StringCollection existingRights = new StringCollection();
            existingRights.AddRange(sExistingRights.Split('|'));
            StringCollection newRights = new StringCollection();
            newRights.AddRange(sNewRights.Split('|'));
            foreach (string sExistingRight in existingRights)
            {
                if (newRights.Contains(sExistingRight))
                    newRights.Remove(sExistingRight);
            }

            string sResult = "";
            foreach (string sVal in newRights)
                sResult += sVal + "|";
            return sResult;
        }
        // generic method to add a string to a history item
        private void AddSearchHistoryItem(StringCollection history, string toAdd)
        {
            // add the item to the find history
            if (history.Contains(toAdd)) {
                // remove it so it gets added at the top
                history.Remove(toAdd);
            }
            // make sure there is only 20
            if (history.Count == HISTORY_LIMIT) {
                history.RemoveAt(HISTORY_LIMIT - 1);
            }
            history.Insert(0, toAdd);

            // update the drop down for the combobox
            string[] stringArray = new string[history.Count];
            history.CopyTo(stringArray, 0);
            if (history == findHistory) {
                searchPatternComboBox.SetPopdownStrings(stringArray);
            } else if( history == replaceHistory) {
                replacePatternComboBox.SetPopdownStrings(stringArray);
            }
        }
Пример #14
0
 /// <summary>
 /// Checks to see if the string collection contains the key file, and if it does
 /// loads it and removes it from the collection.
 /// </summary>
 /// <param name="files">The list of files</param>
 /// <param name="file">The key file to process</param>
 private void ProcessFile(StringCollection files, string file)
 {
     if (files.Contains(file))
     {
         // Create the key, add it to our collection, and remove the
         // file from the list as we've loaded it.
         Key key = new Key(file);
         keys.Add(key);
         files.Remove(file);
     }
 }
Пример #15
0
        /// <summary>
        /// This returns a StringCollection with the names of recently used settings
        /// for the given report
        ///
        /// </summary>
        /// <returns>the list of names of recently used settings, which exist at the moment
        /// </returns>
        public StringCollection GetRecentlyUsedSettings()
        {
            StringCollection ReturnValue;
            String SettingName;
            StringCollection AvailableSettings;

            System.Int32 Counter;
            ReturnValue = new StringCollection();

            if (("RptStg" + FReportName).Length > 32)
            {
                throw new Exception(String.Format("Report name ({0}) is too long for the settings",
                        FReportName));
            }

            // get names of recently used settings from the database
            ReturnValue = StringHelper.StrSplit(TUserDefaults.GetStringDefault("RptStg" + FReportName, ""), ",");

            // remove settings that are not available anymore
            AvailableSettings = GetAvailableSettings();
            Counter = 0;

            while (Counter < ReturnValue.Count)
            {
                SettingName = ReturnValue[Counter];

                if (!AvailableSettings.Contains(SettingName))
                {
                    ReturnValue.Remove(SettingName);
                }
                else
                {
                    Counter = Counter + 1;
                }
            }

            // we might to fill up with reports from the directory, that have not been used yet
            Counter = 0;

            while ((Counter < AvailableSettings.Count) && (ReturnValue.Count < MAX_NUMBER_OF_RECENT_SETTINGS))
            {
                SettingName = AvailableSettings[Counter];

                if (!ReturnValue.Contains(SettingName))
                {
                    ReturnValue.Add(SettingName);
                }

                Counter = Counter + 1;
            }

            return ReturnValue;
        }
Пример #16
0
 public static StringCollection FindProductTemplates()
 {
     StringCollection result = new StringCollection();
     result = ListFolders("BVModules\\ProductTemplates", "Product.aspx");
     result.Remove("FixedPriceGiftCertificate");
     result.Remove("ArbitraryPriceGiftCertificate");
     return result;
 }
Пример #17
0
        /////////////////////////////////////////////////////
        //                                                 //
        // GetNextAvailableDriveLetter()                   //
        //                                                 //
        /////////////////////////////////////////////////////
        //Description:  Finds the next available drive letter
        //              on the current system.
        //Returns:      the drive letter w/o a colon
        /////////////////////////////////////////////////////
        public static string GetNextAvailableDriveLetter()
        {
            // build a string collection representing the alphabet
            StringCollection alphabet = new StringCollection();

            int lowerBound = Convert.ToInt16('g');
            int upperBound = Convert.ToInt16('z');
            for (int i = lowerBound; i < upperBound; i++)
            {
                char driveLetter = (char)i;
                alphabet.Add(driveLetter.ToString());
            }

            // get all current drives
            DriveInfo[] drives = DriveInfo.GetDrives();
            foreach (DriveInfo drive in drives)
            {
                alphabet.Remove(drive.Name.Substring(0, 1).ToLower());
            }

            //if there is one available, return it; else null
            if (alphabet.Count > 0)
                return alphabet[0];
            else
                return null;
        }
Пример #18
0
        public StringCollection GetImgLinks(string image)
        {
            StringCollection a = new StringCollection();
            string src;

            do
            {
                WebRequest(queryurl + "?what=imagelinks&titles=" + image + "&format=xml");

                HttpWebResponse webResp1 = (HttpWebResponse)WebReq.GetResponse();

                Stream srcstrm = webResp1.GetResponseStream();
                StreamReader work = new StreamReader(srcstrm);
                src = work.ReadToEnd();

                MatchCollection mcpt = Ptitle.Matches(src);
                foreach (Match m in mcpt)
                {
                    string ms = m.Value;
                    ms = Regex.Replace(ms, "</il>", "");
                    ms = Regex.Replace(ms, "<il n?s?=?\"?[0|1|2|3|4|5|6|7|8|9]*?\"? ?id=\"[0|1|2|3|4|5|6|7|8|9]*\">", "");

                    a.Add(ms);

                }
            }
            while (NextPortion.IsMatch(src));

            a.Remove(image);

            return a;
        }
Пример #19
0
        /// <summary>
        /// Removes all the element from the IScope object.
        /// </summary>
        public void Flush()
        {
            TraceUtil.Log("Flush session scope.");

            StringCollection toRemove = new StringCollection();
            StringCollection names = (StringCollection)WebUtil.GetCurrentHttpContext().Items[COMPONENT_NAMES];
            foreach (string name in names)
            {
                WebUtil.GetCurrentHttpContext().Session.Remove(SESSION_SCOPE_SUFFIX + name);
                toRemove.Remove(name);
            }
            names.Clear();
        }
Пример #20
0
        public static int Main(string[] argv)
        {
            #if TEST
            AutoTest.TestSuite();
            #endif
            int result = 1;
            StringCollection parameters = new StringCollection();
            parameters.AddRange(argv);

            AppDomain.CurrentDomain.AppendPrivatePath(Environment.CurrentDirectory);
            AppDomain.CurrentDomain.AppendPrivatePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            try {
                EntryPoint entryPoint = new EntryPoint();

                if (parameters.Contains(DebugOption)) { // Handle debug mode
                    AspectDngConfig.Instance.debug = true;
                    parameters.Remove(DebugOption);
                }

                if (parameters.Contains(QueryOption) && parameters.Count >= 3) { // Handle query mode
                    parameters.Remove(QueryOption);
                    Cil.Init(parameters[0], parameters[0]);
                    parameters.RemoveAt(0);

                    string[] array = new string[parameters.Count];
                    parameters.CopyTo(array, 0);
                    string xpath = string.Join(" ", array);
                    Console.WriteLine("\nReal XPath query:\n{0}", xpath);

                    ICollection results = Cil.TargetNavigator.SelectList(xpath);
                    Console.WriteLine("{0} results", results.Count);
                    foreach (Navigator nav in results) {
                        Console.WriteLine("[" + nav.Name + "] " + nav);
                    }
                } else if (parameters.Contains(IlmlDumpOption) && parameters.Count == 3) { // Handle ilml mode
                    parameters.Remove(IlmlDumpOption);
                    Cil.Init(parameters[0], parameters[0]);
                    parameters.RemoveAt(0);

                    // Apply XSLT to Assembly
                    XslTransform ilmlDump = new XslTransform();
                    ilmlDump.Load(new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("IlmlDump.xsl")), null, null);
                    XmlTextWriter writer = new XmlTextWriter(parameters[0], Encoding.Unicode);
                    writer.Formatting = Formatting.Indented;
                    ilmlDump.Transform(new Navigator(Cil.TargetAssembly), null, writer, null);
                    writer.Close();
                } else { // Handle weave mode
                    long Start = DateTime.Now.Ticks;
                    // Interpret parameters
                    if (parameters.Count > 0) {
                        string firstArg = parameters[0];
                        if (firstArg.EndsWith(".xml")) {
                            Log.Debug("Weaving as specified in " + firstArg);
                            entryPoint.Weave(firstArg);
                            result = 0;
                        } else if (firstArg.EndsWith(".dll") || firstArg.EndsWith(".exe")) {
                            if (parameters.Count == 1)
                                entryPoint.DirectWeave(firstArg);
                            else if (parameters.Count == 2) {
                                string secondArg = parameters[1];
                                entryPoint.DirectWeave(firstArg, secondArg);
                            }
                            result = 0;
                        } else entryPoint.PrintUsage();
                    } else entryPoint.PrintUsage();

                    if (result == 0) {
                        Log.Debug("aspectdng took in {0} millis to weave {1} aspects", (DateTime.Now.Ticks - Start) / 10000, AspectDngConfig.Instance.Advice.Count);
                        Log.Save();
                    }
                }
            } catch (ConfigurationException e) {
                Log.Error(e.Message);
            } catch (AdviceException e) {
                Log.Error(e.Message);
            } catch (Exception e) {
                Log.Error(e.Message);
                Log.Error(e.StackTrace);
            }
            return result;
        }
Пример #21
0
        private void AddPathToHistory(StringCollection list, string entry)
        {
            if (list == null)
                return;

            foreach (string item in list) {
                if (item == entry) {
                    list.Remove(item);
                    break;
                }
            }

            while (list.Count >= 5)
                list.RemoveAt(list.Count - 1);

            list.Insert(0, entry);
        }
Пример #22
0
        /// <summary>
        /// The enabled key.
        /// </summary>
        /// <param name="disabledKey">
        /// The disabled key.
        /// </param>
        /// <param name="fieldName">
        /// The field name.
        /// </param>
        public void EnabledKey(string disabledKey, string fieldName)
        {
            var currentDisabledKeys = new StringCollection();

            if (this.disabledKeys.ContainsKey(fieldName))
            {
                currentDisabledKeys = this.disabledKeys[fieldName] as StringCollection;
                this.disabledKeys.Remove(fieldName);
            }

            if (currentDisabledKeys != null && currentDisabledKeys.Contains(disabledKey))
            {
                currentDisabledKeys.Remove(disabledKey);
            }

            this.disabledKeys.Add(fieldName, currentDisabledKeys);
        }