diff --git a/Extensions/CommonExtensions.cs b/Extensions/CommonExtensions.cs
index f8c7aea..22d9153 100644
--- a/Extensions/CommonExtensions.cs
+++ b/Extensions/CommonExtensions.cs
@@ -624,6 +624,21 @@ namespace xCommons.Extensions
{
return !source.IsNull() && source.Count() > 0;
}
+
+ ///
+ /// Select Async ...
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task> SelectAsync(
+ this IEnumerable source, Func> method
+ )
+ {
+ return await Task.WhenAll(source.Select(async s => await method(s)));
+ }
///
/// Update a Collection item ...
@@ -919,6 +934,58 @@ namespace xCommons.Extensions
return result;
}
+ ///
+ /// Summarize a Text ...
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string SummarizeContent(
+ this string source,
+ int maxAllowedLength = 0,
+ string endsWith = ""
+ )
+ {
+ //
+ var result = string.Empty;
+ if (source.IsNullOrEmpty() || maxAllowedLength <= 0)
+ {
+ //
+ result = source;
+ return result;
+ }
+
+ //
+ // Pattern of Links ...
+ var pattern = @"(?:[!]\[(.*?)\]\(.*?\))";
+
+ //
+ // Apply Summarization ...
+
+ //
+ // Replace Markdown Links using RegExp ...
+ result = Regex.Replace(source, pattern, "");
+
+ //
+ // Do Summarization if Length bigger than MaxLength ...
+ if (result.Length > maxAllowedLength)
+ {
+ result = result.Substring(0, maxAllowedLength);
+ }
+
+ //
+ // Apply EndsWith if Provided ...
+ if (!endsWith.IsNullOrEmpty() &&
+ !result.EndsWith(endsWith))
+ {
+ result += endsWith;
+ }
+
+ //
+ return result;
+ }
+
///
/// Check an string is a Valid Representation of PhoneNumber ...
///
@@ -1080,6 +1147,49 @@ namespace xCommons.Extensions
//
return result;
}
+
+ ///
+ /// Converts a List String Representation to GUid List ...
+ ///
+ ///
+ ///
+ ///
+ public static IEnumerable ParseListGuid(
+ this string list,
+ char? separator = null
+ )
+ {
+ //
+ var result = new List();
+
+ //
+ if (!separator.HasValue)
+ {
+ separator = CommonConstants.DEFAULT_LIST_SEPERATOR;
+ }
+
+ //
+ if (list.IsNullOrEmpty())
+ {
+ return result;
+ }
+
+ //
+ var items = list.Split(separator.Value);
+ items.ToList().ForEach(i =>
+ {
+ //
+ if (!i.IsNullOrEmpty() && i.IsGuid() && !i.IsDefaultGuid())
+ {
+ //
+ var gID = new Guid(i);
+ result.Add(gID);
+ }
+ });
+
+ //
+ return result;
+ }
///
/// Convert a List to List String ...