This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Build | |
{ | |
public static OrderBuilder Order(Cutomer customer) | |
{ | |
return new OrderBuilder(customer); | |
} | |
public static CustomerBuilder Customer(string name) | |
{ | |
return new CustomerBuilder(name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Una consulta básica usando Linq-to-NHibernate (con EF supongo que sería parecido) | |
var dbQuery = session.Query<Product>(); | |
El IEnumerable que devuelve, internamente tiene un Enumerator parecido a esto: | |
IEnumerator<Product> GetEnumerator() { | |
using (var reader = command.ExecuteReader()) | |
{ | |
while (reader.Read()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(window, document) { | |
// Create the DOM structure to hold the console messages | |
var div = document.createElement("div"); | |
div.style.cssText = "position: absolute; " + | |
"top: 5px; left: 5px; right: 5px; bottom: 5px; " + | |
"padding: 10px; " + | |
"overflow-y: auto; " + | |
"display: none; " + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Extensions | |
{ | |
public IDictionary<string, object> AsDict(this object obj) | |
{ | |
return obj.GetType().GetProperties().ToDictionary(x => x.Name, x => x.GetValue(obj, null)) | |
} | |
} | |
var obj = new { Name = "Lucas", Age = 14 }.AsDict(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IElement | |
{ | |
IEnumerable<ChildElement> Children { get; } | |
} | |
public class ChildElement | |
{ | |
public readonly IElement Value; | |
public readonly Point Point; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Situación inicial | |
public class OrderStatsCalculator | |
{ | |
// Inyectado por constructor. En todos los casos lo hago igual. | |
private IOrderRepository repository; | |
// Esto se puede testear con un mock/stub/fake/etc. que inyectes por | |
// el constructor | |
public int Calculate() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Id<T> | |
{ | |
public readonly int Value; | |
public Id(int value) | |
{ | |
this.value = value; | |
} | |
public static implicit operator Id<T>(int value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Required libs | |
// - NUnit | |
// - Castle.DynamicProxy | |
using System; | |
using System.Linq; | |
using System.Reflection; | |
using Castle.DynamicProxy; | |
using NUnit.Framework; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Required libs | |
// - NUnit | |
// - Castle.DynamicProxy | |
using System; | |
using System.Linq; | |
using System.Reflection; | |
using Castle.DynamicProxy; | |
using NUnit.Framework; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package koalite.cordova; | |
import org.apache.cordova.api.Plugin; | |
import org.apache.cordova.api.PluginResult; | |
import org.apache.cordova.api.PluginResult.Status; | |
import org.json.JSONArray; | |
import android.content.Intent; | |
import android.net.Uri; | |
public class GoToPlugin extends Plugin { |