Skip to content

Instantly share code, notes, and snippets.

@lmauri
lmauri / PromiseDeferredCSharp
Created February 19, 2014 11:15
Implementation of Promise/Deferred pattern with C#
public interface IPromise
{
/// <summary>
/// Attaches a callback to be executed when the Deferred is resolved
/// </summary>
IPromise Done(Action callback);
/// <summary>
/// Attaches a callback to be executed when the Deferred is rejected
/// </summary>
IPromise Fail(Action<Exception> callback);
@lmauri
lmauri / Autofac Dependency Resolver
Created February 18, 2014 15:54
Autofac manual dependency resolver
/*
Inject the IComponentContext in the property of every BaseController
In BaseController I'll use IComponentContext to resolve services that are non singleton(i.e. datacontext dependency that
use per request lifetime scope)
*/
static void SetDependencyResolverAndConfig(Action<ContainerBuilder> config)
{
var builder = new ContainerBuilder();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly())
.OnActivated((e) =>
@lmauri
lmauri / gist:3957779
Created October 26, 2012 09:11
Force the dismiss of the keyboard on ios with monotouch
public static void DismissKeyboard(UIView view)
{
if (AppManager.IsKeyboardVisible)
{
var text = new UITextField(RectangleF.Empty);
view.AddSubview(text);
text.BecomeFirstResponder();
text.ResignFirstResponder();
text.RemoveFromSuperview();
text.Dispose();
@lmauri
lmauri / AssemblyInfo.cs
Created October 25, 2012 07:25
Fix to ATMHud monotouch bindings to compile against ARM7 only runtime
using System;
using MonoTouch.ObjCRuntime;
[assembly: LinkWith ("libATMHudSDK.a", LinkTarget.Simulator | LinkTarget.ArmV7, ForceLoad = true, Frameworks="AudioToolbox QuartzCore CoreGraphics")]