This file contains 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
Customer customer = | |
A.BuilderFor<Customer>().With(new { | |
GivenName = "John", | |
FamilyName = "Doe", | |
Address = A.BuilderFor<Address>().With(new { | |
FirstLine = "123 Main Street", | |
City = "Nashville", | |
State = "TN" | |
}) | |
}); |
This file contains 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
define( | |
['underscore'], | |
function (_) { | |
// Outputs "true" | |
console.log(_.deepClone !== undefined); | |
} | |
); |
This file contains 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 TypeExtensions | |
{ | |
public static bool Closes(this Type type, Type checkType) | |
{ | |
if (!checkType.IsGenericTypeDefinition) | |
throw new ArgumentException("Type being checked against is not an open generic type."); | |
return | |
type.IsGenericType | |
&& type.GetGenericTypeDefinition() == checkType; |
This file contains 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
// test setup | |
var adapter = new InMemoryAdapter(); | |
var stubId = 15; | |
adapter.AddFunction<int>("GenerateId", () => stubId); // A breakpoint here inside the lambda *does* break when we call it later | |
Database.UseMockAdapter(adapter); | |
dynamic db = Database.Open(); | |
var resultId = db.GenerateId().ReturnValue; |
This file contains 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
void IgnoreException(Action operation) | |
{ | |
try { operation(); } | |
catch (Exception) { } | |
} | |
void OnErrorResumeNext(List<Action> operations) | |
{ | |
operations.ForEach(op => IgnoreException(op)); | |
} |
This file contains 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 class DataContext : IDataContext | |
{ | |
public DataContext(ISessionProvider sessionProvider) | |
{ | |
this.SessionProvider = sessionProvider.ThrowIfNullArgument("sessionProvider"); | |
} | |
private ISessionProvider SessionProvider { get; set;} | |
protected ISessionFacade Session |
This file contains 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 IEnumerableExtensions | |
{ | |
public static IEnumerable<T> EmptyIfNull<T>(this IEnumerable<T> source) | |
{ | |
return source ?? Enumerable.Empty<T>(); | |
} | |
} |
This file contains 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
// Latch definition | |
public class DoubleCheckLockLatch | |
{ | |
private readonly Object _lockSync = new Object(); | |
private readonly Func<bool> _isLatchClosed; | |
public DoubleCheckLockLatch(Func<bool> isLatchClosed) | |
{ | |
_isLatchClosed = isLatchClosed; | |
} |
This file contains 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
// Container context tags | |
enum EContainerContext | |
{ | |
UnitOfWork, | |
Plugin, | |
MultiInstanceWindow | |
} | |
// Registration code for an object that owns a lifetime scope | |
builder.RegisterType<MyDbContext>() |
This file contains 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
internal interface IConfigLoader | |
{ | |
IConfigSettings LoadConfig(); | |
} | |
internal class ConfigLoader : IConfigLoader | |
{ | |
public ConfigLoader() | |
{ | |
} |
NewerOlder