protected bool TestOk(string group, string token) { //nb: ensure that capitalization does not mess anyone up //we approve it if we find either just a token (UI), or that token preceded by the group name (WW:UI) return(m_tokens.Contains(group.ToLower() + ":" + token.ToLower()) || m_tokens.Contains(token.ToLower())); }
private static void AddAssemblyReference(Assembly referencedAssembly, StringCollection referencedAssemblies) { string path = Path.GetFullPath(referencedAssembly.Location); string name = Path.GetFileName(path); if (!(referencedAssemblies.Contains(name) || referencedAssemblies.Contains(path))) { referencedAssemblies.Add(path); } }
public static StringCollection GetLinksFromHTML(string HtmlContent) { StringCollection links = new StringCollection(); MatchCollection AnchorTags = Regex.Matches(HtmlContent.ToLower(), @"(<a.*?>.*?</a>)", RegexOptions.Singleline); MatchCollection ImageTags = Regex.Matches(HtmlContent.ToLower(), @"(<img.*?>)", RegexOptions.Singleline); foreach (Match AnchorTag in AnchorTags) { string value = AnchorTag.Groups[1].Value; Match HrefAttribute = Regex.Match(value, @"href=\""(.*?)\""", RegexOptions.Singleline); if (HrefAttribute.Success) { string HrefValue = HrefAttribute.Groups[1].Value; HrefValue = HrefValue.Replace(@"\0026", "&"); var ascii = Regex.Match(HrefValue, @"?\d\d;", RegexOptions.Singleline); if (ascii.Success) { string chr = ascii.Groups[0].ToString().Remove(0, 2); chr = chr.Remove(chr.Length-1); int ichr = int.Parse(chr); char decodedChar = (char)ichr; HrefValue = HrefValue.Replace(ascii.Groups[0].ToString(), decodedChar.ToString()); } HrefValue = HrefValue.Replace(":", ":"); if (!links.Contains(HrefValue)) { links.Add(HrefValue); } } } foreach (Match ImageTag in ImageTags) { string value = ImageTag.Groups[1].Value; Match SrcAttribute = Regex.Match(value, @"src=\""(.*?)\""", RegexOptions.Singleline); if (SrcAttribute .Success) { string SrcValue = SrcAttribute.Groups[1].Value; if (!links.Contains(SrcValue)) { links.Add(SrcValue); } } } return links; }
[Test] public void Test_04_GetUserRoles() { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string[] roles = admin.GetUserRoles(Globals.SiteCollectionForCreationTests(), @"WSDEV\lnpair"); Assert.IsTrue(roles.Length == 2, "The user is both a Reader and a Contributor"); StringCollection roleList = new StringCollection(); roleList.AddRange(roles); Assert.IsTrue(roleList.Contains("Read"), @"WSDEV\lnpair is a Reader on this site. Really!"); Assert.IsTrue(roleList.Contains("Contribute"), @"WSDEV\lnpair is a Contributor on this site. Really!"); }
/// <summary> /// </summary> /// <param name="folder"></param> public virtual void LoadSlideNames(string folder) { string[] files157b6d8a = null; System.Collections.Specialized.StringCollection StringCollectionFileNames3a9e25eb = null; string filename865b90e0 = null; int UnderScorePos2041a161 = 0; files157b6d8a = System.IO.Directory.GetFiles(folder, "*.xml"); StringCollectionFileNames3a9e25eb = new System.Collections.Specialized.StringCollection(); for (int index_157b6d8a_9d82a78a = 0; (index_157b6d8a_9d82a78a < files157b6d8a.Length); index_157b6d8a_9d82a78a++) { filename865b90e0 = System.IO.Path.GetFileName(files157b6d8a[index_157b6d8a_9d82a78a]); UnderScorePos2041a161 = filename865b90e0.IndexOf('_'); if ((UnderScorePos2041a161 > 1)) { filename865b90e0 = filename865b90e0.Substring(0, UnderScorePos2041a161); if ((StringCollectionFileNames3a9e25eb.Contains(filename865b90e0) == false)) { StringCollectionFileNames3a9e25eb.Add(filename865b90e0); } } } for (int index_3a9e25eb_93735191 = 0; (index_3a9e25eb_93735191 < StringCollectionFileNames3a9e25eb.Count); index_3a9e25eb_93735191++) { this.ListBox1.Items.Add(StringCollectionFileNames3a9e25eb[index_3a9e25eb_93735191]); } }
[Test] public void Test_03_ListUsers() { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string[] users = admin.ListUsers(Globals.SiteCollectionForCreationTests()); Assert.IsTrue(users.Length == 2, "There are two users in the list."); StringCollection userList = new StringCollection(); for(int i = 0; i < users.Length; ++i) { userList.Add(users[i]); } Assert.IsTrue(userList.Contains(@"WSDEV\lnpair"), "Contributor user is missing."); Assert.IsTrue(userList.Contains(@"UK\iainb"), "Contributor user is missing."); }
internal async Task CheckDirectoriesAsync() { var dodgy = new List <string>(); using (new CursorOverride(Cursors.Wait)) { var files = ListFiles(); foreach (var file in files) { if (!legitDirectories.Contains(file.Path)) { dodgy.Add(file.Path); } } } if (dodgy.Count == 0) { MessageBox.Show("Nothing dodgy", "WebWriter AntiHacker", MessageBoxButton.OK, MessageBoxImage.Information); } else { IUIVisualizerService uIVisualiserService = ServiceLocator.Default.ResolveType <IUIVisualizerService>(); if (!(uIVisualiserService is null)) { await uIVisualiserService.ShowDialogAsync <DodgyStuffViewModel>(dodgy); } } }
public static void Copy(StringCollection frList, StringCollection toList) { if (frList == null) return; for (int idx = 0; idx < frList.Count; idx++) { if (toList.Contains(frList[idx]) == false) toList.Add(frList[idx]); } }
public static StringCollection Clone(StringCollection list) { if (list == null) return null; StringCollection retList = new StringCollection(); for (int idx = 0; idx < list.Count; idx++) { if (retList.Contains(list[idx]) == false) retList.Add(list[idx]); } return retList; }
/// <summary> /// Evaulate the path string in relation to the current item /// </summary> /// <param name="context">The Revolver context to evaluate the path against</param> /// <param name="path">The path to evaulate. Can either be absolute or relative</param> /// <returns>The full sitecore path to the target item</returns> public static string EvaluatePath(Context context, string path) { if (ID.IsID(path)) return path; string workingPath = string.Empty; if (!path.StartsWith("/")) workingPath = context.CurrentItem.Paths.FullPath + "/" + path; else workingPath = path; // Strip any language and version tags if (workingPath.IndexOf(':') >= 0) workingPath = workingPath.Substring(0, workingPath.IndexOf(':')); // Make relative paths absolute string[] parts = workingPath.Split('/'); StringCollection targetParts = new StringCollection(); targetParts.AddRange(parts); while (targetParts.Contains("..")) { int ind = targetParts.IndexOf(".."); targetParts.RemoveAt(ind); if (ind > 0) { targetParts.RemoveAt(ind - 1); } } if (targetParts[targetParts.Count - 1] == ".") targetParts.RemoveAt(targetParts.Count - 1); // Remove empty elements while (targetParts.Contains("")) { targetParts.RemoveAt(targetParts.IndexOf("")); } string[] toRet = new string[targetParts.Count]; targetParts.CopyTo(toRet, 0); return "/" + string.Join("/", toRet); }
private static TheBox.Data.Facet Convert( LocationsList list ) { TheBox.Data.Facet f = new TheBox.Data.Facet(); StringCollection categories = new StringCollection(); foreach( Location loc in list.Places ) { if ( ! categories.Contains( loc.Category ) ) { categories.Add( loc.Category ); } } foreach( string cat in categories ) { TheBox.Common.GenericNode g = new TheBox.Common.GenericNode( cat ); f.Nodes.Add( g ); } foreach( TheBox.Common.GenericNode g in f.Nodes ) { StringCollection sub = new StringCollection(); foreach( Location loc in list.Places ) { if ( loc.Category == g.Name && ! sub.Contains( loc.Subsection ) ) { sub.Add( loc.Subsection ); } } foreach( string s in sub ) { TheBox.Common.GenericNode gSub = new TheBox.Common.GenericNode( s ); g.Elements.Add( gSub ); } } foreach( TheBox.Common.GenericNode gCat in f.Nodes ) { foreach( TheBox.Common.GenericNode gSub in gCat.Elements ) { foreach( Location loc in list.Places ) { if ( loc.Category == gCat.Name && loc.Subsection == gSub.Name ) { gSub.Elements.Add( Convert( loc ) ); } } } } return f; }
public bool HasHorizontalVisibility(StringCollection activeAgentFacets) { char[] lDelimiter = { ',' }; string[] lAgents = EmptyHorizontalVisibility.Split(lDelimiter); for (int i = 0; i < lAgents.Length; i++) { if (activeAgentFacets.Contains(lAgents[i].Trim())) return false; } lAgents = HorizontalVisibility.Split(lDelimiter); for (int i = 0; i < lAgents.Length; i++) { if (activeAgentFacets.Contains(lAgents[i].Trim())) return true; } return false; }
private static bool CompareColumns(DataTable source, DataRow sourcerow, DataRow destrow, StringCollection ignorecolumns) { foreach(DataColumn column in source.Columns) { // Not in ignored columns? if(ignorecolumns == null || !ignorecolumns.Contains(column.ColumnName)) { if(sourcerow[column.ColumnName].ToString() != destrow[column.ColumnName].ToString()) return false; } } return true; // All columns matching }
private static ACostCentreRow GetDepartmentCostCentre(ACostCentreTable ACostCentres, ACostCentreRow ACostCentreToInvestigate, StringCollection ADepartmentCodes) { if (ADepartmentCodes.Contains(ACostCentreToInvestigate.CostCentreCode)) { return ACostCentreToInvestigate; } ACostCentreRow row = (ACostCentreRow)ACostCentres.DefaultView.FindRows(ACostCentreToInvestigate.CostCentreToReportTo)[0].Row; return GetDepartmentCostCentre(ACostCentres, row, ADepartmentCodes); }
internal static void AddAssemblyToStringCollection(Assembly assembly, StringCollection toList) { string path = null; if (!MultiTargetingUtil.EnableReferenceAssemblyResolution) { path = GetAssemblyCodeBase(assembly); } else if (AssemblyResolver.GetPathToReferenceAssembly(assembly, out path) == ReferenceAssemblyType.FrameworkAssemblyOnlyPresentInHigherVersion) { return; } if (!toList.Contains(path)) { toList.Add(path); } }
[Test] public void Test_01_ListAvailableSiteTemplates() { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string[] templates = admin.ListAvailableSiteTemplates(Globals.SiteCollectionForTests()); StringCollection tpls = new StringCollection(); tpls.AddRange(templates); Assert.IsTrue(tpls.Contains("Team Site"), "Template is missing: Team Site"); Assert.IsTrue(tpls.Contains("Blank Site"), "Template is missing: Blank Site"); Assert.IsTrue(tpls.Contains("Document Workspace"), "Template is missing: Document Workspace"); Assert.IsTrue(tpls.Contains("Basic Meeting Workspace"), "Template is missing: Basic Meeting Workspace"); Assert.IsTrue(tpls.Contains("Blank Meeting Workspace"), "Template is missing: Blank Meeting Workspace"); Assert.IsTrue(tpls.Contains("Decision Meeting Workspace"), "Template is missing: Decision Meeting Workspace"); Assert.IsTrue(tpls.Contains("Social Meeting Workspace"), "Template is missing: Social Meeting Workspace"); Assert.IsTrue(tpls.Contains("Multipage Meeting Workspace"), "Template is missing: Multipage Meeting Workspace"); }
/// <summary> /// The disabled key. /// </summary> /// <param name="disabledKey"> /// The the key that will be used to maanage the disabled field. /// </param> /// <param name="fieldName"> /// The field name. /// </param> public void DisabledKey(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.Add(disabledKey); } this.disabledKeys.Add(fieldName, currentDisabledKeys); }
/// <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); } }
// Loads the ping services into a StringCollection public override StringCollection LoadPingServices() { string fileName = _Folder + "PingServices.xml"; if (!File.Exists(fileName)) return new StringCollection(); StringCollection col = new StringCollection(); XmlDocument doc = new XmlDocument(); doc.Load(fileName); foreach (XmlNode node in doc.SelectNodes("services/service")) { if (!col.Contains(node.InnerText)) col.Add(node.InnerText); } return col; }
public void Test01() { StringCollection sc; // [] StringCollection is constructed as expected //----------------------------------------------------------------- sc = new StringCollection(); // [] compare to null // if (sc == null) { Assert.False(true, string.Format("Error, collection is null after default ctor")); } // [] check Count // if (sc.Count != 0) { Assert.False(true, string.Format("Error, Count = {0} after default ctor", sc.Count)); } // [] check more properties // if (sc.Contains("string")) { Assert.False(true, string.Format("Error, Contains() returned true after default ctor")); } if (sc.IsReadOnly) { Assert.False(true, string.Format("Error, IsReadOnly returned {0}", sc.IsReadOnly)); } // // IsSynchronized = false by default // if (sc.IsSynchronized) { Assert.False(true, string.Format("Error, IsSynchronized returned {0}", sc.IsSynchronized)); } }
private void MakeIndicatorData(DateTime frDate, DateTime toDate,StringCollection indicatorCode,StringCollection stockCode) { int priceAdjustDay = 100; DateTime frPriceDate = frDate.AddDays(-priceAdjustDay); progressBar.Visible = true; myDataSet.indicator.Clear(); application.dataLibs.LoadData(myDataSet.indicator,false); common.myKeyValueItem[] indicatorCodeList = new common.myKeyValueItem[0]; for (int idx = 0; idx < myDataSet.indicator.Count; idx++) { if(!indicatorCode.Contains(myDataSet.indicator[idx].code.Trim())) continue; Array.Resize(ref indicatorCodeList,indicatorCodeList.Length+1); indicatorCodeList[indicatorCodeList.Length-1]= new common.myKeyValueItem(myDataSet.indicator[idx].code.Trim(),myDataSet.indicator[idx].parameter.Trim()); } //this.ShowMessage("Calculating..."); progressBar.Maximum = stockCode.Count; progressBar.Value = 0; myDataSet.indicatorData.Clear(); for (int count = 0; count < stockCode.Count; count++) { if (fCanceled) break; myDataSet.indicatorData.Clear(); myDataSet.priceData.Clear(); application.dataLibs.LoadData(myDataSet.priceData, frPriceDate, toDate, stockCode[count]); MakeIndicatorData(indicatorCodeList, myDataSet.priceData, myDataSet.indicatorData); //Update database application.dataLibs.DeleteIndicatorDataByStockCode(frDate, toDate, stockCode[count]); for (int idx = 0; idx < myDataSet.indicatorData.Count; idx++) { if (myDataSet.indicatorData[idx].onDate < frDate || myDataSet.indicatorData[idx].onDate > toDate) continue; application.dataLibs.UpdateData(myDataSet.indicatorData[idx]); } progressBar.Value++; Application.DoEvents(); } progressBar.Visible = false; this.ShowMessage(""); return; }
/// <summary> /// Loads the ping services. /// </summary> /// <returns>A StringCollection.</returns> public override StringCollection LoadPingServices() { var fileName = this.Folder + "pingservices.xml"; if (!File.Exists(fileName)) { return new StringCollection(); } var col = new StringCollection(); var doc = new XmlDocument(); doc.Load(fileName); foreach (XmlNode node in doc.SelectNodes("services/service").Cast<XmlNode>().Where(node => !col.Contains(node.InnerText))) { col.Add(node.InnerText); } return col; }
public bool DoesFilterApply(StringCollection p, int c, bool o, bool i, string r) { if (!Properties.Settings.Default.useFilter) return true; if (!p.Contains(Planet)) return false; if (o && c > Credits) return false; if (!o && c < Credits) return false; if (i && Rewards.Length == 0) return false; if (r.Length > 0) { string[] rs = r.Split(','); for (int y = 0; y < rs.Length; ++y) { for (int x = 0; x < Rewards.Length; ++x) { if (Rewards[x].ToLower().Contains(rs[y].Trim().ToLower())) return true; } } return false; } return true; }
public void ListBoxMultiSelection() { ListBoxTester myListBox = new ListBoxTester("myListBox"); string[] alternateColors = new string[] {"Red", "Yellow", "Blue", "Violet"}; StringCollection alternates = new StringCollection(); alternates.AddRange(alternateColors); myListBox.ClearSelected(); foreach(string color in alternates) { myListBox.SetSelected(color, true); } Assert.AreEqual(4, myListBox.Properties.SelectedItems.Count); foreach(object selectedItem in myListBox.Properties.SelectedItems) { Assert.IsTrue(alternates.Contains(Convert.ToString(selectedItem))); } }
public void ListAllEncoders() { var encoders = new AudioEncoderCollection(); Assert.IsTrue(encoders.Count > 1); var names = new StringCollection(); foreach (AudioEncoder encoder in encoders) { Assert.IsFalse(string.IsNullOrEmpty(encoder.FriendlyName)); Assert.IsFalse(names.Contains(encoder.FriendlyName)); names.Add(encoder.FriendlyName); } // if you want to dump a list out, a better example foreach (AudioEncoder encoder in encoders) { Console.WriteLine(string.Format("encoder: {0}\r\n------------------------------\r\n", encoder.FriendlyName)); foreach (WavFormatInfo info in encoder.Formats) { Console.WriteLine(info.ToString()); } } }
ICollection IPropertyValueProvider.GetPropertyValues(ITypeDescriptorContext context) { StringCollection names = new StringCollection(); if (string.Equals(context.PropertyDescriptor.Name, "OwnerActivityName", StringComparison.Ordinal)) { ISelectionService selectionService = context.GetService(typeof(ISelectionService)) as ISelectionService; if (selectionService != null && selectionService.SelectionCount == 1 && selectionService.PrimarySelection is Activity) { // add empty string as an option // names.Add(string.Empty); Activity currentActivity = selectionService.PrimarySelection as Activity; foreach (Activity activity in GetEnclosingCompositeActivities(currentActivity)) { string activityId = activity.QualifiedName; if (!names.Contains(activityId)) { names.Add(activityId); } } } } return names; }
private void BuildVisualStudioAssemblyFolders(StringCollection folderList, RegistryKey hive, string visualStudioVersion) { RegistryKey assemblyFolders = hive.OpenSubKey(@"SOFTWARE\Microsoft\VisualStudio\" + visualStudioVersion + @"\AssemblyFolders"); if (assemblyFolders == null) { return; } string[] subKeyNames = assemblyFolders.GetSubKeyNames(); foreach (string subKeyName in subKeyNames) { RegistryKey subKey = assemblyFolders.OpenSubKey(subKeyName); string folder = subKey.GetValue(string.Empty) as string; if (folder != null && !folderList.Contains(folder)) { folderList.Add(folder); } } }
private void BuildDotNetAssemblyFolders(StringCollection folderList, RegistryKey hive) { RegistryKey assemblyFolders = hive.OpenSubKey(@"SOFTWARE\Microsoft\" + @".NETFramework\AssemblyFolders"); if (assemblyFolders == null) { return; } string[] subKeyNames = assemblyFolders.GetSubKeyNames(); foreach (string subKeyName in subKeyNames) { RegistryKey subKey = assemblyFolders.OpenSubKey(subKeyName); string folder = subKey.GetValue(string.Empty) as string; if (folder != null && !folderList.Contains(folder)) { folderList.Add(folder); } } }
private static string FormatLinks(string text) { if (string.IsNullOrEmpty(text)) { return text; } //Find any links string pattern = @"(\s|^)(http|ftp|https):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])(\s|$)"; MatchCollection matchs; StringCollection uniqueMatches = new StringCollection(); matchs = Regex.Matches(text, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled); foreach (Match m in matchs) { if (!uniqueMatches.Contains(m.ToString())) { string link = m.ToString().Trim(); if (link.Length > 30) { try { Uri uri = new Uri(link); string absolutePath = uri.AbsolutePath.EndsWith("/") ? uri.AbsolutePath.Substring(0, uri.AbsolutePath.Length - 1) : uri.AbsolutePath; int slashIndex = absolutePath.LastIndexOf("/"); if (slashIndex > -1) { absolutePath = "/..." + absolutePath.Substring(slashIndex); } if (absolutePath.Length > 20) { absolutePath = absolutePath.Substring(0, 20); } link = uri.Host + absolutePath; } catch { } } text = text.Replace(m.ToString(), " <a onclick=\" return openLinkInDefaultBrowser('" + m.ToString().Trim() + "')\" target=\"_blank\" href=\"" + "javascript:void();" + "\">" + link + "</a> "); uniqueMatches.Add(m.ToString()); } } pattern = "@*\\w"; matchs = Regex.Matches(text, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled); foreach (Match m in matchs) { string link = m.ToString().Trim(); // text = text.Replace(m.ToString(), " <a onclick=\" return openPersonInDefaultBrowser('" + (m.ToString()).Substring(1).Trim() + "')\" target=\"_blank\" href=\"" + "javascript:void();" + "\">" + link + "</a> "); } return text; }
/// <summary> /// Get stopwords from the database /// </summary> /// <returns>collection of stopwords</returns> public override StringCollection LoadStopWords() { StringCollection col = new StringCollection(); string connString = ConfigurationManager.ConnectionStrings[connStringName].ConnectionString; string providerName = ConfigurationManager.ConnectionStrings[connStringName].ProviderName; DbProviderFactory provider = DbProviderFactories.GetFactory(providerName); using (DbConnection conn = provider.CreateConnection()) { conn.ConnectionString = connString; using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "SELECT StopWord FROM " + tablePrefix + "StopWords"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; conn.Open(); using (DbDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { if (!col.Contains(rdr.GetString(0))) col.Add(rdr.GetString(0)); } } } } return col; }
/// <summary> /// Gets the member or type access. /// </summary> /// <param name="wordList">The word list.</param> /// <returns>Member or type access.</returns> private static CodeAccess GetAccess(StringCollection wordList) { CodeAccess access = CodeAccess.None; if (wordList.Contains(VBKeyword.Public)) { access = CodeAccess.Public; } else if (wordList.Contains(VBKeyword.Private)) { access = CodeAccess.Private; } else { if (wordList.Contains(VBKeyword.Protected)) { access |= CodeAccess.Protected; } if (wordList.Contains(VBKeyword.Friend)) { access |= CodeAccess.Internal; } } return access; }
public static string FormatLinks(string text) { if (string.IsNullOrEmpty(text)) return text; //Find any links string pattern = @"(\s|^)(http|ftp|https):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])(\s|$)"; MatchCollection matchs; StringCollection uniqueMatches = new StringCollection(); matchs = Regex.Matches(text, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled); foreach (Match m in matchs) { if (!uniqueMatches.Contains(m.ToString())) { string link = m.ToString().Trim(); if (link.Length > 30) { try { Uri u = new Uri(link); string absolutePath = u.AbsolutePath.EndsWith("/") ? u.AbsolutePath.Substring(0, u.AbsolutePath.Length - 1) : u.AbsolutePath; int slashIndex = absolutePath.LastIndexOf("/"); if (slashIndex > -1) absolutePath = "/..." + absolutePath.Substring(slashIndex); if (absolutePath.Length > 20) absolutePath = absolutePath.Substring(0, 20); link = u.Host + absolutePath; } catch { } } text = text.Replace(m.ToString(), " <a target=\"_blank\" href=\"" + m.ToString().Trim() + "\">" + link + "</a> "); uniqueMatches.Add(m.ToString()); } } return text; }
public void RealFileViewUpdate (ArrayList directoriesArrayList, ArrayList fileArrayList) { BeginUpdate (); Items.Clear (); SelectedItems.Clear (); foreach (FSEntry directoryFSEntry in directoriesArrayList) { if (!ShowHiddenFiles) if (directoryFSEntry.Name.StartsWith (".") || (directoryFSEntry.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue; FileViewListViewItem listViewItem = new FileViewListViewItem (directoryFSEntry); Items.Add (listViewItem); } StringCollection collection = new StringCollection (); foreach (FSEntry fsEntry in fileArrayList) { // remove duplicates. that can happen when you read recently used files for example if (collection.Contains (fsEntry.Name)) { string fileName = fsEntry.Name; if (collection.Contains (fileName)) { int i = 1; while (collection.Contains (fileName + "(" + i + ")")) { i++; } fileName = fileName + "(" + i + ")"; } fsEntry.Name = fileName; } collection.Add (fsEntry.Name); DoOneFSEntry (fsEntry); } EndUpdate (); collection.Clear (); collection = null; directoriesArrayList.Clear (); fileArrayList.Clear (); }
/// <summary> /// Gets the type of the operator. /// </summary> /// <param name="wordList">The word list.</param> /// <returns>Operator type.</returns> private static OperatorType GetOperatorType(StringCollection wordList) { OperatorType operatorType = OperatorType.None; if (wordList.Contains(VBKeyword.Widening)) { operatorType = OperatorType.Implicit; } else if (wordList.Contains(VBKeyword.Narrowing)) { operatorType = OperatorType.Explicit; } return operatorType; }