Skip to content

Instantly share code, notes, and snippets.

View robinvanderknaap's full-sized avatar

Robin van der Knaap robinvanderknaap

View GitHub Profile
public class ViewBaseClass<TModel> : DefaultTemplateBase<TModel>
{
private readonly ITranslationService _translationService;
private CultureInfo _culture;
public ViewBaseClass(ITranslationService translationService, IApplicationSettings applicationSettings)
{
_translationService = translationService;
ApplicationSettings = applicationSettings;
}
var mailMessage = new MailMessage();
string eml = mailMessage.ToEml();
using System.IO;
using System.Net.Mail;
using System.Reflection;
using System.Text;
namespace Infrastructure.MailMessageExtensions
{
public static class MailMessageExtensions
{
public static string ToEml(this MailMessage message)
@(Html.Grid("basic")
.SetCaption("Basic Grid")
.AddColumn(new Column("CustomerId")
.SetLabel("Id"))
.AddColumn(new Column("Name"))
.AddColumn(new Column("Company"))
.AddColumn(new Column("EmailAddress"))
.AddColumn(new Column("Last Modified"))
.AddColumn(new Column("Telephone"))
.SetUrl("/Home/GridData/")
public JsonResult GridData(GridSettings gridSettings)
{
...
}
NinjectValidatorFactory ninjectValidatorFactory = new NinjectValidatorFactory(Kernel);
FluentValidationModelValidatorProvider
.Configure(x => x.ValidatorFactory = ninjectValidatorFactory);
DataAnnotationsModelValidatorProvider
.AddImplicitRequiredAttributeForValueTypes = false;
AssemblyScanner.FindValidatorsInAssembly( Assembly.GetExecutingAssembly())
.ForEach(match => kernel.Bind(match.InterfaceType).To(match.ValidatorType));
public class User
{
public int Id { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
public string Email { get; set; }
public DateTime DateOfBirth { get; set; }
}
// Create factory for poco's and setup datasources
var pocoFactory = AutoPocoContainer.Configure(x =>
{
x.Conventions(c => c.UseDefaultConventions());
x.AddFromAssemblyContainingType<User>();
x.Include<User>()
.Setup(u => u.Email).Use<EmailAddressSource>()
.Setup(u => u.Firstname).Use<FirstNameSource>()
.Setup(u => u.Lastname).Use<LastNameSource>()
.Setup(u => u.DateOfBirth).Use<DateOfBirthSource>();
public class ExampleSource : DatasourceBase<string>
{
public override string Next(IGenerationContext context)
{
throw new NotImplementedException();
}
}