Skip to content

Instantly share code, notes, and snippets.

Avatar

Fabrício Sanchez fabriciosanchez

View GitHub Profile
View gist:9050625
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;
using System.Net.Mime;
...
public bool EnviaMensagemComSendGrid()
{
View gist:9553932
...
kernel.Bind<IRepositorioGeneral>().To<Repository_General>();
...
View gist:9553523
public class Repository_General: IRepositorioGeneral, IDisposable
{
...
public SeuModeloDeDados db = new SeuModeloDeDados();
private bool disposed = false;
public void Dispose()
{
Dispose(true);
View gist:9554117
public class PrincipalController : Controller
{
[Inject]
public IRepositorioGeneral RGeneral { get; set; }
...
public JsonResult CarregarVideosMaisRecentes()
{
return Json(RGeneral.RetornaQuatroVideosMaisRecentes(), JsonRequestBehavior.AllowGet);
@fabriciosanchez
fabriciosanchez / gist:9552858
Last active Aug 29, 2015
IRepositoryGeneral
View gist:9552858
public interface IRepositorioGeneral
{
List<VideosRetornados> RetornaQuatroVideosMaisRecentes();
}
View gist:2fad8bf8d31db8099476
using AppFunc = Func<
IDictionary<string, object>, // Ambiente
Task>; // Tarefa retornada
@fabriciosanchez
fabriciosanchez / gist:fce19172b3955cfa2ffe
Created May 26, 2014
Adicionando classe ao pipeline
View gist:fce19172b3955cfa2ffe
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.Use<LoggerMiddleware>(new TraceLogger());
}
}
View gist:942a92f1a34a9cd83560
static void Main(string[] args)
{
const string baseUrl = "http://localhost:5000/";
using (WebApplication.Start<Startup>(new StartOptions { Url = baseUrl }))
{
Console.WriteLine("Press Enter to quit.");
Console.ReadKey();
}
}
View gist:6fb65ad078f0811eeda4
public class LoggerMiddleware : OwinMiddleware
{
private readonly ILog _logger;
public LoggerMiddleware(OwinMiddleware next, ILog logger) : base(next)
{
_logger = logger;
}
public override async Task Invoke(IOwinContext context)
View gist:b5b54b966597a8ed42e3
static void Main()
{
var baseAddress = new Uri("http://localhost:5000");
var config = new HttpSelfHostConfiguration(baseAddress);
config.Routes.MapHttpRoute("default", "{controller}");
using (var svr = new HttpSelfHostServer(config))
{
svr.OpenAsync().Wait();