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
| private static void ConfigureIocAndAop() | |
| { | |
| var builder = new ContainerBuilder(); | |
| //If using an IOC container, it is a handy to be able to us an IProfiler to | |
| //wrap mini profiler calls just to remove that dependency for unit testing | |
| builder.RegisterType<MiniProfilerWrapper>().AsImplementedInterfaces(); | |
| //We want some classes that do some work, but we don't want to have to wrap profiler steps | |
| //around each method call, so use AOP to do it for us! |
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 Snap; | |
| namespace ConsoleApplicationWithIocAndAop.AOP | |
| { | |
| public class ProfileMethodAttribute : MethodInterceptAttribute | |
| { | |
| } | |
| } |
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 System; | |
| using System.Reflection; | |
| using Castle.DynamicProxy; | |
| using Snap; | |
| using StackExchange.Profiling; | |
| namespace ConsoleApplicationWithIocAndAop.AOP | |
| { | |
| public class ProfileMethodInterceptor : MethodInterceptor | |
| { |
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
| private static void Main(string[] args) | |
| { | |
| //Configure building blocks | |
| ConfigureIocAndAop(); | |
| //Start profiling | |
| ConsoleProfiling.Start(); | |
| //Run the application, the log is all behind the IConsoleApplication's Run method so it can be easily unit tested | |
| var app = _container.Resolve<IConsoleApplication>(); |
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 Model : IValidatableObject | |
| { | |
| [Display(Name = "Send to (email)")] | |
| [Required(ErrorMessage = "'{0}' must be supplied")] | |
| [RegularExpression(@".+\@.", ErrorMessage = "{0}' must be an email address")] | |
| public override string ToEmailAddress { get; set; } | |
| public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) | |
| { | |
| ValidationResult emailInvalidError = null; |
OlderNewer