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
using(var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["connSpionshopString"].ConnectionString)) | |
{ | |
connection.Open(); | |
string sql = "INSERT INTO dbo.Table(userId, imagePath, userComments, dateCommented) VALUES (@userId, @imagePath, @userComments, @dateCommented)"; | |
SqlCommand cmd = new SqlCommand(sql, connection); | |
cmd.Parameters.Add("@userId", SqlDbType.Int).value = userId | |
cmd.Parameters.Add("@imagePath", SqlDbType.Varchar, 50).value = imagePath; | |
cmd.Parameters.Add("@userComments", SqlDbType.Varchar, 50).value = userComments; | |
cmd.Parameters.Add("@dateCommented", SqlDbType.DateTime).value = dateCommented; | |
cmd.CommandType = CommandType.Text; |
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
[Serializable] | |
public class Blobbed<T> : IUserType where T : class | |
{ | |
public new bool Equals(object x, object y) | |
{ | |
if (x == null && y == null) | |
return true; | |
if (x == null || y == null) | |
return false; |
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 LocalizationService : ILocalizationService | |
{ | |
//some injections | |
//... | |
//ctor | |
//... | |
public virtual string GetResource(string resourceKey) | |
{ |
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
//necessary to call custom binding (method Create in my model) | |
public class BindingExtensions : IModelBinder | |
{ | |
public object Bind(NancyContext context, Type modelType, object instance, BindingConfig configuration, params string[] blackList) | |
{ | |
var data = GetDataFields(context); | |
var model = QueryHistoryConfigurationModel.Create(data); | |
return model; |
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 abstract class CarFactory | |
{ | |
public abstract Car CreateSportsCar(); | |
public abstract Car CreateFamilyCar(); | |
} | |
public abstract class Car | |
{ | |
public abstract string CompareSpeed(Car car); | |
} |