Skip to content

Instantly share code, notes, and snippets.

View vas6ili's full-sized avatar

Vasile Bujac vas6ili

View GitHub Profile
@vas6ili
vas6ili / Deconstruct.cs
Last active June 21, 2018 14:45
Deconstruction in Service Locator pattern example
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Runtime.CompilerServices;
namespace DisposableValueTuples
{
[MemoryDiagnoser]
public class Benchmark
{
@vas6ili
vas6ili / gist:0c436aa18000d2c5f830fe20af7596de
Created March 23, 2017 14:26
Push reservation example
POST /reservations
{
"hotel": "S01543",
"reservationNumber": "123456",
"confirmationNumber": "654321",
"status": "Booked",
"arrivalDate": "2017-03-24",
"departureDate": "2017-03-26",
"room": {
@vas6ili
vas6ili / FuncExtensions.cs
Created April 30, 2013 09:03
Some useful Func<T> extensions methods
using System;
namespace NoNamespace
{
public static class FuncExtensions
{
public static Func<T> ToFunc<T>(this Lazy<T> lazyValue)
{
if (lazyValue == null)
throw new ArgumentNullException("lazyValue");
@vas6ili
vas6ili / SessionFactoryExtensions.cs
Created April 29, 2013 07:53
Gives a nice XML representation of NHibernate session factory statistics object
using System;
using System.Linq;
using System.Xml.Linq;
using NHibernate;
namespace NHibernate
{
public static class SessionFactoryExtensions
{
public static XElement GetStatisticsXml(this ISessionFactory sessionFactory)
@vas6ili
vas6ili / LogTableEntity.cs
Created April 24, 2013 15:12
Simple log4net azure table storage appender.
using System;
using System.Collections.Generic;
using log4net.Core;
using Microsoft.WindowsAzure.Storage.Table;
namespace WindowsAzure.Logging
{
/// <summary>
/// There used to be a dedicated log table entity class for derived from <see cref="TableEntity" />
/// Because TableEntity uses a lot of reflection, I switched it to a DynamicTableEntity which uses a dictionary of properties
public class Employee
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual Employee Manager { get; set; }
private int _age;
public virtual int Age
{
get { return _age; }
@vas6ili
vas6ili / Program.cs
Last active December 14, 2015 23:18
ToArray and ToList micro benchmark
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace ConsoleApplication3
{
class Program
{
static volatile IEnumerable<int> results;
@vas6ili
vas6ili / SelectListExtensions.cs
Created December 4, 2012 10:17
Helper extension methods for creating a list of ASP.NET MVC SelectListItem with NHibernate LINQ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Web.Mvc;
using NHibernate;
using NHibernate.Linq;
public static class SelectListExtensions