Skip to content

Instantly share code, notes, and snippets.

View kellypleahy's full-sized avatar

Kelly Leahy kellypleahy

View GitHub Profile
public class Base
{
private bool _Initialized;
private void _EnsureInitialized() { if(!_Initialized) _Initialize(); }
private void _Initialize() { Initialize(); _Initialized = true; }
public virtual void Initialize()
{
public interface ICommandRepository<T>
{
void SaveOrUpdate<U>(U item) where U: T;
void Delete<U>(U item) where U: T;
}
/* then, library code asks for ICommandRepository<Core.Customer> and so do clients.
However, when clients call SaveOrUpdate, they'll be passing a Extended.Customer,
but when library code calls it, they'll be passing what they think is a Core.Customer
(though it will still be a Extended.Customer, of course).
private class RefVisitor: BaseReflectionVisitor
{
public override void VisitModuleDefinition(ModuleDefinition module)
{
module.Types.Accept(this);
VisitCollection(module.Types);
}
public override void VisitTypeDefinition(TypeDefinition type)
{
void Main()
{
var rootList = new List<Node>(new[]{ new Node() }); // only ever one root, I assume.
var childrenAtThisLevel = FillLevel(rootList);
while(childrenAtThisLevel.Count > 0)
childrenAtThisLevel = FillLevel(childrenAtThisLevel);
}
List<Node> FillLevel(List<Node> childrenAtThisLevel)
{
// field _LookAhead
Node Operand()
{
Node ret;
if(matches(TokenId.Identifier))
{
ret = new Node()
{
Value = _LookAhead.TokenText,
[merge]
keepBackup = false;
tool = p4merge
[mergetool "p4merge"]
cmd = p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
keepTemporaries = false
trustExitCode = false
keepBackup = false
@kellypleahy
kellypleahy / IQueueWatcher.cs
Created March 24, 2011 07:05
an attempt at a queue watcher that is more correct for our needs.
public interface IQueueWatcher
{
void Start();
}
public interface IQueueMessageProcessor
{
void ProcessMessage(byte[] messageBytes);
}
@kellypleahy
kellypleahy / gist:959341
Created May 6, 2011 17:08
testing post message handler
public class PostStatusCodeMessageHandler: DelegatingChannel
{
public PostStatusCodeMessageHandler(HttpMessageChannel innerChannel)
: base(innerChannel)
{
}
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var task = base.SendAsync(request, cancellationToken);
@kellypleahy
kellypleahy / ThreadPool.cs
Created May 6, 2011 22:19
thread pool implementation from the advanced threading class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace ThreadingApp
{
public interface ITask
{
void Execute();
@kellypleahy
kellypleahy / gist:988177
Created May 24, 2011 05:33
CECIL based unit tests.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using Milliman.MGAlfa.AplInterface;
using Mono.Cecil;
using Mono.Cecil.Cil;
using NUnit.Framework;