This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ICar | |
{ | |
void ConnectBattery(); | |
void SendPowerToStarter(); | |
void AddFuelToCylinder(int cylinderNumber); | |
void AddAirToCylinder(int cylinderNumber); | |
void SendSparkToPlug(int plugNumber); | |
void TurnCrankshaft(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult Index() | |
{ | |
var m = Database.Open().Media.FindByName("KitKat Killer"); | |
return View(new Media{Name = m.Name, Url = m.Url}); | |
} | |
public class Media | |
{ | |
public int Id { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use OmniAuth::Builder do | |
provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET'] | |
provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET'] | |
end | |
get '/auth/:provider/callback' do | |
auth = request.env['omniauth.auth'] | |
user = User.where(:provider => auth["provider"], :uid => auth["uid"].to_i).first() || | |
User.create(:provider => auth["provider"], :uid => auth["uid"].to_i, :name => auth['info']['name']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make sure to add autofac to the project | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Autofac; | |
using Autofac.Configuration; | |
namespace ValidationTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void Should_Add_User() | |
{ | |
var user = new UserInput {Email = "autotest@example.com", FirstName = "automated", LastName = "user", Password = "abc"}; | |
using (var host = new InMemoryHost(new Configuration())) | |
{ | |
var req = new InMemoryRequest | |
{ | |
Uri = new Uri("http://localhost/users"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sql = new Sql().Append("declare @@result int") | |
.Append("exec GetData @userId, @date", | |
new {userId = userId, @date = DateTime.Now}) | |
.Append("select @@result); | |
var ret = Database.ExecuteScalar<int>(sql); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var returnCode = Database.ExecuteScalar<int>( | |
"exec GetData @userId, @date", | |
new {userId = userId, @date = DateTime.Now}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TYPE [dbo].[MyRecords] AS TABLE( | |
[Id] [int] NOT NULL, | |
[ModuleId] [int] NOT NULL, | |
[Code] [nvarchar](20) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, | |
PRIMARY KEY CLUSTERED | |
( | |
[Id] ASC, | |
[ModuleId] ASC, | |
[Code] ASC | |
)WITH (IGNORE_DUP_KEY = OFF) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ISqlProfiler | |
{ | |
bool Enabled { get;} | |
void Update(PetaPocoSqlInfo info); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SqlInfo | |
{ | |
public double Time { get; set; } | |
public string FormattedSql { get; set; } | |
public string Sql { get; set; } | |
public IDataParameterCollection Parameters { get; set; } | |
} |