CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets for: Mike Minutillo
C#
Action callMe = () => { };
 
Action fooledYou = () => callMe();
 
callMe = fooledYou;
 
fooledYou();
by Mike Minutillo   March 29, 2011 @ 2:11am
Tags:
64 Views
no comments
 
C#
public abstract class Agent : IAgent
{
    private IDeck _deck;
    private int _lastAttackedInTick = 0;
    private IAgentUpdateInfo _currentState;
    //private object _attackLock = new object();
 
    public INodeInformation CurrentNode { get { return _currentState.Node; } }
 
    protected bool AttackedThisTick { get { return _deck.TickNumber == _lastAttackedInTick; } }
by Mike Minutillo   December 23, 2010 @ 5:20am
Tags:
113 Views
1 comments
 
C#
public static class ActionExtensions
{
    public static void ExecuteWith(this Action action, params Action<Action>[] wrappers)
    {
        wrappers.Reverse().Aggregate(action, (a, b) => () => b(a)).Invoke();
    }
}
 
public static class Wrap
{
by Mike Minutillo   October 13, 2010 @ 2:08am
Tags:
203 Views
no comments
 
C#
public static class ActionExtensions
{
    public static void ExecuteWithLoggedErrors(this Action action)
    {
        try
        {
            action();
        }
        catch (Exception ex)
        {
by Mike Minutillo   October 13, 2010 @ 1:29am
Tags:
187 Views
1 comments
 
C#
public static class GenericExtensions
{
  public static TProp Get<TSource, TProp>(this TSource target, Func<TSource, TProp> getter, TProp ifNull = default(TProp)) where TSource : class
  {
    return target == null ? ifNull : getter(target);
  }
}
 
// Usage
customer.Get(x => x.Supplier).Get(x => x.Manager).Get(x => x.FullName, "No Manager"); 
by Mike Minutillo   June 16, 2010 @ 9:33pm
Tags:
155 Views
2 comments
 
C#
// Main.cs
static void Main(string[] args)
{
  var foo = new Foo();
  foo.location = new Point(5, 5);
}
 
 
// Main.il
by Mike Minutillo   April 29, 2010 @ 4:03am
Tags:
86 Views
no comments
 
C#
class DeferredResolutionExtension : UnityContainerExtension
 {
     protected override void Initialize()
     {
         Context.Policies.Set<IBuildPlanPolicy>(new DeferredBuilderPolicy(), new NamedTypeBuildKey(typeof(Func<>), null));
         Context.Policies.Set<IBuildPlanPolicy>(new LazyBuilderPolicy(), new NamedTypeBuildKey(typeof(Lazy<>)));
     }
 }
 
 class LazyBuilderPolicy : IBuildPlanPolicy
by Mike Minutillo   April 27, 2010 @ 10:33am
Tags:
291 Views
no comments
 
C#
Mapper.CreateMap<Customer, CustomerDto>()
      .For(d => d.FirstName, o => o.MapFrom(c => c.FirstName))
      .For(d => d.LastName, o => o.MapFrom(c => c.LastName))
      .For(d => d.Gender, o => o.MapFrom(c => c.Gender))
      .For(d => d.Salutation, o => o.MapFrom(c => c.Salutation))
      .For(d => d.PostalAddressLine1, o => o.MapFrom(c => c.PostalAddressLine1))
      .For(d => d.PostalAddressLine2, o => o.MapFrom(c => c.PostalAddressLine2))
      .For(d => d.PostalAddressLine3, o => o.MapFrom(c => c.PostalAddressLine3))
      .For(d => d.PostalAddressPostcode, o => o.MapFrom(c => c.PostalAddressPostcode))
      .For(d => d.PostalAddressSuburb, o => o.MapFrom(c => c.PostalAddressSuburb))
by Mike Minutillo   April 07, 2010 @ 10:36pm
Tags:
183 Views
no comments
 
C#
class HAL : IInsaneComputer
{
  public IList<Questions> Disconnect(DisconnectionRequest request)
  {
    var questions = request.Questions ?? new List<Question>();
    
    var whatAreYouDoing = questions.Ask<WhatAreYouDoing>(GetCurrentUser());
 
    if( whatAreYouDoing.IsUnanswered )
      return questions;
by Mike Minutillo   March 18, 2010 @ 8:15pm
Tags:
122 Views
no comments
 
C#
public IList<Question> DoSomething(DoSomethingRequest request)
{
  var questions = request.Questions ?? new List<Question>();
 
  var sendNotificationEmail = questions.Ask<CanSendNotifactionEmail>();
 
  if( sendNotifactionEmail.GotResponse(true) )
  {
    delayedActions.Add(() => notificatiosService.SendNotifications());
  }
by Mike Minutillo   March 18, 2010 @ 8:07pm
Tags:
151 Views
1 comments
 
C#
[DataContract]
public class UserBooleanDecision
{
  [DataMember]
  public bool? Decision { get; set; }
 
  [DataMember]
  public bool RequiresAnswer { get; set; }
}
by Mike Minutillo   March 17, 2010 @ 11:20pm
Tags:
117 Views
no comments
 
C#
public class SomeController
{
  private static SomeController instance;
  public SomeController(){}
 
  /// <summary>
  /// Gets the instance.
  /// </summary>
  /// <returns></returns>
  public static SomeController GetInstance()
by Mike Minutillo   September 16, 2009 @ 8:12pm
159 Views
1 comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate