Alefair.Extended.Methods 1.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package Alefair.Extended.Methods --version 1.0.6                
NuGet\Install-Package Alefair.Extended.Methods -Version 1.0.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Alefair.Extended.Methods" Version="1.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Alefair.Extended.Methods --version 1.0.6                
#r "nuget: Alefair.Extended.Methods, 1.0.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Alefair.Extended.Methods as a Cake Addin
#addin nuget:?package=Alefair.Extended.Methods&version=1.0.6

// Install Alefair.Extended.Methods as a Cake Tool
#tool nuget:?package=Alefair.Extended.Methods&version=1.0.6                

Alefair.Extended.Methods

Extended Methods powered by Alefair

Current version 1.0.6

nuget on https://www.nuget.org


class StringExtended

  • Like
  • ContainsInList
  • ToDouble
  • ToDoubleStr
  • ToDecimal
  • ToDecimalStr
  • GetSimilarity
  • DictToString
  • DictToJson
  • DateParse
  • Capitalize

class DataExtended (added 1.0.5)

  • ReadCSV
  • WriteCSV
  • AppendCSV

class ProcessExtended (added 1.0.6)

  • GetPid
  • Kill
  • GetWinHandle
  • GetMainWinHandle
  • GetWinTitle
  • GetProcess

class StringExtended


Like
/// <summary>
/// "String".Like("*ring*") -> true
/// </summary>
/// <param name="toSearch"></param>
/// <param name="toFind"></param>
/// <param name="RegOptions"></param>
/// <returns></returns>
public static bool Like(this string toSearch, string toFind, RegexOptions RegOptions = RegexOptions.IgnoreCase)

"123 456 789".Like("456") - > true
"123 456 789".Like("^456") -> false


ContainsInList
/// <summary>
/// "Hello, world!".ContainsInList(new List(){"world", "peace", "men"}) -> true
/// </summary>
/// <param name="toSearch"></param>
/// <param name="currentList"></param>
/// <returns></returns>
public static bool ContainsInList(this string toSearch, List<string> currentList = default(List<string>))

"123 456 789".ContainsInList({"asd", "456", "ghj"})  - > true
"123 456 789".ContainsInList({"asd", "^456", "ghj"}) - > false


ToDouble
/// <summary>
/// "0,13".ToDouble() -> 0.13
/// "0,13".ToDouble(3) -> 0.130
/// </summary>
/// <param name="cdblString"></param>
/// <param name="Count"></param>
/// <returns></returns>
public static double ToDouble(this string cdblString, int Count = -1)

"123 456 789".ToDouble()         -> 123456789
"123 456 789.123456".ToDouble(2) -> 12346789.12


ToDoubleStr
/// <summary>
/// "0,13".ToDoubleStr() -> "0.13"
/// "0,13".ToDoubleStr("#.###") -> "0.130"
/// </summary>
/// <param name="cdblString"></param>
/// <param name="StringFormat"></param>
/// <returns></returns>
public static string ToDoubleStr(this string cdblString, string StringFormat = "*")

"123 456 789".ToDoubleStr()               -> "123456789"
"123 456 789.123456".ToDoubleStr("#.###") -> "123456789.123"


ToDecimal
/// <summary>
/// "0,13".ToDecimal() -> 0.13
/// "0,13".ToDecimal(3) -> 0.130
/// </summary>
/// <param name="decString"></param>
/// <param name="Count"></param>
/// <returns></returns>
public static decimal ToDecimal(this string decString, int Count = -1)

"123 456 789".ToDecimal()         -> 123456789
"123 456 789.123456".ToDecimal(2) -> 12346789.12


ToDecimalStr
/// <summary>
/// "0,13".ToDecimalStr() -> "0.13"
/// "0,13".ToDecimalStr("#.###") -> "0.130"
/// </summary>
/// <param name="decString"></param>
/// <param name="StringFormat"></param>
/// <returns></returns>
public static string ToDecimalStr(this string decString, string StringFormat = "*")

"123 456 789".ToDecimalStr()               -> "123456789"
"123 456 789.123456".ToDecimalStr("#.###") -> "123456789.123"


GetSimilarity
/// <summary>
/// "hello, world".GetSimilarity("hello,men") -> 0.58 is percent accuracy
/// </summary>
/// <param name="toSearch"></param>
/// <param name="toFind"></param>
/// <returns></returns>
public static Single GetSimilarity(this string toSearch, string toFind)

"123 456 789".GetSimilarity("123456 789") -> 0.9090909 - 91% accuracy
"123 456 789".GetSimilarity("123456789")  -> 0.8181818 - 82% accuracy


DictToString
/// <summary>
/// dict.DictToString() -> {"4"="a","5"="b"}
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="dictionary"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static string DictToString<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)

(new Dictionary<string, object>() {{"a","1"}, {"b", 1}}).DictToString ->  "{\"a\"=\"1\",\"b\"=\"1\"}"


DictToJson
/// <summary>
/// dict.DictToJson() -> {4:"a", 5:"b"}
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="dictionary"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static JObject DictToJson<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)

(new Dictionary<string, object>() {{"a","1"}, {"b", 1}}).DictToJson ->  {"a":"1","b"=1}


DateParse
/// <summary>
/// "10.07.2022".DateParse() -> 07/10/2022 00:00:00
/// </summary>
/// <param name="date"></param>
/// <param name="listFormat"></param>
/// <returns></returns>
public static DateTime DateParse(this string date, string[] listFormat = null)

"10.07.2022".DateParse()                                     -> 07/10/2022 00:00:00
"7/10/22".DateParse({"M/dd/yy", "dd.MM.yyyy", "MM/dd/yyyy"}) -> 07/10/2022 00:00:00

Capitalize
/// <summary>
/// 
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string Capitalize(this string s)

"this text".Capitalize() -> "This text"

class DataExtended


ReadCSV
/// <summary>
/// 
/// </summary>
/// <param name="FilePath"></param>
/// <param name="DelimiterType"></param>
/// <param name="Encoding"></param>
/// <param name="HasHeaders"></param>
/// <param name="IgnoreQuotes"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static DataTable ReadCSV(string FilePath, Delimiter Delimiter = Delimiter.Semicolon, string Encoding = "", bool HasHeaders = false, bool IgnoreQuotes = false)
   
sFileName = "C:\Temp\test.csv";

dt = ReadCSV(sFileName);

-> dt as DataTable


WriteCSV
/// <summary>
/// 
/// </summary>
/// <param name="FilePath"></param>
/// <param name="data"></param>
/// <param name="DelimiterType"></param>
/// <param name="Encoding"></param>
/// <param name="HasHeaders"></param>
/// <returns></returns>
public static bool WriteCSV(string FilePath, DataTable data, Delimiter DelimiterType = Delimiter.Semicolon, string Encoding = "", bool HasHeaders = false)

sFileName = "C:\Temp\test.csv";

WriteCSV(sFileName);

-> file csv


AppendCSV
/// <summary>
/// 
/// </summary>
/// <param name="FilePath"></param>
/// <param name="data"></param>
/// <param name="DelimiterType"></param>
/// <param name="Encoding"></param>
/// <returns></returns>
public static bool AppendCSV(string FilePath, DataTable data, Delimiter DelimiterType = Delimiter.Semicolon, string Encoding = "")

sFileName = "C:\Temp\test.csv";

AppendCSV(sFileName);

-> file csv


class ProcessExtended


GetPid
/// <summary>
/// 
/// </summary>
/// <param name="processname"></param>
/// <param name="title"></param>
/// <param name="handle"></param>
/// <returns></returns>
public static int GetPid(this string processname, string title = "", IntPtr? handle = null)
   
iPID = "notepad".GetPid()
-> 12456

iPID = "notepad".GetPid("unti*")
-> 12456

iPID = "notepad".GetPid("", 78451689)
-> 12456


Kill
/// <summary>
/// 
/// </summary>
/// <param name="processname"></param>
/// <param name="title"></param>
/// <param name="pid"></param>
/// <returns></returns>
/// <exception cref="ApplicationException"></exception>
public static bool Kill(this string processname, string title = "", int pid = -1)
   
"notepad".Kill()
-> true

"notepad".Kill("untit*")
-> true

"notepad".Kill("", 12456)
-> true


GetWinHandle
/// <summary>
/// 
/// </summary>
/// <param name="processname"></param>
/// <param name="title"></param>
/// <returns></returns>
public static IntPtr GetWinHandle(this string processname, string title = "")
   
hwnd = "notepad".GetWinHandle()
-> 78451689

hwnd = "notepad".GetWinHandle("untit*")
-> 78451689


GetMainWinHandle
/// <summary>
/// 
/// </summary>
/// <param name="processname"></param>
/// <param name="title"></param>
/// <returns></returns>
public static IntPtr GetMainWinHandle(this string processname, string title = "")
   
hwnd = "notepad".GetMainWinHandle()
-> 78451689

hwnd = "notepad".GetMainWinHandle("untit*")
-> 78451689


GetWinTitle
/// <summary>
/// 
/// </summary>
/// <param name="processname"></param>
/// <param name="pid"></param>
/// <returns></returns>
public static string GetWinTitle(this string processname, int pid = -1)
   
sTitle = "notepad".GetWinTitle()
-> "Untitled - Notepad"

sTitle = "notepad".GetWinTitle(12456)
-> "Untitled - Notepad"


GetProcess
/// <summary>
/// 
/// </summary>
/// <param name="processname"></param>
/// <param name="title"></param>
/// <param name="pid"></param>
/// <returns></returns>
public static Process GetProcess(this string processname, string title = "", int pid = -1)
   
sTitle = "notepad".GetProcess()
-> Process <Notepad.exe, "Untitled - Notepad">

sTitle = "notepad".GetProcess("untitl*")
-> Process <Notepad.exe, "Untitled - Notepad">

sTitle = "notepad".GetProcess("", 12456)
-> Process <Notepad.exe, "Untitled - Notepad">


Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.12 363 12/28/2022
1.0.6 447 9/20/2022
1.0.5 418 9/20/2022
1.0.4 693 9/18/2022
1.0.3 411 9/8/2022
1.0.1 428 8/20/2022