Skip to content

Instantly share code, notes, and snippets.

View agutierrezcu's full-sized avatar
😁
working hard!

Armando Gutierrez Riera agutierrezcu

😁
working hard!
  • Barcelona, Spain
View GitHub Profile
/// <summary>
/// Contains extension methods to format the type name.
/// </summary>
public static class TypeFormattingExtensions
{
/// <summary>
/// Builds the pretty full name of the specified type.
/// <remarks>
/// Specially for generic types the resulting full name is more redeable.
/// </remarks>
@agutierrezcu
agutierrezcu / EnumerableExtension.cs
Created February 16, 2017 14:19
A direct way to check if an enumerable is null or empty
public static class EnumerableExtension
{
public static bool IsNullOrEmpty(this IEnumerable enumerable)
{
if (enumerable == null)
{
return true;
}
return !enumerable.GetEnumerator().MoveNext();
}
@agutierrezcu
agutierrezcu / ExceptionExtension.cs
Last active September 21, 2017 11:49
A handy extension method to extract all useful information from exception instance and its inner exceptions as well.
public static class ExceptionExtension
{
public static string GetDetails(this Exception exception, StringBuilder sb = null)
{
if (exception == null)
{
return sb?.ToString() ?? string.Empty;
}
if (sb == null)
{
@agutierrezcu
agutierrezcu / createEnum.js
Last active February 4, 2017 23:38
Add support to simples Enum types in javascript. Testing using mocha and expect.
import { fromJS } from 'immutable';
import check from 'check-types';
class Enum {
constructor(constants, enumType = '') {
if (check.not.array(constants) && check.not.object(constants)) {
throw new TypeError('The enum constants must be an array or an object.');
}