Skip to content

Instantly share code, notes, and snippets.

View fabriciosanchez's full-sized avatar

Fabrício Sanchez fabriciosanchez

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;
using System.Net.Mime;
...
public bool EnviaMensagemComSendGrid()
{
@fabriciosanchez
fabriciosanchez / gist:9552858
Last active August 29, 2015 13:57
IRepositoryGeneral
public interface IRepositorioGeneral
{
List<VideosRetornados> RetornaQuatroVideosMaisRecentes();
}
@fabriciosanchez
fabriciosanchez / gist:9553523
Created March 14, 2014 18:14
Repository_General
public class Repository_General: IRepositorioGeneral, IDisposable
{
...
public SeuModeloDeDados db = new SeuModeloDeDados();
private bool disposed = false;
public void Dispose()
{
Dispose(true);
@fabriciosanchez
fabriciosanchez / gist:9553932
Created March 14, 2014 18:36
KernelNinject
...
kernel.Bind<IRepositorioGeneral>().To<Repository_General>();
...
@fabriciosanchez
fabriciosanchez / gist:9554117
Created March 14, 2014 18:44
PrincipalController
public class PrincipalController : Controller
{
[Inject]
public IRepositorioGeneral RGeneral { get; set; }
...
public JsonResult CarregarVideosMaisRecentes()
{
return Json(RGeneral.RetornaQuatroVideosMaisRecentes(), JsonRequestBehavior.AllowGet);
using AppFunc = Func<
IDictionary<string, object>, // Ambiente
Task>; // Tarefa retornada
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();
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();
}
}
public class Startup
{
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
config.Routes.MapHttpRoute("default", "{controller}");
app.UseWebApi(config);
}
}
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)