Because csharp needs some help.
- DNX 5.0
- DNX 4.6
- .NET 4.6
Method | Description | Example |
---|---|---|
#Send |
calls a property or method | obj.Send("MethodName") |
#Send= |
Sets a field or property | obj.Send("PropertyName=", value) |
#RespondsTo |
has property or method? | obj.RespondsTo("MethodName") |
#IsA |
checks class, superclass, and interfaces | obj.IsA("IEnumerable") |
#CallableInfo |
returns the Member's Info object | obj.CallableInfo("propertyOrFieldOrMethod") |
#IsIterable |
checks if the object can be iterated over | obj.IsIterable() |
#GetInstanceFields |
returns a list of fields for the instance | obj.GetInstanceFields() |
#IsPrimitive |
returns true if the object is a primitive type, string, or decimal | obj.IsPrimitive() |
#IsSameTypeAs |
compares the objects type to a passed in object | obj.IsSameTypeAs(otherObj) |
#HasFieldMatching |
checks instance fields if the passed in field matches name and type | obj.HasFieldMatching(otherField) |
Method | Description | Example |
---|---|---|
#FirstOrDefault |
configurable default | list.FirstOrDefault(i => i.IsTrue, defaultValue) |
#Flatten |
recusively reduces nested lists to a single dimension | list.Flatten() |
#AddRange |
adds an at-runtime defined List<object> or List<dynamic> to a statically typed list |
list.AddRange(otherList) as long as all lists have the item type |
#Subset |
returns a subset of the enumerable, given a start and end index | list.Subset(1, 4) |
#Join |
joins an enumerable of strings | list.Join("-") |
#Zip |
zips two IEnumerables together for easier looping over both simultaneously | list.Zip(otherList) |
Method | Description | Example |
---|---|---|
#GrepProperties |
List of properties matching regex | |
#ImplementsType |
Returns whether or not a type Implements an Interface | typeof(List<int>).ImplementsType(typeof(IEnumerable)) |
#HasGenericType |
Returns whether or not a type has a given generic type | typeof(Dictionary<int, string>).HasGenericType(typeof(string)) |
Method | Description | Example |
---|---|---|
#Gsub |
Replaces the matching pattern with the given text | "hello".Gsub("\A..l", "") |
There are no additional classes / data structures at this time.
Dependencies are defined in project.json
They can be installed/updated via dnu restore
dnu build
dnx test
NuGet pack
NuGet Push csharp-extensions.x.y.z.nupkg