This file contains hidden or 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 static string ToDisplayString(this Enum value) | |
{ | |
if (value == null) | |
{ | |
throw new ArgumentNullException("value"); | |
} | |
string description = value.ToString(); | |
EnumDescriptionAttribute[] attributes = (EnumDescriptionAttribute[])value.GetType().GetCustomAttributes(typeof(EnumDescriptionAttribute), false); |
This file contains hidden or 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
//użycie bezpośrednie napisu | |
var applicationName = ConfigurationManager.AppSettings["ApplicationName"]; | |
//skorzystanie z stałej | |
var applicationName = ConfigurationManager.AppSettings[SettingsNames.ApplicationName]; |
This file contains hidden or 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 EnumDescriptionAttribute : Attribute | |
{ | |
public Type ResourceType { get; set; } | |
public EnumDescriptionAttribute(Type resourceType) | |
{ | |
ResourceType = resourceType; | |
} | |
} |
This file contains hidden or 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 FilterConfig | |
{ | |
public static void RegisterGlobalFilters(GlobalFilterCollection filters) | |
{ | |
filters.Add(new LogFilterAttribute()); | |
} | |
} |
This file contains hidden or 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 (DataContext db = new DataContext()) | |
{ | |
db.Database.Log = m => _logger.Info(m); | |
var product = db.Products.FirstOrDefault(p => p.Id == productId); | |
if (product == null) | |
{ | |
return; | |
} |
This file contains hidden or 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 BaseIntegrationTests | |
{ | |
protected Lazy<IEmailServiceFactory> CreateEmailServiceFactory() | |
{ | |
return new Lazy<IEmailServiceFactory>(() => | |
new EmailServiceFactory(new Lazy<IHostingEnviromentService>(() => new TestHostingEnviromentService()))); | |
} | |
} |
This file contains hidden or 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 BaseMailer | |
{ | |
protected void Send(Email email) | |
{ | |
var mailerName = GetType().Name.Replace("Mailer", string.Empty); | |
var viewsPath = Path.GetFullPath(string.Format(HostingEnvironment.MapPath(@"~/Views/Emails/{0}"), mailerName)); | |
var engines = new ViewEngineCollectionWithoutResolver(); | |
engines.Add(new FileSystemRazorViewEngine(viewsPath)); |
This file contains hidden or 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
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/elmah" /> | |
<errorMail from="[email protected]" to="[email protected]" subject="Application Exception" async="false" smtpPort="25" smtpServer="***" userName="***" password="***" /> |
This file contains hidden or 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 static class IRuleBuilderExtensions | |
{ | |
public static IRuleBuilderOptions<T, TProperty> Nip<T, TProperty>(this IRuleBuilder<T, TProperty> ruleBuilder) | |
{ | |
return ruleBuilder.SetValidator(new NipValidator()); | |
} | |
} |
This file contains hidden or 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
static void Main(string[] args) | |
{ | |
var user = new User() | |
{ | |
CreateInvoice = true, | |
Nip = "123", | |
Email = "[email protected]", | |
Orders = new List<Order>() | |
{ | |
new Order(){Product = "Laptop"}, |