diff --git a/Olive.Globalization/Html/EnglishSpelling.cs b/Olive.Globalization/Html/EnglishSpelling.cs
new file mode 100644
index 000000000..f569c90a3
--- /dev/null
+++ b/Olive.Globalization/Html/EnglishSpelling.cs
@@ -0,0 +1,76 @@
+using System.Collections.Generic;
+using System.Linq;
+using HtmlAgilityPack;
+
+namespace Olive.Globalization
+{
+ public class EnglishSpelling
+ {
+ string Original;
+ string[] ToReplace;
+ readonly Dictionary Map;
+
+ public EnglishSpelling(string htmlOrText, Dictionary map)
+ {
+ Original = htmlOrText.TrimOrEmpty();
+ Map = map;
+ if (Original.HasValue())
+ ToReplace = map.Where(v => Original.ContainsWholeWord(v.Key)).Select(v => v.Key).ToArray();
+ }
+
+ public static string ToBritish(string htmlOrText) => new EnglishSpelling(htmlOrText, SpellingMap.AmericanToBritish).Convert();
+ public static string ToAmerican(string htmlOrText) => new EnglishSpelling(htmlOrText, SpellingMap.BritishToAmerican).Convert();
+
+ public string Convert()
+ {
+ if (ToReplace.None() || Original.Lacks("<")) return Replace(Original);
+
+ var htmlDoc = new HtmlDocument();
+ htmlDoc.LoadHtml(Original);
+
+ Replace(htmlDoc.DocumentNode);
+
+ return htmlDoc.DocumentNode.InnerHtml;
+ }
+
+ void Replace(HtmlNode node)
+ {
+ node.ChildNodes.Do(Replace);
+
+ if (node.NodeType == HtmlNodeType.Text)
+ {
+ var to = node.InnerHtml;
+ if (to.ContainsAny(ToReplace))
+ node.InnerHtml = Replace(to);
+ }
+ }
+
+ string Replace(string text)
+ {
+ if (text.ContainsAny(ToReplace))
+ ToReplace.Do(v => text = text.ReplaceWholeWord(v, Map[v]));
+
+ return text;
+ }
+ }
+
+ static class SpellingMap
+ {
+ public readonly static Dictionary AmericanToBritish, BritishToAmerican;
+
+ static SpellingMap()
+ {
+ AmericanToBritish = ConvertIze();
+ AmericanToBritish.Add(Others());
+ BritishToAmerican = AmericanToBritish.ToDictionary(v => v.Value, v => v.Key);
+ }
+
+ static Dictionary ConvertIze() => "accessorize,acclimatize,acclimatized,acclimatizes,acclimatizing,actualize,agonize,agonized,agonizes,agonizing,alphabetize,americanize,amortize,anaesthetize,anglicize,antagonize,antagonized,antagonizes,antagonizing,apologize,apologized,apologizes,apologizing,apostrophize,atomize,authorize,authorized,authorizes,authorizing,baptize,baptized,baptizes,baptizing,bastardize,brutalize,brutalized,cannibalize,canonize,capitalize,capitalized,capitalizes,capitalizing,carbonize,carburize,categorize,categorized,categorizing,cauterize,cauterized,cauterizes,cauterizing,centralize,centralized,characterize,characterized,characterizes,characterizing,civilize,civilized,civilizes,civilizing,colonize,colonized,colonizes,colonizing,commercialize,commercialized,compartmentalize,compartmentalized,compartmentalizing,contextualize,contextualized,criminalize,criminalizing,criticize,criticized,criticizes,criticizing,crystallize,crystallized,crystallizes,crystallizing,customize,customized,decarbonize,decentralize,decentralized,decimalize,dehumanize,delegitimize,demobilize,democratize,democratized,democratizing,demonize,demonized,demonizing,demoralize,demoralized,denationalize,deputize,destabilize,digitize,digitized,diphthongize,dramatize,dramatized,dramatizes,dramatizing,economize,economized,economizes,economizing,empathize,energize,energized,energizes,energizing,epitomize,epitomized,epitomizes,epitomizing,equalize,equalizing,eulogize,eulogized,eulogizes,eulogizing,europeanize,evangelize,evangelized,evangelizes,evangelizing,extemporize,extemporized,extemporizes,extemporizing,externalize,factorize,familiarize,feminize,fertilize,fertilized,fertilizes,fertilizing,fetishize,fictionalize,fictionalized,focalize,formalize,formalized,fossilize,fraternize,fraternized,fraternizes,fraternizing,galvanize,galvanized,galvanizes,galvanizing,generalize,generalized,generalizes,generalizing,glamorize,globalize,globalized,harmonize,harmonized,harmonizes,harmonizing,hospitalize,humanize,humanizes,humanizing,hybridize,hypnotize,hypnotized,idealize,idealized,idealizes,idealizing,idolize,idolized,idolizing,immobilize,immortalize,immunize,incentivize,incentivized,individualize,individualized,industrialize,industrialized,institutionalize,internalize,internalized,internalizing,internationalize,italicize,itemize,jeopardize,jeopardized,jeopardizes,jeopardizing,legalize,legalized,legalizes,legalizing,legitimize,legitimized,legitimizes,legitimizing,liberalize,liberalized,liberalizes,liberalizing,lionize,liquidize,localize,localized,localizes,localizing,magnetize,magnetized,magnetizes,magnetizing,marginalize,marginalized,materialize,materialized,materializes,maximize,maximized,maximizes,maximizing,mechanize,memorialize,memorize,memorized,memorizes,memorizing,mesmerize,mesmerized,mesmerizes,mesmerizing,metabolize,minimize,minimized,minimizes,minimizing,mobilize,mobilized,mobilizes,mobilizing,modernize,modernized,modernizes,modernizing,moisturize,moisturized,moisturizing,monetize,monetized,monetizing,monopolize,monopolized,monopolizes,monopolizing,moralize,moralized,moralizes,moralizing,nasalize,nationalize,naturalize,naturalized,neutralize,neutralized,neutralizes,neutralizing,nominalize,normalize,normalized,normalizing,optimize,optimized,optimizing,organize,organized,organizes,organizing,ostracize,ostracized,ostracizes,ostracizing,oxidize,oxidized,oxidizes,oxidizing,palatalize,particularize,pasteurize,patronize,patronized,patronizes,patronizing,pedestrianize,penalize,penalized,penalizes,penalizing,personalize,personalized,personalizing,philosophize,picturize,plagiarize,plagiarized,plagiarizes,plagiarizing,pluralize,polarize,polarized,polarizing,politicize,politicized,polymerize,popularize,popularized,popularizes,popularizing,prioritize,prioritized,prioritizes,prioritizing,privatize,privatized,privatizing,proselytize,proselytized,proselytizes,proselytizing,publicize,publicized,publicizing,pulverize,pulverized,pulverizes,pulverizing,radicalize,radicalized,rationalize,rationalized,rationalizes,rationalizing,realize,realized,realizes,realizing,reauthorize,reauthorized,recognize,recognized,recognizes,recognizing,regularize,reorganize,reorganized,reorganizes,reorganizing,revitalize,revitalized,revitalizes,revitalizing,revolutionize,revolutionized,revolutionizes,revolutionizing,rhapsodize,romanticize,romanticized,romanticizing,satirize,satirized,satirizing,scandalize,scandalized,scandalizes,scandalizing,schematize,scrutinize,scrutinized,scrutinizes,scrutinizing,secularize,sensationalize,sensationalized,sensitize,sensitized,sentimentalize,sermonize,sexualize,socialize,socialized,socializing,solemnize,soliloquize,specialize,specialized,specializes,specializing,stabilize,stabilized,stabilizes,stabilizing,standardize,standardized,sterilize,sterilized,sterilizes,sterilizing,stigmatize,stigmatized,stigmatizes,stigmatizing,subsidize,subsidized,subsidizes,subsidizing,summarize,summarized,summarizes,summarizing,symbolize,symbolized,symbolizes,symbolizing,sympathize,sympathizing,synchronize,synchronized,synchronizes,synchronizing,systematize,tantalize,tantalized,tantalizes,tantalizing,temporize,temporized,temporizes,temporizing,terrorize,terrorized,terrorizes,terrorizing,theorize,theorized,theorizes,theorizing,tranquillize,tranquillized,tranquillizes,tranquillizing,trivialize,trivialized,tyrannize,tyrannized,tyrannizes,tyrannizing,unauthorized,uncivilized,utilize,utilized,utilizes,utilizing,vaporize,vaporized,vaporizes,vaporizing,verbalize,victimize,victimized,victimizes,victimizing,visualize,visualized,visualizes,visualizing,vocalize,vulgarize"
+ .Split(',').SelectMany(x => new[] { x, x[0].ToUpper() + x.Substring(1) })
+ .ToDictionary(x => x, x => x.Replace("z", "s"));
+
+ static Dictionary Others() => "aging:ageing|aluminum:aluminium|catalog:catalogue|cataloged:catalogued|cataloging:cataloguing|catalogs:catalogues|center:centre|centered:centred|centering:centring|centers:centres|check:cheque|checked:chequed|checking:chequing|checks:cheques|color:colour|colored:coloured|coloring:colouring|colors:colours|curb:kerb|curbed:kerbed|curbing:kerbing|curbs:kerbs|defense:defence|defenses:defences|draft:draught|drafted:draughted|drafting:draughting|drafts:draughts|dreamed:dreamt|enroll:enrol|enrolls:enrols|favorite:favourite|favorites:favourites|fiber:fibre|fibers:fibres|fulfill:fulfil|fulfills:fulfils|gray:grey|grayed:greyed|graying:greying|grays:greys|jewelry:jewellery|labor:labour|labored:laboured|laboring:labouring|labors:labours|license:licence|licensed:licenced|licenses:licences|licensing:licencing|maneuver:manoeuvre|maneuvered:manoeuvred|maneuvering:manoeuvring|maneuvers:manoeuvres|meter:metre|metered:metred|metering:metring|meters:metres|mold:mould|molded:moulded|molding:moulding|molds:moulds|neighbor:neighbour|neighbored:neighboured|neighboring:neighbouring|neighbors:neighbours|offense:offence|offenses:offences|pajamas:pyjamas|plow:plough|plowed:ploughed|plowing:ploughing|plows:ploughs|practice:practise|practiced:practised|practices:practises|practicing:practising|program:programme|programs:programmes|skillful:skilful|spelled:spelt|sulfur:sulphur|sulfured:sulphured|sulfuring:sulphuring|sulfurs:sulphurs|theater:theatre|theaters:theatres|toward:towards|traveler:traveller|travelers:travellers"
+ .Split('|').Distinct().Select(c => c.Split(':')).ToDictionary(x => x[0], x => x[1]);
+ }
+
+}
diff --git a/Olive.Globalization/Olive.Globalization.csproj b/Olive.Globalization/Olive.Globalization.csproj
index f1f178a4e..72aa64dbb 100644
--- a/Olive.Globalization/Olive.Globalization.csproj
+++ b/Olive.Globalization/Olive.Globalization.csproj
@@ -1,11 +1,11 @@
netstandard2.0
- 2.1.114
+ 2.1.116
-
+
diff --git a/Olive/-Extensions/Async/Linq.SpecialCollectionTypes.Async.cs b/Olive/-Extensions/Async/Linq.SpecialCollectionTypes.Async.cs
index 423efdebb..f2880a54e 100644
--- a/Olive/-Extensions/Async/Linq.SpecialCollectionTypes.Async.cs
+++ b/Olive/-Extensions/Async/Linq.SpecialCollectionTypes.Async.cs
@@ -377,6 +377,12 @@ public static Task> Concat(this Task> Concat(this Task @this, Task other) where TOther : IEnumerable
=> @this.Get(async x => x.Concat(await other));
+ public static Task> Prepend(this Task @this, TOther other) where TOther : IEnumerable
+ => @this.Get(x => x.Prepend(other));
+
+ public static Task> Prepend(this Task @this, Task other) where TOther : IEnumerable
+ => @this.Get(async x => x.Prepend(await other));
+
public static Task> Where(this Task @this, Func> predicate)
=> @this.Get(x => x.Where(predicate));
@@ -641,6 +647,12 @@ public static Task> Concat(this Task> Concat(this Task> @this, Task other) where TOther : IEnumerable
=> @this.Get(async x => x.Concat(await other));
+ public static Task> Prepend(this Task> @this, TOther other) where TOther : IEnumerable
+ => @this.Get(x => x.Prepend(other));
+
+ public static Task> Prepend(this Task> @this, Task other) where TOther : IEnumerable
+ => @this.Get(async x => x.Prepend(await other));
+
public static Task> Where(this Task> @this, Func> predicate)
=> @this.Get(x => x.Where(predicate));
@@ -905,6 +917,12 @@ public static Task> Concat(this Task> Concat(this Task> @this, Task other) where TOther : IEnumerable
=> @this.Get(async x => x.Concat(await other));
+ public static Task> Prepend(this Task> @this, TOther other) where TOther : IEnumerable
+ => @this.Get(x => x.Prepend(other));
+
+ public static Task> Prepend(this Task> @this, Task other) where TOther : IEnumerable
+ => @this.Get(async x => x.Prepend(await other));
+
public static Task> Where(this Task> @this, Func> predicate)
=> @this.Get(x => x.Where(predicate));
@@ -1169,6 +1187,12 @@ public static Task> Concat(this Task> Concat(this Task> @this, Task other) where TOther : IEnumerable
=> @this.Get(async x => x.Concat(await other));
+ public static Task> Prepend(this Task> @this, TOther other) where TOther : IEnumerable
+ => @this.Get(x => x.Prepend(other));
+
+ public static Task> Prepend(this Task> @this, Task other) where TOther : IEnumerable
+ => @this.Get(async x => x.Prepend(await other));
+
public static Task> Where(this Task> @this, Func> predicate)
=> @this.Get(x => x.Where(predicate));
diff --git a/Olive/-Extensions/Async/Linq.SpecialCollectionTypes.Async.tt b/Olive/-Extensions/Async/Linq.SpecialCollectionTypes.Async.tt
index 3fc9b686c..8da97c63f 100644
--- a/Olive/-Extensions/Async/Linq.SpecialCollectionTypes.Async.tt
+++ b/Olive/-Extensions/Async/Linq.SpecialCollectionTypes.Async.tt
@@ -285,6 +285,12 @@ namespace Olive
public static Task> Concat(this Task<<#=t#>> @this, Task other) where TOther : IEnumerable
=> @this.Get(async x => x.Concat(await other));
+ public static Task> Prepend(this Task<<#=t#>> @this, TOther other) where TOther : IEnumerable
+ => @this.Get(x => x.Prepend(other));
+
+ public static Task> Prepend(this Task<<#=t#>> @this, Task other) where TOther : IEnumerable
+ => @this.Get(async x => x.Prepend(await other));
+
public static Task> Where(this Task<<#=t#>> @this, Func> predicate)
=> @this.Get(x => x.Where(predicate));
diff --git a/Olive/-Extensions/Async/Linq.Task.Of.IEnumerable.cs b/Olive/-Extensions/Async/Linq.Task.Of.IEnumerable.cs
index 5f3ad8c4d..6d875a160 100644
--- a/Olive/-Extensions/Async/Linq.Task.Of.IEnumerable.cs
+++ b/Olive/-Extensions/Async/Linq.Task.Of.IEnumerable.cs
@@ -86,6 +86,10 @@ public static Task> Concat(
this Task> @this, TSource item)
=> @this.Get(x => x.OrEmpty().Concat(item));
+ public static Task> Prepend(
+ this Task> @this, TSource item)
+ => @this.Get(x => x.OrEmpty().Prepend(item));
+
public static Task> Distinct(
this Task> @this) => @this.Get(x => x.OrEmpty().Distinct());
diff --git a/Olive/-Extensions/Boolean.cs b/Olive/-Extensions/Boolean.cs
index 3d5d2ee18..a6ac84286 100644
--- a/Olive/-Extensions/Boolean.cs
+++ b/Olive/-Extensions/Boolean.cs
@@ -21,7 +21,7 @@ partial class OliveExtensions
/// The output string if this value is True. the default value is Yes.
/// The output string if this value is False.. the default value is No.
public static string ToYesNoString(this bool? value, string yes = "Yes", string no = "No") =>
- value.HasValue ? ToYesNoString(value.Value) : string.Empty;
+ value.HasValue ? ToYesNoString(value.Value, yes, no) : string.Empty;
///
/// Compares two Boolean object and returns 0 if both are equal.
diff --git a/Olive/-Extensions/DateTime.cs b/Olive/-Extensions/DateTime.cs
index a7fb7e19e..66daf7997 100644
--- a/Olive/-Extensions/DateTime.cs
+++ b/Olive/-Extensions/DateTime.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
+using System.Threading.Tasks;
namespace Olive
{
@@ -75,6 +76,9 @@ public static DateTime GetLast(this DateTime @this, DayOfWeek dayOfWeek, bool sk
}
}
+ public static async Task< string> ToString(this Task @this, string format)
+ => (await @this).ToString(format);
+
///
/// Determines whether this value is before than TimeSpan parameter
///
diff --git a/Olive/Olive.csproj b/Olive/Olive.csproj
index c7cc2bafe..b4f62985d 100644
--- a/Olive/Olive.csproj
+++ b/Olive/Olive.csproj
@@ -1,48 +1,50 @@
-
- netstandard2.0
- 2.1.383.0
- Library
- latest
-
-
-
- $(TargetDir)\Olive.xml
- TRACE;ProfileGCop
-
-
-
- Linq.SpecialCollectionTypes.Async.cs
- TextTemplatingFileGenerator
-
-
- TextTemplatingFileGenerator
- Linq.NumericIEnumerable.Async.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
- True
- Linq.NumericIEnumerable.Async.tt
-
-
- True
- True
- Linq.SpecialCollectionTypes.Async.tt
-
-
-
\ No newline at end of file