Skip to content

marlond18/EMDD.Kt.Extensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nuget

EMDD.Kt.Extensions

Collection of Extension methods


Requirements

Use .net5.0.

Usage

Package Manager PM> Install-Package EMDD.Kt.Extensions -Version 1.0.0.1 .NET CLI dotnet add package EMDD.Kt.Extensions --version 1.0.0.1

Array2D

Collection of methods to deal with 2D array

Aggregate<T , TQ>(arr, initial, func)

Loop Through a 2d array

Name Description
arr 2D array to work with
initial initial Value to work with the aggregate method
func function to work for each cycle

Type Parameters

  • T - base
  • TQ - target

Returns

an equivalent array of TQ[,]

All(array, func)

All - Extension for 2D array

Type Parameters

  • T -
Name Description
array 2D array of T to work with
func Predicate to check

System.NullReferenceException: Method Cannot be null

Returns

DeleteCol(arr, index)

Delete the column of an array

Name Description
arr 2D Array to work with
index index of column to delete

Type Parameters

  • T -

Returns

DeleteCol(arr, indices)

Delete multiple col of a 2d Array

Type Parameters

  • T -
Name Description
arr 2D Array to work with
indices array of column indices to delete

Returns

DeleteRow(arr, index)

Delete the row of 2 dimensional array

Name Description
arr 2D Array to work with
index index of the row to delete

Type Parameters

  • T -

Returns

DeleteRow(arr, indices)

Delete multiple row of a 2d Array

Type Parameters

  • T -
Name Description
arr 2D Array to work with
indices row indices to delete

Returns

ForEach(arr, action)

Loop Through a 2d array without any returns

Name Description
arr 2D Array to work with
action Action to run for each element

Type Parameters

  • T -

Returns

ForEachCol(mat, rowIndex, action)

Call a Foreach Col method on Matrix

Type Parameters

  • T -
Name Description
arr 2D Array to work with
rowIndex zero-based index of row to work with
action System.Int32

ForEachCol<Tin,Tout>(mat, rowIndex, func)

ForEach Col with return type

Type Parameters

  • Tin -
  • Tout -
Name Description
mat 2D Array to work with
rowIndex zero-based index of row to work with
func function to run each element

System.ArgumentNullException: func can't be null

Returns

ForEachRow(mat, colIndex, action)

Call a ForEach Row method on Matrix

Type Parameters

  • T -
Name Description
mat 2D Array
colIndex 0:]
zero-based index
action System.Int32

ForEachRow<Tin,Tout>(mat, colIndex, func)

ForEach Row with return type

Type Parameters

  • Tin -
  • Tout -
Name Description
mat 2D Array
colIndex 0:]
zero-based
func System.Int32

System.ArgumentNullException: func can't be null

Returns

GetBounds(mat, dimension)

Get RowBounds

Type Parameters

  • T -
Name Description
mat 2D Array
dimension 0:]

Returns

HasAny(matrix)

Check if a 2D array has data

Type Parameters

  • T -
Name Description
matrix 2D Array

Returns

IndexIsOutOfBound(matrix, index, dimension)

Check if an index is out of bound from an array 2D

Type Parameters

  • T -
Name Description
matrix 2D Array
index 0:]
dimension System.Int32

Returns

Select<T,TQ>(arr, func)

Loop Through a 2d array

Name Description
arr 2D Array
func 0:]

Type Parameters

  • T -
  • TQ -

Returns

Select<T,TQ>(arr, func)

Loop Through a 2d array

Name Description
arr 2D Array
func 0:]

Type Parameters

  • T -
  • TQ -

Returns

SelectCol(matrix, index)

Get the col

Type Parameters

  • T -
Name Description
matrix 2D Array
index 0:]

Returns

SelectCol<Tresult,Tbase>(matrix, index, func)

Get col and apply some modifications

Type Parameters

  • Tresult -
  • Tbase -
Name Description
matrix [0:
index 0:]
func System.Int32

Returns

SelectCols<TBase,TResult>(array, func)

Cast the column of the two dimensional array using a function, func

Type Parameters

  • TBase -
  • TResult -
Name Description
array 2D Array
func 0:]

Returns

The result is an System.Collections.Generic.IEnumerable`1

SelectCols<TBase,TInnnerResult,TResult>(array, InnerFunc, func)

Cast the column of the two dimensional array using a function, func

Type Parameters

  • TBase -
  • TInnerResult -
  • TResult -
Name Description
array 2D Array
InnerFunc 0:]
func System.Func{``0,}

Returns

The result is an System.Collections.Generic.IEnumerable`1

SelectRow(matrix, index)

Get the row

Type Parameters

  • T -
Name Description
matrix 2D Array
index 0:]

Returns

SelectRow``2(matrix, index, func)

Get row and apply some modifications

Type Parameters

  • Tresult -
  • Tbase -
Name Description
matrix [0:
index 0:]
func System.Int32

Returns

SelectRows``2(array, func)

Cast the row of the two dimensional array using a function, func

Type Parameters

  • TBase -
  • TResult -
Name Description
array 2D Array
func 0:]

Returns

The result is an System.Collections.Generic.IEnumerable`1

SelectRows``3(array, InnerFunc, func)

modify element in row, modify row and return as an ienumerable

Type Parameters

  • TBase -
  • TInnerResult -
  • TResult -
Name Description
array 2D Array
InnerFunc 0:]
func System.Func{``0,}

Returns

SequenceEqual(arr1, arr2)

Check if Two 2d array are equal

Name Description
arr1 2D Array
arr2 0:]

Type Parameters

  • T -

Returns

Size(array)

Get the size of a two dimensional array, array, of type T

Type Parameters

  • T -
Name Description
array 2D Array

Returns

System.ValueTuple of (System.Int32 row, System.Int32 col)

SwapCol(arr, index1, index2)

swap columns of a 2 dimensional matrix

Name Description
arr 2D Array
index1 0:]
index of column 1
index2 System.Int64
index of column 2

Type Parameters

  • T -

Returns

SwapColInternal(arr, index1, index2)

swap columns of a 2 dimensional matrix

Name Description
arr 2D Array
index1 0:]
index of column 1
index2 System.Int64
index of column 2

Type Parameters

  • T -

Returns

SwapRow(arr, index1, index2)

swap rows of a 2 dimensional matrix

Name Description
arr 2D Array
index1 0:]
index of row 1
index2 System.Int64
index of row 2

Type Parameters

  • T -

Returns

SwapRowInternal(arr, index1, index2)

swap rows of a 2 dimensional matrix

Name Description
arr 2D Array
index1 0:]
index of row 1
index2 System.Int64
index of row 2

Type Parameters

  • T -

Returns

TabbedToString(arr)

Convert the array in a tabulated string format

Type Parameters

  • T -
Name Description
arr 2D Array

Returns

ToDictionary(matrix)

Convert Matrix to Dictionary

Type Parameters

  • T -
Name Description
matrix 2D Array

Returns

first row is the ket and the rest are stored on an array

System.IndexOutOfRangeException: Error for less than 2D Array

ToDictionary``2(array1, array2)

ToDictionary with same return type

Type Parameters

  • T1 -
  • T2 -
Name Description
array1 2D Array
array2 0:]

Returns

ToDictionary``2(array1, array2)

Tranform 2 Column Matrices into Dictionary

Type Parameters

  • T1 -
  • T2 -
Name Description
array1 System.Object[0:
array2 0:]

Returns

ToDictionary``2(arrays)

Extension of type method of ToDictionary

Type Parameters

  • T1 -
  • T2 -
Name Description
arrays System.ValueTuple{``0[0:,0:],[0:,0:]}

Returns

ArrayExtensions

extending the static methods of Array abstract class

Add(arr, toAdd)

Add an item to the existing array but creates a new array.

Name Description
arr ``0[]
toAdd ``0

Type Parameters

  • T -

Returns

Clone(arrayToClone)

Deep Clone a array

Name Description
arrayToClone ``0[]

Type Parameters

  • T -

Returns

Find(array, match)

extending Find method in Array

Type Parameters

  • T -
Name Description
array ``0[]
match System.Predicate{``0}

Returns

RemoveAt(arr, index)

Array version of List.RemoveAt

Name Description
arr ``0[]
index System.Int32

Type Parameters

  • T -

Returns

System.NullReferenceException: throws exception if array is null

System.Exception: throws exception of array is of zero length

BigIntegerExtensions

Extensions for BigInteger

Factor(i)

Exhaust All Factor of a BigInteger

Name Description
i System.Numerics.BigInteger

Returns

PerfectSqr(A)

Determine if a number is perfect sqaure

Name Description
A System.Numerics.BigInteger

Root(base, n)

Get the root of a BigInteger

Name Description
base System.Numerics.BigInteger
n System.Int32

System.ArgumentException: root cannot be less than zero

System.ArgumentException: negative value root base 2

Sqrt(number)

Get the Sqrt of BigInteger

Name Description
number System.Numerics.BigInteger

System.ArgumentException: number cannot be less than zero

CharExtensions

Extensions for Characters

CollectionEqComparerUnarranged`1

Comparer for Collection Unarranged

Type Parameters

  • T -

Equals(x, y)

Equality

Name Description
x System.Collections.Generic.IEnumerable{`0}
y System.Collections.Generic.IEnumerable{`0}

Returns

GetHashCode(obj)

Hashcode

Name Description
obj System.Collections.Generic.IEnumerable{`0}

Returns

DateExtensions

Extensions for dates

EndOfWeek(dt, endOfWeek)

Get the end date of the week of a datetime

Name Description
dt System.DateTime
endOfWeek System.DayOfWeek

Returns

IsBetweenDays(current, start, end, excludeBounds)

Check if a date is between two spans ( excluding the time)

Name Description
current System.DateTime
start System.DateTime
end System.DateTime
excludeBounds System.Boolean

Returns

IsTimeSensitiveBetween(current, start, end, excludeBounds)

Check if a date is between two spans ( including thee relevant time)

Name Description
current System.DateTime
start System.DateTime
end System.DateTime
excludeBounds System.Boolean

Returns

Months(date)

Return the total months of a datetime

Name Description
date System.DateTime

Returns

StartOfWeek(dt, startOfWeek)

Get the start date of the week a datetime

Name Description
dt System.DateTime
startOfWeek System.DayOfWeek

Returns

Weeks(date)

Get Total Weeks of a datetime

Name Description
date System.DateTime

Returns

DiagnosticsExtensions

Extensions for Diagnostics

ElapsedTime(action)

Get Elapsed time for action

Name Description
action System.Action

Returns

DoubleComparer

Compare double data type

Equals(x, y)

Determines whether the specified objects are equal.

Returns

true if the specified objects are equal; otherwise, false.

Name Description
x System.Double
The first object of type to compare.
y System.Double
The second object of type to compare.

GetHashCode(obj)

Returns a hash code for the specified object.

Returns

A hash code for the specified object.

Name Description
obj System.Double
The System.Object for which a hash code is to be returned.

System.ArgumentNullException: The type of obj is a reference type and obj is null.

EnumerableExtensions

Extensions for Ienumerable

AggregatePartition``3(collection, getKey, getValue, func)

Partition collection and aggregate Results stored in a dictionary

Type Parameters

  • TBase -
  • TKey -
  • TValue -
Name Description
collection System.Collections.Generic.IEnumerable{``0}
getKey System.Func{``0,}
getValue System.Func{``0,``2}
func System.Func{``2,``2,``2}

Returns

AggregatePartition``4(collection, getKey, comparer, getValue, func)

Partition collection and aggregate Results stored in a dictionary

Type Parameters

  • TBase -
  • TKey -
  • TComparer -
  • TValue -
Name Description
collection System.Collections.Generic.IEnumerable{``0}
getKey System.Func{``0,}
comparer ``2
getValue System.Func{``0,``3}
func System.Func{``3,``3,``3}

Returns

AggregatePartition``4(collection, getKey, getValue, func, getOutput)

Partition collection and aggregate Results

Type Parameters

  • TBase -
  • TKey -
  • TValue -
  • TResult -
Name Description
collection System.Collections.Generic.IEnumerable{``0}
getKey System.Func{``0,}
getValue System.Func{``0,``2}
func System.Func{``2,``2,``2}
getOutput System.Func{,``2,``3}

Returns

AggregatePartition``5(collection, getKey, comparer, getValue, func, getOutput)

Partition collection and aggregate Results

Type Parameters

  • TBase -
  • TKey -
  • TComparer -
  • TValue -
  • TResult -
Name Description
collection System.Collections.Generic.IEnumerable{``0}
getKey System.Func{``0,}
comparer ``2
getValue System.Func{``0,``3}
func System.Func{``3,``3,``3}
getOutput System.Func{,``3,``4}

Returns

AggregateSelect``2(enumerable, seed, func)

Combined Aggregate and Select

Type Parameters

  • TBase -
  • TResult -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
seed
func System.Func{,``0,}

Returns

AnyExcept(source, except, func)

Similar to Ienumerable.Any() but excludes checking a certain element

Type Parameters

  • T -
Name Description
source System.Collections.Generic.IEnumerable{``0}
except ``0
Excluded Element
func System.Func{``0,System.Boolean}

Returns

Concat(enumerable, toConCat)

Extended Concat Method where the enumerable to be concatenated is params

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
toConCat System.Collections.Generic.IEnumerable{``0}[]

Returns

ContentEquals(a, b)

Determine if two collections have the same content

Type Parameters

  • T -
Name Description
a System.Collections.Generic.IEnumerable{``0}
b System.Collections.Generic.IEnumerable{``0}

Returns

Cross``3(col1, col2, func)

Select + Select Many/ Nested Linq from - operator for two collections

Type Parameters

  • T1 -
  • T2 -
  • TResult -
Name Description
col1 System.Collections.Generic.IEnumerable{``0}
col2 System.Collections.Generic.IEnumerable{}
func System.Func{``0,,``2}

Returns

FilterSuggestion(items, keyword, propertyName)

Use the whole word as suggestion

Name Description
items System.Collections.IEnumerable
keyword System.String
propertyName System.String

Returns

FilterSuggestions(items, keyword, propertyName)

Search filter ienumerable

Name Description
items System.Collections.IEnumerable
keyword System.String
propertyName System.String

Returns

FirstOfBoth``2(pair, func)

Get the first item on both enumerable that satifies the boolean function

Type Parameters

  • Tfirst -
  • Tsecond -
Name Description
pair System.ValueTuple{System.Collections.Generic.IEnumerable{``0}
func System.Collections.Generic.IEnumerable{}}

Returns

Fork(source, pred)

Two way fork by using Ternary conditions

Type Parameters

  • T -
Name Description
source System.Collections.Generic.IEnumerable{``0}
pred System.Func{``0,KtExtensions.EnumerableExtensions.Ternary}

Returns

Fork(source, pred)

Splits an ienumerable in two based on the boolean condition stated,

Reference:

Byers, M (2010,December 28) C#: Can I split an IEnumerable into two by a boolean criteria without two queries? [Online forum comment].Message to posted to https://stackoverflow.com/questions/4549339/can-i-split-an-ienumerable-into-two-by-a-boolean-criteria-without-two-queries

Type Parameters

  • T - Type
Name Description
source System.Collections.Generic.IEnumerable{``0}
the Ienumerable to be split
pred System.Func{``0,System.Boolean}
boolean condition

Returns

value tuple 2 two groups

Has(enumerable, itemToFind)

Works like LInq Contains

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
itemToFind ``0

Returns

HeuristicallyDetermineType(myList)

Get the Underlaying type of items inside an Ilist

Name Description
myList System.Collections.IList

Returns

IsEmpty(enumerable)

Check if a collection contains any data

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}

Returns

MakeEnumerable(enumerable)

boxing of any enumerable to it's interface equivalence

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}

Returns

MinMax(enumerable, IsLesser, IsGreater)

Get the minimum and maximum value of enumerable based on IsLesser and IsGreater

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
IsLesser System.Func{``0,``0,System.Boolean}
Check if a value is lesser that another
IsGreater System.Func{``0,``0,System.Boolean}
Check if a value is greater that another

Returns

MinMax(enumerable, func)

Determine where the min and max value of T resulting to double, from an ienumerable enumerable

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
func System.Func{``0,System.Double}
function to convert the item T to a System.Double

Returns

MinMax(enumerable, func)

Determine where the min and max value of T resulting to double, from an ienumerable enumerable

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
func System.Func{``0,System.Int32}
function to convert the item T to a System.Int32

Returns

OfType``2(main)

Ienumerable.OfType but takes two type signature

Type Parameters

  • T1 -
  • T2 -
Name Description
main System.Collections.IEnumerable

Returns

OfType``3(main)

Ienumerable.OfType but takes three type signature

Type Parameters

  • T1 -
  • T2 -
  • T3 -
Name Description
main System.Collections.IEnumerable

Returns

OfType``4(main)

Ienumerable.OfType but takes four type signature

Type Parameters

  • T1 -
  • T2 -
  • T3 -
  • T4 -
Name Description
main System.Collections.IEnumerable

Returns

OfType``5(main)

Ienumerable.OfType but takes five type signature

Type Parameters

  • T1 -
  • T2 -
  • T3 -
  • T4 -
  • T5 -
Name Description
main System.Collections.IEnumerable

Returns

OfType``6(main)

Ienumerable.OfType but takes six type signature

Type Parameters

  • T1 -
  • T2 -
  • T3 -
  • T4 -
  • T5 -
  • T6 -
Name Description
main System.Collections.IEnumerable

Returns

OfType``7(main)

Ienumerable.OfType but takes 7 type signature

Type Parameters

  • T1 -
  • T2 -
  • T3 -
  • T4 -
  • T5 -
  • T6 -
  • T7 -
Name Description
main System.Collections.IEnumerable

Returns

OfType``8(main)

Ienumerable.OfType but takes 8 type signature

Type Parameters

  • T1 -
  • T2 -
  • T3 -
  • T4 -
  • T5 -
  • T6 -
  • T7 -
  • T8 -
Name Description
main System.Collections.IEnumerable

Returns

Partition``2(enumerable, func)

Partition

Type Parameters

  • T1 -
  • T2 -
Name Description
enumerable System.Collections.Generic.IEnumerable{}
func System.Func{,``0}

Returns

ReverseSelect``2(source, conversion, break, continue)

Reverse Select an Array

Type Parameters

  • TBase -
  • TResult -
Name Description
source ``0[]
conversion System.Func{``0,}
break System.Func{``0,System.Boolean}
continue System.Func{``0,System.Boolean}

Returns

ReverseSelect``2(source, conversion)

Reverse Select an Array

Type Parameters

  • TBase -
  • TResult -
Name Description
source ``0[]
conversion System.Func{``0,}

Returns

SelectPair(inum)

Return an ienumerable of a tuple paired for a successive items

Type Parameters

  • T -
Name Description
inum System.Collections.Generic.IEnumerable{``0}

Returns

SelectPair``2(inum, method)

IEnumerable Select But using successive pairs

Name Description
inum System.Collections.Generic.IEnumerable{``0}
method System.Func{``0,``0,}

Type Parameters

  • T -
  • TD -

Returns

System.NullReferenceException: method cannot be null

SplitFirst(source, predicate)

Find First and split it from the main enumerable

Type Parameters

  • T -
Name Description
source System.Collections.Generic.IEnumerable{``0}
predicate System.Func{``0,System.Boolean}

Returns

SplitTake(source, count)

Divide an ienumerable into two; first value's size is based on Count.

Type Parameters

  • T -
Name Description
source System.Collections.Generic.IEnumerable{``0}
count System.Int32

Returns

Ternary

3 boolean type

False

false

Neutral

nuetral

True

true

KtExtensions.EnumerableExtensions.Venn(AA, BB)

Venn Group Elements of two enumerables based on venn diagram rep

Type Parameters

  • T -
Name Description
AA System.Collections.Generic.IEnumerable{``0}
BB System.Collections.Generic.IEnumerable{``0}

Returns

KtExtensions.EnumerableExtensions.Venn(ienums, comparer)

Exclusion Inclusion of Elements of two collections

Type Parameters

  • T -
Name Description
ienums System.ValueTuple{System.Collections.Generic.IEnumerable{``0}
comparer System.Collections.Generic.IEnumerable{``0}}

Returns

KtExtensions.EnumerableExtensions.WhereNot(enumerable, other)

Exclude other from the query

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
other ``0

Returns

KtExtensions.EnumerableExtensions.WhereNot(enumerable, others)

Exclude others from the query

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
others System.Collections.Generic.IEnumerable{``0}

Returns

KtExtensions.EnumerableExtensions.WhereNot(enumerable, predicate)

same Linq -Where but the predicate is negated

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
predicate System.Predicate{``0}

Returns

EqualityExtensions

Collection of methods for equality purposes

ChainHashCode(hash, other, multiplier)

Chain the hashcode of the new item to the previous

Type Parameters

  • T -
Name Description
hash System.Int32
initial hash
other ``0
other item
multiplier System.Int32

Returns

ChainHashCode(hash, other)

Chain the hashcode of the new item to the previous

Type Parameters

  • T -
Name Description
hash System.Int32
initial hash
other ``0
other item

Returns

ChainHashCode(hash, other)

Chain the hashcode of the new item to the previous

Type Parameters

  • T -
Name Description
hash System.Int32
initial hash
other ``0[]
other item

Returns

ChainHashCode(hash, other)

Chain the hashcode of the new item to the previous

Type Parameters

  • T -
Name Description
hash System.Int32
initial hash
other System.Collections.Generic.IEnumerable{``0}
other item

Returns

DefaultEquals(a, b)

Shortened System.Collections.Generic.EqualityComparer`1.Default.Equals

Type Parameters

  • T -
Name Description
a ``0
b ``0

Returns

EqualsObject(a, obj, final)

Test if an element of type T is equal to an object

Type Parameters

  • T -
Name Description
a ``0
obj System.Object
final System.Func{``0,System.Boolean}

Returns

GetHashCodeOfArray(array)

Determine the hashcode of an array using EqualityExtensions.ChainHashCode(System.Int32,``0) method

Type Parameters

  • T -
Name Description
array ``0[]

Returns

GetHashCodeOfEnumerable(array)

Determine the hashcode of an enumerable using EqualityExtensions.ChainHashCode(System.Int32,``0) method

Type Parameters

  • T -
Name Description
array System.Collections.Generic.IEnumerable{``0}

Returns

TestNullBeforeEquals(a, b, final)

Test for null before doing the final equality check of final

Type Parameters

  • T -
Name Description
a ``0
b ``0
final System.Boolean

Returns

TestNullBeforeEquals(a, b, final)

Test for null before doing the final equality check of final

Type Parameters

  • T -
Name Description
a ``0
b ``0
final System.Func{``0,System.Boolean}

Returns

TestNullBeforeEquals(a, b, final)

Test for null before doing the final equality check of final

Type Parameters

  • T -
Name Description
a ``0
b ``0
final System.Func{System.Boolean}

Returns

FilePathExtensions

Extensions for System.IO.File and System.IO.Path

CanReadFile(filePath)

Check if a file can be opened

Name Description
filePath System.String

CopyToUniqueName(source, filePathDestination)

extension of File.Copy where destination name will be made unique using FilePathExtensions.GetUniqueFilePath(System.String)

Name Description
source System.String
filePathDestination System.String

Returns

GetUniqueFilePath(filepath)

Make file path unique

Name Description
filepath System.String

Returns

GenericExtensions

Extensions for generic types

IsNull(value)

Check if a generic value of type T is null Reference: McGivern, D. (2011,Febuary 10) C#: Alternative to GenericType == null [Online forum comment].Message to posted to https://stackoverflow.com/questions/565564/c-alternative-to-generictype-null modification was done by using IsNullable() Method

Type Parameters

  • T -
Name Description
value ``0

Returns

MakeArrayFor(val, times)

Create an Array using the value with "times" size

Name Description
val ``0
times System.Int32
size of the array

Type Parameters

  • T -

Returns

MakeListFor(val, times)

Create a List using the value with "times" size

Name Description
val ``0
times System.Int32
size of the list

Type Parameters

  • T -

Returns

ListExtensions

List Extensions

Clone(listToClone)

Deep Clone a List

Name Description
listToClone System.Collections.Generic.List{``0}

Type Parameters

  • T -

Returns

FirstPair(listToLoop, test)

Determine the first pair in list that passed the test

Name Description
listToLoop System.Collections.Generic.List{``0}
test System.Func{``0,``0,System.Boolean}

Type Parameters

  • T -

Returns

if fails it returns null

FoundAt(list, item, comparer)

Find the Element and return its index

Type Parameters

  • T -
Name Description
list System.Collections.Generic.List{``0}
item ``0
comparer System.Collections.Generic.IEqualityComparer{``0}

Returns

FoundAt(list, item)

Find the Element and return its index using the Default Equality Comparer

Type Parameters

  • T -
Name Description
list System.Collections.Generic.List{``0}
item ``0

Returns

IndexedForEach(list, action)

Run for loop using action which takes in System.Int32 index and the item of T

Type Parameters

  • T -
Name Description
list System.Collections.Generic.List{``0}
action System.Action{``0,System.Int32}
is null, the method will not run

LoopTwoEach(null, listToLoop, action)

Loop through a List using the two consecutive elements

Name Description
System.Collections.Generic.List{``0}
listToLoop System.Action{``0,``0}
The list for looping, count must be beyond 2
action Unknown type

Type Parameters

  • T -

Swap(list, index1, index2)

swap elements of a List

Name Description
list System.Collections.Generic.List{``0}
index1 System.Int32
index of row 1
index2 System.Int32
index of row 2

Type Parameters

  • T -

Returns

MethodShortcuts

Improved Action methods

BoolAction(condition, ifTrue, ifFalse)

Runs based on a the condition of condition, runs ifTrue if condition is true and runs ifFalse if condition is false

Name Description
condition System.Boolean
ifTrue System.Action
ifFalse System.Action

Recursion(func)

Inception type of function. create a value null, assign a value

Type Parameters

  • T -
Name Description
func System.Func{System.Func{``0},``0}

Returns

SeedProcess``2(seed, result)

Chainable initial values to func

Type Parameters

  • Tseed -
  • Tresult -
Name Description
seed System.Func{``0}
result System.Func{``0,}

Returns

SeedProcess``3(seed1, seed2, result)

Chainable initial values to func

Type Parameters

  • Tseed1 -
  • Tseed2 -
  • Tresult -
Name Description
seed1 System.Func{``0}
seed2 System.Func{}
result System.Func{``0,,``2}

Returns

SeedProcess``3(seed, result)

Chainable initial values to func

Type Parameters

  • Tseed1 -
  • Tseed2 -
  • Tresult -
Name Description
seed System.Func{System.ValueTuple{``0,}}
result System.Func{``0,,``2}

Returns

SeedProcess``4(seed1, seed2, seed3, result)

Chainable initial values to func

Type Parameters

  • Tseed1 -
  • Tseed2 -
  • Tseed3 -
  • Tresult -
Name Description
seed1 System.Func{``0}
seed2 System.Func{}
seed3 System.Func{``2}
result System.Func{``0,,``2,``3}

Returns

SeedProcess``4(seed, result)

Chainable initial values to func: Tuple of 3

Type Parameters

  • Tseed1 -
  • Tseed2 -
  • Tseed3 -
  • Tresult -
Name Description
seed System.Func{System.ValueTuple{``0,,``2}}
result System.Func{``0,,``2,``3}

Returns

SeedProcess``5(seed1, seed2, seed3, seed4, result)

Chainable initial values to func

Type Parameters

  • Tseed1 -
  • Tseed2 -
  • Tseed3 -
  • Tseed4 -
  • Tresult -
Name Description
seed1 System.Func{``0}
seed2 System.Func{}
seed3 System.Func{``2}
seed4 System.Func{``3}
result System.Func{``0,,``2,``3,``4}

Returns

SeedProcess``5(seed, result)

Chainable initial values to func: Tuple of 4

Type Parameters

  • Tseed1 -
  • Tseed2 -
  • Tseed3 -
  • Tseed4 -
  • Tresult -
Name Description
seed System.Func{System.ValueTuple{``0,,``2,``3}}
result System.Func{``0,,``2,``3,``4}

Returns

SeedProcess``5(seed1, seed2, result)

Chainable initial values to func

Type Parameters

  • Tseed1 -
  • Tseed2 -
  • Tseed3 -
  • Tseed4 -
  • Tresult -
Name Description
seed1 System.Func{System.ValueTuple{``0,}}
seed2 System.Func{System.ValueTuple{``2,``3}}
result System.Func{``0,,``2,``3,``4}

Returns

SeedProcess``6(seed1, seed2, seed3, seed4, seed5, result)

Chainable initial values to func: 5 seed elements

Type Parameters

  • Tseed1 -
  • Tseed2 -
  • Tseed3 -
  • Tseed4 -
  • Tseed5 -
  • Tresult -
Name Description
seed1 System.Func{``0}
seed2 System.Func{}
seed3 System.Func{``2}
seed4 System.Func{``3}
seed5 System.Func{``4}
result System.Func{``0,,``2,``3,``4,``5}

Returns

SeedProcess``6(seed, result)

Chainable initial values to func: Tuple of 5

Type Parameters

  • Tseed1 -
  • Tseed2 -
  • Tseed3 -
  • Tseed4 -
  • Tseed5 -
  • Tresult -
Name Description
seed System.Func{System.ValueTuple{``0,,``2,``3,``4}}
result System.Func{``0,,``2,``3,``4,``5}

Returns

NumberDisplayExtensions

Extensions for converting numeric values to proper string format

ToExp(val)

Convert a number into string exponential form string

Name Description
val System.Double

Returns

NumericExtensions

Numeric Extensions

Atan3(y, x)

Return the angle in degrees

Name Description
y System.Double
numerator of the tangent function
x System.Double
denominator of the tangent function

Returns

Base10Of1stSignificantFigure(val)

get the decimal place of first significant figure

Name Description
val System.Double

Returns

CompareTo(values)

(v1,v2) => v1.CompareTo(v2)

Name Description
values System.ValueTuple{System.Double,System.Double}

Returns

CycleWithin(val1, val2, val3)

Used for looping through circular sequence

Name Description
val1 System.Double
The Number that loops
val2 System.Double
The Begining of the loop
val3 System.Double
The end of the loop

Returns

Looped equivalent of val1

CycleWithin(val1, val2, val3)

Used for looping through circular sequence

Name Description
val1 System.Int32
The Number that loops
val2 System.Int32
The Begining of the loop
val3 System.Int32
The end of the loop

Returns

Looped equivalent of val1

Exp(val1, val2)

multiply a number with 10 raised to ____

Name Description
val1 System.Double
val2 System.Double
Power of th multiplyier number "10"

Returns

Exp(val1, val2)

multiply a number with 10 raised to ____

Name Description
val1 System.Double
val2 System.Int32
Power of th multiplyier number "10"

Returns

GetPotentialNumber(val)

Check if a string can potentially be converted into number

Name Description
val System.String

Returns

HasDecimal(val)

Return if a double value has floating values

Name Description
val System.Double

Returns

HasDecimal(val)

Check if string is a number and has float values.

Name Description
val System.String
string to check

Returns

IntToArray(val)

Convert an integer to an array of single digits

Name Description
val System.Int64

Returns

InvalidNumber(val)

check if a number is infinity or NaN

Name Description
val System.Double
the value to be tested

Returns

Boolean value

IsBetween(val1, val2, val3)

Test if a number is inside but should not be on the limits

Name Description
val1 System.Double
val2 System.Double
Limit 1
val3 System.Double
Limit 2

Returns

IsBetween(val1, val2, val3)

Test if a number is inside but should not be on the limits

Name Description
val1 System.Int32
val2 System.Int32
Limit 1
val3 System.Int32
Limit 2

Returns

IsBetween(val1, val2, val3)

Test if a number is inside but should not be on the limits

Name Description
val1 System.Int64
val2 System.Int64
Limit 1
val3 System.Int64
Limit 2

Returns

IsEven(value)

Determine if an integer is Even

Name Description
value System.Int32

Returns

IsNumeric(val)

Determine if a string can be converted into a number, Similar VB.net IsNumeric Function

Name Description
val System.String
The string to be tested

Returns

Boolean Value

IsWithin(val1, val2, val3)

Test if a number is inside or exactly on the limits

Name Description
val1 System.Double
val2 System.Double
Limit 1
val3 System.Double
Limit 2

Returns

IsWithin(val1, limits)

Test if a number is inside or exactly on the limits

Name Description
val1 System.Double
limits System.ValueTuple{System.Double,System.Double}

Returns

IsWithin(val1, val2, val3)

Test if a number is inside or exactly on the limits

Name Description
val1 System.Int32
val2 System.Int32
Limit 1
val3 System.Int32
Limit 2

Returns

IsWithin(val1, limits)

Test if a number is inside or exactly on the limits

Name Description
val1 System.Int32
limits System.ValueTuple{System.Int32,System.Int32}

Returns

LimitWithin(val1, val2, val3)

Make a value stay within the limits (Including the limits themselves)

Name Description
val1 System.Double
val2 System.Double
Limit 1
val3 System.Double
Limit

Returns

LimitWithin(val1, val2, val3)

Make a value stay within the limits (Including the limits themselves)

Name Description
val1 System.Int32
val2 System.Int32
Limit 1
val3 System.Int32
Limit

Returns

LimitWithin(val1, val2, val3)

Make a value stay within the limits (Including the limits themselves)

Name Description
val1 System.Int64
val2 System.Int64
Limit 1
val3 System.Int64
Limit

Returns

MinMax(val1, val2)

determine the min or max of two doubles

Name Description
val1 System.Double
val2 System.Double

Returns

MinMax(val1, val2)

determine the min or max of two integers

Name Description
val1 System.Int32
val2 System.Int32

Returns

NearEqual(val1, val2, accuracy)

Check if a number is Approximately Equal to the other

Name Description
val1 System.Double
val2 System.Double
accuracy System.Int32

Returns

NearZero(val, accuracy)

Determine if a double number is almost equal to zero

Name Description
val System.Double
accuracy System.Int32
accuracy to the n'th degree

Returns

NoFloat(val, precision)

Check if a double value is an integer

Name Description
val System.Double
precision System.Int32

Returns

NumberSign

Numeric Enumeration

Negative

Less that 0

Neutral

Exactly Zero

Positive

Greater than 0

KtExtensions.NumericExtensions.RaiseTo(val1, val2)

Acts like an exponent/power

Name Description
val1 System.Double
val2 System.Double
exponent

Returns

KtExtensions.NumericExtensions.RaiseTo(val1, val2)

Acts like an exponent/power

Name Description
val1 System.Double
val2 System.Int32
exponent

Returns

KtExtensions.NumericExtensions.RaiseTo(val1, val2)

Acts like an exponent/power

Name Description
val1 System.Int32
val2 System.Double
exponent

Returns

KtExtensions.NumericExtensions.RaiseTo(val1, val2)

Acts like an exponent/power

Name Description
val1 System.Int32
val2 System.Int32
exponent

Returns

KtExtensions.NumericExtensions.Roundby(val1, val2)

Round for every interval

Name Description
val1 System.Double
val2 System.Double
interval

Returns

KtExtensions.NumericExtensions.Roundby(val1, val2)

Round for every interval

Name Description
val1 System.Double
val2 System.Int32
interval

Returns

KtExtensions.NumericExtensions.RoundDownby(val1, val2)

Round down for every interval

Name Description
val1 System.Double
val2 System.Double
interval

Returns

KtExtensions.NumericExtensions.RoundDownby(val1, val2)

Round down for every interval

Name Description
val1 System.Double
val2 System.Int32
interval

Returns

KtExtensions.NumericExtensions.RoundUpby(val1, val2)

Roundup for every interval

Name Description
val1 System.Double
val2 System.Double
interval

Returns

KtExtensions.NumericExtensions.RoundUpby(val1, val2)

Roundup for every interval

Name Description
val1 System.Double
val2 System.Int32
interval

Returns

KtExtensions.NumericExtensions.ScientificNotation(val)

Return the scientific notation

Name Description
val System.Double
todo: describe val parameter on ScientificNotation

Returns

return a tuple of significant figure in 1's and the base 10 exponent

KtExtensions.NumericExtensions.Sign(num, accuracy)

Determine the sign of a number

Name Description
num System.Double
accuracy System.Int32

Returns

KtExtensions.NumericExtensions.Sign(num)

Determine the sign of a number

Name Description
num System.Int32

Returns

KtExtensions.NumericExtensions.SmartRoundActual(val, digits)

Round the value based on the repeated 999's and 000's

Name Description
val System.Double
digits System.Int64[]

Returns

KtExtensions.NumericExtensions.SmartRoundSignificantValue(val, digits)

Round The number by finding the first repeated digits from the number;

Name Description
val System.Double
digits System.Int64[]
digits that are repeated

Returns

KtExtensions.NumericExtensions.SmartToString(val)

Desirable tostring of a double data type

Name Description
val System.Double

Returns

KtExtensions.NumericExtensions.Store15DecimalsToArray(val)

Make 15 decimals to array

Name Description
val System.Double

Returns

KtExtensions.NumericExtensions.ToDouble(val)

Convert a string to a number, if the string is not numeric then the return value will be zero

Name Description
val System.String

Returns

Partition`2

Grouping of Ienumerable

Type Parameters

  • TKey -
  • TValue -

Constructor

base Constructor

Constructor(info, context)

Constructor

Name Description
info System.Runtime.Serialization.SerializationInfo
context System.Runtime.Serialization.StreamingContext

Add(key, value)

Add Individual Element

Name Description
key `0
value `1

Add(key, value)

Add a partition

Name Description
key `0
value System.Collections.Generic.List{`1}

Item(`0)

Create Partition

Name Description
key `0

Returns

Remove(key)

Remove a partition

Name Description
key `0

ReflectionExtensions

Reflection extensions

GetCascadedPropertyValue(o, name)

Get the property value cascaded to its subproperties

Name Description
o System.Object
name System.String

GetCascadedPropertyValue(o, pNames)

Get the property value cascaded to its subproperties

Name Description
o System.Object
pNames System.String[]

Returns

GetPropertyValue(o, pName)

The the value of the runtime property of name pName

Name Description
o System.Object
pName System.String

Returns

System.ArgumentNullException:

GetPropertyValue(obj, propertyName)

Get the value of Property and cast it to it's proper type

Type Parameters

  • T -
Name Description
obj System.Object
propertyName System.String

Returns

GetPropertyValues(obj)

Search all property names, get their values, and store them into a dictionary of string/object generic type

Name Description
obj System.Object

Returns

GetPropertyValues(objs)

Search all property names, get their values, and store them into a dictionary of string/object generic type

Name Description
objs System.Collections.Generic.IEnumerable{``0}

Returns

PropertyValueString(o, pName)

Get value of object

Name Description
o System.Object
pName System.String

Returns

StringManipulation

String extensions

AppendNewLine(sb)

Append new line to the string builder

Name Description
sb System.Text.StringBuilder

Returns

AppendThenNewLine(sb, str)

Append A string then add new line

Name Description
sb System.Text.StringBuilder
str System.String

Returns

AppendWhen(sb, str, predicate)

Append A string then when

Name Description
sb System.Text.StringBuilder
str System.String
predicate System.Func{System.Boolean}

Returns

BuildString(enumerable, separator, enclosure)

Concatenate all the element System.Object.ToString value of an enumerable

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
separator System.String
String separating each string
enclosure System.ValueTuple{System.String,System.String}
strings enclosing the element string

Returns

BuildString(enumerable, separator)

Concatenate all the element System.Object.ToString value of an enumerable

Type Parameters

  • T -
Name Description
enumerable System.Collections.Generic.IEnumerable{``0}
separator System.String
String separating each string

Returns

FirstCharacterToLower(str)

Make First Letter of a string into lower character

Name Description
str System.String

Returns

FirstCharacterToUpper(str)

Make First Letter of a string into upper character

Name Description
str System.String

Returns

GuardClausedEquals(str1, str2, stringComparison)

Guard Claused Equals w/ string comparison

Name Description
str1 System.String
str2 System.String
stringComparison System.StringComparison

Returns

GuardClausedEquals(str1, str2)

Guard Claused Equals

Name Description
str1 System.String
str2 System.String

Returns

Has(this, possibles)

Determine if a character is inside a list of characters

Name Description
this System.String
possibles System.Char[]

Returns

Has(this, possibles)

Determine if a character is inside a list of strings

Name Description
this System.String
possibles System.String[]

Returns

IsNullOrEmpty(str)

Similar to System.String.IsNullOrEmpty(System.String)

Name Description
str System.String

Returns

MakeUniqueFrom(str, strs, maxLength)

Check if string is a duplicate and create new numbered string

Name Description
str System.String
strs System.Collections.Generic.IEnumerable{System.String}
maxLength System.Int32

Returns

MakeUniqueFrom(str, strs)

Check if string is a duplicate and create new numbered string

Name Description
str System.String
strs System.Collections.Generic.IEnumerable{System.String}

Returns

RemoveLastChar(str)

Remove the last letter of the string

Name Description
str System.String

Returns

RemoveVowels(str)

Remove Vowels from strings

Name Description
str System.String

Returns

RepeatString(str, count)

Concatenate a repeat string at a number of times

Name Description
str System.String
the string to be repeated
count System.Int32
number of times to repeat

Returns

SmartAppend(str, strToAppend)

Be able identify if it is good to append a text to the main text

if str is null or empty then an empty text is returned

Name Description
str System.String
strToAppend System.String

SmartConcat(str1, str2, filler)

Concat Two strings with a filler

Name Description
str1 System.String
str2 System.String
filler System.String

Returns

SmartConcat(str, toConcat, filler)

Concat strings with filler

Name Description
str System.String
toConcat System.String[]
filler System.String

Returns

SmartPrepend(str, strToPrepend)

Be able identify if it is good to prepend a text to the main text

if str is null or empty then an empty text is returned

Name Description
str System.String
strToPrepend System.String

SplitTextAndNumber(text)

Separate String and Number, example "text (1)" the text and the number will be extracted

Name Description
text System.String

Returns

text and a number, "text (1)" return "text " and "1"

ToWords(number)

Convert integers to words

Name Description
number System.Int32

Returns

TypesExtensions

Extensions for type

GetTypeHierarchy(type)

Get all type derivation Reference: KallDrexx (2011, June 21). How can I use reflection to return all classes subclassing from a generic, without giving a specific generic type [Online forum comment]. Message posted to https://stackoverflow.com/questions/6426949/how-can-i-use-reflection-to-return-all-classes-subclassing-from-a-generic-witho/6427201#6427201

Name Description
type System.Type

Returns

IsDerivedFromOpenGenericType(type, openGenericType)

Determine if a type is derived from open generic type Reference: KallDrexx (2011, June 21). How can I use reflection to return all classes subclassing from a generic, without giving a specific generic type [Online forum comment]. Message posted to https://stackoverflow.com/questions/6426949/how-can-i-use-reflection-to-return-all-classes-subclassing-from-a-generic-witho/6427201#6427201

Name Description
type System.Type
openGenericType System.Type

Returns

System.ArgumentNullException:

System.ArgumentException:

IsNullable(type)

Determine if a generic param is a Nullable type Reference: Traub, D. (2011, March 3). Determine if a generic param is a Nullable type [Online forum comment]. Message posted to https://stackoverflow.com/questions/5181494/determine-if-a-generic-param-is-a-nullable-type

Name Description
type System.Type

Returns

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages