Giter VIP home page Giter VIP logo

commonextensions's Introduction

System.Common.Extensions

Common C# Extensions for Developers

Contents

CommonExtensions type

Namespace

System

Summary

Defines the CommonExtensions

DeHumanize(humanized,delimiter) method

Summary

Make Readable string Dirty

Returns

The String

Parameters
Name Type Description
humanized System.String humanized stringString
delimiter System.String delimiter String

Distinct``2(this,keySelector) method

Summary

Provides a Distinct method that takes a key selector lambda as parameter. The .net framework only provides a Distinct method that takes an instance of an implementation of IEqualityComparer where the standard parameter less Distinct that uses the default equality comparer doesn't suffice.

Returns
Parameters
Name Type Description
this System.Collections.Generic.IEnumerable{``0} IEnumerable.
keySelector System.Func{``0,``1} key selector.
Generic Types
Name Description
T
TKey The type of the key.

Extend``1(target,source) method

Summary

An extension function to work like the extend method of javascript. It takes the object and merge with oder, but only if the property of the other object has value.

Returns

The

Parameters
Name Type Description
target ``0 The target
source ``0 The source
Generic Types
Name Description
T

ForAwait(task) method

Summary

The ForAwait

Returns

The ConfiguredValueTaskAwaitable

Parameters
Name Type Description
task System.Threading.Tasks.ValueTask@ The taskValueTask

ForAwait(task) method

Summary

The ForAwait

Returns

The ConfiguredTaskAwaitable

Parameters
Name Type Description
task System.Threading.Tasks.Task The taskTask

ForAwait``1(task) method

Summary

The ForAwait

Returns

The ConfiguredValueTaskAwaitable`1

Parameters
Name Type Description
task System.Threading.Tasks.ValueTask{``0}@ The taskValueTask`1
Generic Types
Name Description
T

ForAwait``1(task) method

Summary

The ForAwait

Returns

The ConfiguredTaskAwaitable`1

Parameters
Name Type Description
task System.Threading.Tasks.Task{``0} The taskTask`1
Generic Types
Name Description
T

Format(value,arg0) method

Summary

Replaces the format item in a specified System.String with the text equivalent of the value of a specified System.Object instance.

Returns

The String

Parameters
Name Type Description
value System.String A composite format string
arg0 System.Object An System.Object to format

Format(value,args) method

Summary

Replaces the format item in a specified System.String with the text equivalent of the value of a specified System.Object instance.

Returns

The String

Parameters
Name Type Description
value System.String A composite format string
args System.Object[] An System.Object array containing zero or more objects to format.

GetDefault(type) method

Summary

Get Default Value

Returns

The Object

Parameters
Name Type Description
type System.Type The typeType

Humanize(value) method

Summary

Human Readable string

Returns

The String

Parameters
Name Type Description
value System.String The valueString

IfIs``1(target,method) method

Summary

allows an action to be taken on an object if it is cast able as the given type, with no return value. if the target does not match the type, does nothing

Parameters
Name Type Description
target System.Object The targetObject
method System.Action{``0} The methodAction`1
Generic Types
Name Description
T

IfIs``2(target,method) method

Summary

allows an action to be taken on an object if it is cast-able as the given type, with a return value. if the target does not match the type, returns default(T)

Returns

The

Parameters
Name Type Description
target System.Object The targetObject
method System.Func{``0,``1} The methodFunc`2
Generic Types
Name Description
T
TResult

IfNotNull``2(source,selector) method

Summary

Returns a selected value when the source is not null; null otherwise.

Returns

The selected value when source is not null; null otherwise.

Parameters
Name Type Description
source ``0 The source
selector System.Func{``0,``1} The selectorFunc`2
Generic Types
Name Description
T
TInner

ImplementsInterfaces(obj,interfaces) method

Summary

Implements Interfaces Determines if a class object implements an interface type and returns a list of types it actually implements. If no matching type is found an empty list will be returned.

Returns

The List`1

Parameters
Name Type Description
obj System.Object The objObject
interfaces System.Collections.Generic.List{System.Type} The interfacesList`1

In(value,stringValues) method

Summary

Checks string object's value to array of string values

Returns

Return true if any string value matches

Parameters
Name Type Description
value System.String The valueString
stringValues System.String[] Array of string values to compare

In``1(source,list) method

Summary

Allows you to compare a value to a list of values analogous to the 'In' statement in sql. This makes for a very friendly syntax that is (IMHO) superior to a list of 'or' clauses. Instead of : if (s=="John" || s=="Peter" or s=="Paul") one can write if (s.In("John","Paul","Peter"))

Returns

The Boolean

Parameters
Name Type Description
source ``0 The source
list ``0[] The list
Generic Types
Name Description
T

IsDecimal(input) method

Summary

Check string IsDecimal

Returns

The Boolean

Parameters
Name Type Description
input System.String The inputString

IsDouble(input) method

Summary

Check string IsDouble

Returns

The Boolean

Parameters
Name Type Description
input System.String The inputString

IsInt(input) method

Summary

Check string IsInt

Returns

The Boolean

Parameters
Name Type Description
input System.String The inputString

IsNotNull(input) method

Summary

Check if Input string is not null or whitespace

Returns

The Boolean

Parameters
Name Type Description
input System.String The inputString

IsNull``1(me) method

Summary

Check IsNull

Returns

The Boolean

Parameters
Name Type Description
me ``0 The me
Generic Types
Name Description
T

IsNull``1(me) method

Summary

Check IsNull

Returns

True or False Boolean

Parameters
Name Type Description
me System.Nullable{``0} Struct need to check is null
Generic Types
Name Description
T Where T is struct

IsSet(input) method

Summary

Check if string is null or empty

Returns

True or False Boolean

Parameters
Name Type Description
input System.String The inputString

Left(value,length) method

Summary

Returns characters from left of specified length

Returns

Returns string from left

Parameters
Name Type Description
value System.String String value
length System.Int32 Max number of characters to return

Like(value,search) method

Summary

An C# extension method based on "LIKE" operator of T-SQL.

Returns

The Boolean

Parameters
Name Type Description
value System.String The valueString
search System.String The searchString

ReferenceEqualsEx(objA,objB) method

Summary

This extension method represents shorthand version of ReferenceEqualsEx method.

Returns

The Boolean

Parameters
Name Type Description
objA System.Object The objAObject
objB System.Object The objBObject

Return``2(value,evaluateFunc) method

Summary

Returns a value based on an provided value and evaluation function

Returns

The

Parameters
Name Type Description
value ``0 The value
evaluateFunc System.Func{``0,``1} The evaluateFuncFunc`2
Generic Types
Name Description
TIn
TOut

Right(value,length) method

Summary

Returns characters from right of specified length

Returns

Returns string from right

Parameters
Name Type Description
value System.String String value
length System.Int32 Max number of characters to return

SpinThread``1(params,action) method

Summary

Spins up and executes the action within a thread. Basically fire and forget. Real big question here. Does anybody see any issues with thread management? I would like to update this with any code necessary to manage thread cleanup if necessary. I realize that this has the ability to create unsafe thread referencing if not written such that the contents of the action are exclusive to the scope of the action, but that is outside the purview of this extension

Parameters
Name Type Description
params ``0 The params
action System.Action{``0} The actionAction`1
Generic Types
Name Description
T

SplitCamelCase(source) method

Summary

Split Camel Case string to space delimited

Returns

spited string array

Parameters
Name Type Description
source System.String The sourceString

ThrowIf``1(val,predicate,exceptionFunc) method

Summary

Throw's a given exception is a given predicate is True

Returns

T object to throw exception

Parameters
Name Type Description
val ``0 The val
predicate System.Func{``0,System.Boolean} The predicate
exceptionFunc System.Func{System.Exception} The exceptionFuncFunc`1
Generic Types
Name Description
T

ToDecimal(input) method

Summary

Converts string to ToDecimal

Returns

The Decimal

Parameters
Name Type Description
input System.String The inputString

ToDouble(input) method

Summary

Converts string to ToDouble

Returns

The Double

Parameters
Name Type Description
input System.String The inputString

ToEnum``1(value) method

Summary

Converts string to enum object

Returns

Returns enum object

Parameters
Name Type Description
value System.String String value to convert
Generic Types
Name Description
T Type of enum

ToInt(input) method

Summary

Converts string to Int

Returns

The Int32

Parameters
Name Type Description
input System.String The inputString

ToLogString(ex,additionalMessage) method

Summary

Creates a log-string from the Exception.

The result includes the stacktrace, inner-exception et crater, separated by .

Returns
Parameters
Name Type Description
ex System.Exception The exception to create the string from.
additionalMessage System.String Additional message to place at the top of the string, maybe be empty or null.

ToNull(_) method

Summary

Make object Null

Returns

The Object

Parameters
Name Type Description
_ System.Object _Object

ToUrlSlug(value) method

Summary

Make Url Slug

Returns

The String

Parameters
Name Type Description
value System.String The valueString

commonextensions's People

Contributors

emonarafat avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

sakib-dhrubo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.