Skip to content

Instantly share code, notes, and snippets.

View marcioalthmann's full-sized avatar

Márcio Fábio Althmann marcioalthmann

View GitHub Profile
@marcioalthmann
marcioalthmann / DadosBase.cs
Created February 6, 2011 17:13
Classe de acesso a dados, onde não existia EF e eu não usava NHibernate.
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using System.Reflection;
using System.Web;
@marcioalthmann
marcioalthmann / gist:1023026
Created June 13, 2011 15:47
Criando um Worker para o MassTransit, definindo a quantidade de consumidores concorrentes
DataBus = ServiceBusFactory.New(x =>
{
x.ReceiveFrom(ConfigurationManager.AppSettings["SourceQueue"]);
x.SetPurgeOnStartup(false);
x.UseMsmq();
x.UseMulticastSubscriptionClient(m => m.SetNetworkKey(ConfigurationManager.AppSettings["NetworkName"]));
x.SetConcurrentConsumerLimit(4);
x.UseDistributorFor<DoSimpleWorkItem>();
@marcioalthmann
marcioalthmann / gist:1610042
Created January 14, 2012 02:50
Loops no C# inspirados em Ruby
3.Times(x => Console.Write("{0} ", x));
5.UpTo(10).Each(x => Console.Write("{0} ", x));
10.DownTo(5).Each(x => Console.Write("{0} ", x));
@marcioalthmann
marcioalthmann / gist:2554759
Created April 30, 2012 01:40
Primeiros testes com o RavenDB
[TestClass]
public class RavenDbTests
{
private DocumentStore _documentStore;
[TestInitialize]
public void Inicializacao()
{
_documentStore = new DocumentStore{Url = "http://localhost:8080"};
_documentStore.Initialize();
@marcioalthmann
marcioalthmann / RavenDB.Testes.cs
Created May 4, 2012 00:30
RavenDB: DocumentStore
private IDocumentStore _documentStore;
[TestInitialize]
public void Inicializacao()
{
_documentStore = new DocumentStore {Url = "http://localhost:8080"};
_documentStore.Initialize();
}
@marcioalthmann
marcioalthmann / RavenDB.Testes.cs
Created May 4, 2012 00:42
RavenDB: DocumentSession
using(IDocumentSession session = _documentStore.OpenSession())
{
session.Store(album);
session.SaveChanges();
}
@marcioalthmann
marcioalthmann / const.cs
Created May 14, 2012 03:54
const keyword
const double pi = 3.14;
// erro de compilação
pi = 3.15;
@marcioalthmann
marcioalthmann / readonly.cs
Created May 14, 2012 04:02
keyword readonly
class Foo
{
private readonly double _pi = 3.14;
private readonly double _foo;
public Foo()
{
_foo = Double.MaxValue;
}
var nomes = new List<string>();
for (int i = 0; i < 1000; i++)
{
nomes.Add("Althmann");
}
Console.WriteLine("Digite o mesmo texto várias vezes.");
while (true)
@marcioalthmann
marcioalthmann / StringIntern.cs
Created May 16, 2012 00:50
Usando String.Intern
var nomes = new List<string>();
for (int i = 0; i < 1000; i++)
{
nomes.Add("Althmann");
}
Console.WriteLine("Agora usando String.Intern");
Console.WriteLine("Digite o mesmo texto várias vezes.");