public static void RemoveCssClass(this HtmlControl control, string cssClass) { List<string> classes = new List<string>(); if (control.Attributes["class"] != null) { classes = control.Attributes["class"].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } classes.Remove(cssClass); control.Attributes.Add("class", classes.ToDelimitedString(" ")); }
public static void Main(string[] args) { var liste = new List<int> { 50, 51 }; Console.WriteLine("Liste<int> = { " + liste.ToDelimitedString() + " }"); var critrRech = new Criteres(new DateTime(2011, 1, 1), new DateTime(2012, 2, 2), 50, 51); Console.WriteLine("Criteres 1 = { " + critrRech.ToParamArray().ToDelimitedString() + " }"); var critrRech2 = new Criteres(new DateTime(2011, 1, 1), new DateTime(2012, 2, 2)); Console.WriteLine("Criteres 2 = { " + critrRech2.ToParamArray().ToDelimitedString() + " }"); var aClass = SealedClassExtensions.CreateInstance("one"); var liste2 = aClass.GetListeString(); Console.WriteLine("Liste<string> = { Count = " + liste2.Count + ", Value(s) = " + liste2.ToDelimitedString() + " }"); }
public TemplateManager(Assembly assembly, string rootNamespace, List<string> templates, List<string> themes, string baseDirectory) { var resourceFinder = new ResourceFinder(assembly, rootNamespace, baseDirectory); if (templates == null || templates.Count == 0) { Logger.Log(LogLevel.Info, "Template is not specified, files will not be transformed."); } else { var templateResources = templates.Select(s => resourceFinder.Find(s)).Where(s => s != null).ToArray(); if (templateResources.Length == 0) { Logger.Log(LogLevel.Warning, $"No template resource found for [{templates.ToDelimitedString()}]."); } else { _templateProcessor = new TemplateProcessor(new CompositeResourceCollectionWithOverridden(templateResources)); } } if (themes == null || themes.Count == 0) { Logger.Log(LogLevel.Info, "Theme is not specified, no additional theme will be applied to the documentation."); } else { var themeResources = themes.Select(s => resourceFinder.Find(s)).Where(s => s != null).ToArray(); if (themeResources.Length == 0) { Logger.Log(LogLevel.Warning, $"No theme resource found for [{themes.ToDelimitedString()}]."); } else { _themeResource = new CompositeResourceCollectionWithOverridden(themeResources); } } }
private static void CleanAddresses(System.Net.Mail.MailMessage msg) { if (Settings.Current.WebsiteMode == WebsiteMode.Production) return; var invalid = new List<string>(); invalid.AddRange(CleanAddresses(msg.To)); invalid.AddRange(CleanAddresses(msg.CC)); invalid.AddRange(CleanAddresses(msg.Bcc)); if (invalid.Count == 0) return; if (invalid.Count <= 3) msg.Subject = String.Concat("[", invalid.ToDelimitedString(), "] ", msg.Subject).StripInvisible(); msg.To.Add(Settings.Current.TestEmailAddress); }
/// <summary> /// The build search sql. /// </summary> /// <param name="toSearchWhat"> /// The to search what. /// </param> /// <param name="toSearchFromWho"> /// The to search from who. /// </param> /// <param name="searchFromWhoMethod"> /// The search from who method. /// </param> /// <param name="searchWhatMethod"> /// The search what method. /// </param> /// <param name="userID"> /// The user id. /// </param> /// <param name="searchDisplayName"> /// The search display name. /// </param> /// <param name="boardId"> /// The board id. /// </param> /// <param name="maxResults"> /// The max results. /// </param> /// <param name="useFullText"> /// The use full text. /// </param> /// <param name="forumIds"> /// The forum ids. /// </param> /// <returns> /// The build search sql. /// </returns> public string BuildSearchSql( [NotNull] string toSearchWhat, [NotNull] string toSearchFromWho, SearchWhatFlags searchFromWhoMethod, SearchWhatFlags searchWhatMethod, int userID, bool searchDisplayName, int boardId, int maxResults, bool useFullText, [NotNull] IEnumerable<int> forumIds) { CodeContracts.ArgumentNotNull(toSearchWhat, "toSearchWhat"); CodeContracts.ArgumentNotNull(toSearchFromWho, "toSearchFromWho"); CodeContracts.ArgumentNotNull(forumIds, "forumIds"); var builtStatements = new List<string>(); if (maxResults > 0) { builtStatements.Add("SET ROWCOUNT {0};".FormatWith(maxResults)); } string searchSql = "SELECT a.ForumID, a.TopicID, a.Topic, b.UserID, IsNull(c.Username, b.Name) as Name, c.MessageID, c.Posted, [Message] = '', c.Flags "; searchSql += "\r\nfrom {databaseOwner}.{objectQualifier}topic a left join {databaseOwner}.{objectQualifier}message c on a.TopicID = c.TopicID left join {databaseOwner}.{objectQualifier}user b on c.UserID = b.UserID join {databaseOwner}.{objectQualifier}vaccess x on x.ForumID=a.ForumID "; searchSql += "\r\nwhere x.ReadAccess<>0 AND x.UserID={0} AND c.IsApproved = 1 AND a.TopicMovedID IS NULL AND a.IsDeleted = 0 AND c.IsDeleted = 0" .FormatWith(userID); if (forumIds.Any()) { searchSql += " AND a.ForumID IN ({0})".FormatWith(forumIds.ToDelimitedString(",")); } if (toSearchFromWho.IsSet()) { searchSql += "\r\nAND ({0})".FormatWith( this.BuildWhoConditions(toSearchFromWho, searchFromWhoMethod, searchDisplayName).BuildSql(true)); } if (toSearchWhat.IsSet()) { builtStatements.Add(searchSql); builtStatements.Add( "AND ({0})".FormatWith( this.BuildWhatConditions(toSearchWhat, searchWhatMethod, "c.Message", useFullText).BuildSql(true))); builtStatements.Add("UNION"); builtStatements.Add(searchSql); builtStatements.Add( "AND ({0})".FormatWith( this.BuildWhatConditions(toSearchWhat, searchWhatMethod, "a.Topic", useFullText).BuildSql(true))); } else { builtStatements.Add(searchSql); } builtStatements.Add("ORDER BY c.Posted DESC"); string builtSql = builtStatements.ToDelimitedString("\r\n"); Debug.WriteLine("Build Sql: [{0}]".FormatWith(builtSql)); return builtSql; }
public string HtmlTagForbiddenDetector( [NotNull] string stringToClear, [NotNull] string stringToMatch, char delim) { string[] codes = stringToMatch.Split(delim); var forbiddenTagList = new List<string>(); MatchAndPerformAction( "<.*?>", stringToClear, (tag, index, len) => { var code = tag.Replace("/", string.Empty).Replace(">", string.Empty); // If tag contains attributes kill them for cecking if (code.Contains("=\"")) { code = code.Remove(code.IndexOf(" ", StringComparison.Ordinal)); } if (codes.Any(allowedTag => code.ToLower() == allowedTag.ToLower())) { return; } if (!forbiddenTagList.Contains(code)) { forbiddenTagList.Add(code); } }); return forbiddenTagList.ToDelimitedString(","); /*bool checker = string.IsNullOrEmpty(stringToMatch); //string[] codes = stringToMatch.Split(delim); char[] charray = stringToClear.ToCharArray(); int currentPosition = 0; // Loop through char array i will be current poision for (int i = 0; i < charray.Length; i++) { if (i >= currentPosition) { // bbcode token is detected if (charray[i] == '<') { int openPosition = i; // we loop to find closing bracket, beginnin with i position for (int j = i; j < charray.Length - 1; j++) { // closing bracket found if (charray[j] != '>') { continue; } // we should reset the value in each cycle // if an opening bracket was found bool detectedTag = false; string res = null; // now we loop through out allowed bbcode list foreach (string t in codes) { // closing bracket is in position 'j' opening is in pos 'i' // we should not take into account closing bracket // as we have tags like '[URL=' for (int l = openPosition; l < j; l++) { res = res + charray[l].ToString().ToUpper(); } if (checker) { return "ALL"; } // detect if the tag from list was found detectedTag = res.Contains("<" + t.ToUpper().Trim()) || res.Contains("</" + t.ToUpper().Trim()); res = string.Empty; // if so we go out from k-loop after we should go out from j-loop too if (!detectedTag) { continue; } currentPosition = j + 1; break; } currentPosition = j + 1; // we didn't found the allowed tag in k-loop through allowed list, // so the tag is forbidden one and we should exit if (!detectedTag) { string tagForbidden = stringToClear.Substring(i, j - i + 1).ToUpper(); return tagForbidden; } if (detectedTag) { break; } // continue to loop } } } } */ }
private List<int> GetIdsOfContainedFeatureCentroids(IRecordSet recordset, IPolygon tilePolygon) { List<int> ids = new List<int>(); IFeatureCursor cursor = recordset.get_Cursor(true) as IFeatureCursor; IFeature feature = cursor.NextFeature(); if (feature == null) { return ids; } if (feature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryMultipoint && feature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryPolygon) { throw new ArgumentException("Only multipoint and polygon geometry types are supported by this method."); } this.tracePolygon(tilePolygon); IRelationalOperator2 relationalOperator = tilePolygon as IRelationalOperator2; try { // Envelope must contain centriod IPoint centroid = null; while (feature != null) { centroid = (feature.ShapeCopy as IArea).Centroid; if (relationalOperator.Contains(centroid)) { this.tracePolygonContainsPoint(tilePolygon, centroid, feature.OID); ids.Add(feature.OID); } feature = cursor.NextFeature(); } if (ids.Count > 0) { System.Diagnostics.Debug.WriteLine("OIDs with centroids contained: " + ids.ToDelimitedString<int>(",")); } return ids; } finally { this.ReleaseComObject(cursor); cursor = null; } }
// Parse LDAP distinguished name tokens private static string ParseDNTokens(string dn, string token, char delimiter = '.') { List<string> tokens = new List<string>(); string[] elements = dn.Split(','); for (int i = 0; i < elements.Length; i++) { string element = elements[i].Trim(); if (element.StartsWith(token, StringComparison.OrdinalIgnoreCase)) { string[] parts = element.Split('='); if (parts.Length == 2) tokens.Add(parts[1].Trim()); } } return tokens.ToDelimitedString(delimiter); }
/// <summary> /// Builds the search SQL. /// </summary> /// <param name="context">The search context.</param> /// <returns>Returns the full SQL script</returns> public string BuildSearchSql([NotNull] ISearchContext context) { CodeContracts.VerifyNotNull(context, "context"); var builtStatements = new List<string>(); if (context.MaxResults > 0) { builtStatements.Add("SET ROWCOUNT {0};".FormatWith(context.MaxResults)); } string searchSql = "SELECT a.ForumID, a.TopicID, a.Topic, b.UserID, IsNull(c.Username, b.Name) as Name, c.MessageID, c.Posted, [Message] = '', c.Flags "; searchSql += "\r\nfrom {databaseOwner}.{objectQualifier}topic a left join {databaseOwner}.{objectQualifier}message c on a.TopicID = c.TopicID left join {databaseOwner}.{objectQualifier}user b on c.UserID = b.UserID join {databaseOwner}.{objectQualifier}vaccess x on x.ForumID=a.ForumID "; searchSql += "\r\nwhere x.ReadAccess<>0 AND x.UserID={0} AND c.IsApproved = 1 AND a.TopicMovedID IS NULL AND a.IsDeleted = 0 AND c.IsDeleted = 0" .FormatWith(context.UserID); if (context.ForumIDs.Any()) { searchSql += " AND a.ForumID IN ({0})".FormatWith(context.ForumIDs.ToDelimitedString(",")); } if (context.ToSearchFromWho.IsSet()) { searchSql += "\r\nAND ({0})".FormatWith( this.BuildWhoConditions( context.ToSearchFromWho, context.SearchFromWhoMethod, context.SearchDisplayName).BuildSql(true)); } if (context.ToSearchWhat.IsSet()) { if (!context.SearchTitleOnly) { builtStatements.Add(searchSql); builtStatements.Add( "AND ({0})".FormatWith( this.BuildWhatConditions( context.ToSearchWhat, context.SearchWhatMethod, "c.Message", context.UseFullText).BuildSql(true))); builtStatements.Add("UNION"); } builtStatements.Add(searchSql); builtStatements.Add( "AND ({0})".FormatWith( this.BuildWhatConditions( context.ToSearchWhat, context.SearchWhatMethod, "a.Topic", context.UseFullText).BuildSql(true))); } else { builtStatements.Add(searchSql); } builtStatements.Add("ORDER BY c.Posted DESC"); string builtSql = builtStatements.ToDelimitedString("\r\n"); Debug.WriteLine("Build Sql: [{0}]".FormatWith(builtSql)); return builtSql; }
private static void WriteRecordToFile(List<string> record, StreamWriter sw, int rowNumber, int totalRowCount) { var commaDelimitedRecord = record.ToDelimitedString(","); if (rowNumber == totalRowCount) { sw.Write(commaDelimitedRecord); } else { sw.WriteLine(commaDelimitedRecord); } }