Example #1
0
 /// <summary>
 /// Add FluenValidation
 /// </summary>
 /// <param name="mvcCoreBuilder"></param>
 /// <param name="typeSearcher"></param>
 private static void AddFluentValidation(IMvcCoreBuilder mvcCoreBuilder, ITypeSearcher typeSearcher)
 {
     //Add fluentValidation
     mvcCoreBuilder.AddFluentValidation(configuration =>
     {
         var assemblies = typeSearcher.GetAssemblies();
         configuration.RegisterValidatorsFromAssemblies(assemblies);
         configuration.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
         //implicit/automatic validation of child properties
         configuration.ImplicitlyValidateChildProperties = true;
     });
 }
Example #2
0
 /// <summary>
 /// Add FluenValidation
 /// </summary>
 /// <param name="mvcCoreBuilder"></param>
 /// <param name="typeSearcher"></param>
 private static void AddFluentValidation(IMvcCoreBuilder mvcCoreBuilder, ITypeSearcher typeSearcher)
 {
     //Add fluentValidation
     mvcCoreBuilder.AddFluentValidation(configuration =>
     {
         var assemblies = typeSearcher.GetAssemblies();
         configuration.RegisterValidatorsFromAssemblies(assemblies);
         configuration.DisableDataAnnotationsValidation = true;
         //implicit/automatic validation of child properties
         configuration.ImplicitlyValidateChildProperties = true;
     });
 }
Example #3
0
        /// <summary>
        /// Register type Converters
        /// </summary>
        /// <param name="typeSearcher"></param>
        private static void RegisterTypeConverter(ITypeSearcher typeSearcher)
        {
            //find converters provided by other assemblies
            var converters = typeSearcher.ClassesOfType <ITypeConverter>();

            //create and sort instances of typeConverter
            var instances = converters
                            .Select(converter => (ITypeConverter)Activator.CreateInstance(converter))
                            .OrderBy(converter => converter.Order);

            foreach (var item in instances)
            {
                item.Register();
            }
        }
Example #4
0
        /// <summary>
        /// Run startup tasks
        /// </summary>
        /// <param name="typeSearcher">Type finder</param>
        private static void ExecuteStartupTasks(ITypeSearcher typeSearcher)
        {
            //find startup tasks provided by other assemblies
            var startupTasks = typeSearcher.ClassesOfType <IStartupTask>();

            //create and sort instances of startup tasks
            var instances = startupTasks
                            .Select(startupTask => (IStartupTask)Activator.CreateInstance(startupTask))
                            .OrderBy(startupTask => startupTask.Order);

            //execute tasks
            foreach (var task in instances)
            {
                task.Execute();
            }
        }
Example #5
0
        /// <summary>
        /// Register and init AutoMapper
        /// </summary>
        /// <param name="typeSearcher">Type finder</param>
        private static void InitAutoMapper(ITypeSearcher typeSearcher)
        {
            //find mapper configurations provided by other assemblies
            var mapperConfigurations = typeSearcher.ClassesOfType <IAutoMapperProfile>();

            //create and sort instances of mapper configurations
            var instances = mapperConfigurations
                            .Where(mapperConfiguration => PluginExtensions.OnlyInstalledPlugins(mapperConfiguration))
                            .Select(mapperConfiguration => (IAutoMapperProfile)Activator.CreateInstance(mapperConfiguration))
                            .OrderBy(mapperConfiguration => mapperConfiguration.Order);

            //create AutoMapper configuration
            var config = new MapperConfiguration(cfg =>
            {
                foreach (var instance in instances)
                {
                    cfg.AddProfile(instance.GetType());
                }
            });

            //register automapper
            AutoMapperConfig.Init(config);
        }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="typeSearcher">Type finder</param>
 public GeneralShipmentTracker(ITypeSearcher typeSearcher)
 {
     _typeSearcher = typeSearcher;
 }