Skip to content

Latest commit

 

History

History
143 lines (90 loc) · 6.09 KB

README.md

File metadata and controls

143 lines (90 loc) · 6.09 KB

BarbezDotEu.Generic

Contents

LinqHelper type

Namespace

BarbezDotEu.Generic

Summary

Generic helper extension method adapted for Linq from https://stackoverflow.com/questions/2019417/how-to-access-random-item-in-list, http://www.albahari.com/nutshell/predicatebuilder.aspxamongst, and others.

GenerateRandomList``1(source,numberOfItems) method

Summary

Generates n number of items randomly from a given IEnumerable`1 source, even if the source list has less items than the number of items to return (as provided by the numberOfThings).

Returns

The random list.

Parameters
Name Type Description
source System.Collections.Generic.IEnumerable{``0} The source.
numberOfItems System.Int32 The number of items to take.
Generic Types
Name Description
T The type.

PickRandom``1(source) method

Summary

From a given IEnumerable`1, selects a random single item.

Returns

One item, randomly chosen from the given collection.

Parameters
Name Type Description
source System.Collections.Generic.IEnumerable{``0} The source collection to pick one item out of.
Generic Types
Name Description
T The type to pick one of.

PickRandom``1(source,count) method

Summary

Picks an n number of items randomly from the IEnumerable`1. If n is larger than the number of items in the list, returns all items in the list only (which in this case is less than the number of items given to return).

Returns

The random list.

Parameters
Name Type Description
source System.Collections.Generic.IEnumerable{``0} The source.
count System.Int32 The number of items to take.
Generic Types
Name Description
T The type.

Shuffle``1(source) method

Summary

Randomly shuffles the given source collection.

Returns

A shuffled version of the given collection.

Parameters
Name Type Description
source System.Collections.Generic.IEnumerable{``0} The collection to shuffle.
Generic Types
Name Description
T The types to be found in the collection to shuffle.

ReflectionHelper type

Namespace

BarbezDotEu.Generic

Summary

Generic helper extension method adapted for Reflection from https://stackoverflow.com/a/1954663, amongst others.

GetPropertyValue``1() method

Summary

Example use: DateTime now = DateTime.Now; int min = GetPropertyValue(now, "TimeOfDay.Minutes"); int hrs = now.GetPropertyValue("TimeOfDay.Hours");

Parameters

This method has no parameters.