private static void InitContainer(IInitializationExpression container)
        {
            container.Scan(
                scan =>
            {
                scan.TheCallingAssembly();
                scan.WithDefaultConventions();
            });

            container.For <ISessionContainer>().Use <HttpContextSessionContainer>();
            container.For <IConfigAccessor>().Use <FileConfigAccessor>();
            container.For <ILogger>().Use <Log4NetLogger>();
            container.For <IImageGenerator>().Use <ImageGenerator>();
            container.For <IIdentity>().Use(i => HttpContext.Current.User.Identity);
            container.For <INotificationSender>().Use <AsyncNotificationSender>();
            container.For <Markdown>().Use(
                new Markdown(new MarkdownOptions {
                AutoHyperlink = true, AutoNewLines = true, EncodeProblemUrlCharacters = true
            }));

            MailConfiguration mailConfiguration = new MailConfiguration
            {
                MailFrom = ConfigurationManager.AppSettings["mail-from"],
                SmtpHost = ConfigurationManager.AppSettings["mail-smtpHost"],
                Username = ConfigurationManager.AppSettings["mail-username"],
                Password = ConfigurationManager.AppSettings["mail-password"]
            };

            container.For <MailConfiguration>().Use(m => mailConfiguration);
        }
Exemple #2
0
        private static void InitializeContainer(IInitializationExpression exp)
        {
            exp.For <IDbContextManager>()
            .Use <DbContextManager>();

            exp.FillAllPropertiesOfType <IDbContextManager>()
            .Use <DbContextManager>();

            exp.For(typeof(ISimpleRepository <>))
            .Use(typeof(SimpleRepository <>));

            exp.For <IAuthentication>()
            .Use <Authentication>();

            exp.FillAllPropertiesOfType <IAuthentication>()
            .Use <Authentication>();

            exp.Scan(cfg =>
            {
                cfg.AssemblyContainingType <RepositoryBase>();
                cfg.IncludeNamespaceContainingType <RepositoryBase>();
                cfg.SingleImplementationsOfInterface();
            });

            AssemblyScanner.FindValidatorsInAssemblyContaining <RegistrationModelValidation>()
            .ForEach(result => exp.For(result.InterfaceType)
                     .Singleton()
                     .Use(result.ValidatorType));
        }
        public static LambdaInstance <object> ForRepositoriesUseSharpRepository(this IInitializationExpression initialization, string repositoryName = null)
        {
            initialization.Scan(scan => scan.IncludeNamespaceContainingType <IAmInRepository>());

            initialization.For(typeof(IRepository <>))
            .Use(context =>
            {
                var genericArgs = context.BuildStack.Current.RequestedType.GetGenericArguments();

                return(RepositoryFactory.GetInstance(genericArgs[0], repositoryName));
            }
                 );

            initialization.For(typeof(IRepository <,>))
            .Use(context =>
            {
                var genericArgs = context.BuildStack.Current.RequestedType.GetGenericArguments();

                return(RepositoryFactory.GetInstance(genericArgs[0], genericArgs[1], repositoryName));
            }
                 );

            return(initialization.For(typeof(ICompoundKeyRepository <, ,>))
                   .Use(context =>
            {
                var genericArgs = context.BuildStack.Current.RequestedType.GetGenericArguments();

                return RepositoryFactory.GetInstance(genericArgs[0], genericArgs[1], genericArgs[2], repositoryName);
            }
                        ));
        }
        private void Initialize(IInitializationExpression x)
        {
            x.Scan(Scan);

            // Web.config/app settings
            x.For <ApplicationSettings>().Singleton().Use(_applicationSettings);

            // Set the 2 core types to use HTTP/Thread-based lifetimes
            x.For <IRepository>().HybridHttpOrThreadLocalScoped();
            x.For <IUserContext>().HybridHttpOrThreadLocalScoped();

            // Plugins
            x.For <IPluginFactory>().Singleton().Use <PluginFactory>();

            // Screwturn importer
            x.For <IWikiImporter>().Use <ScrewTurnImporter>();

            // Cache
            x.For <ObjectCache>().Use(new MemoryCache("Roadkill"));
            x.For <ListCache>().Singleton();
            x.For <SiteCache>().Singleton();
            x.For <PageViewModelCache>().Singleton();
            x.For <IPluginCache>().Use <SiteCache>();

            // Site sttings
            x.For <ConfigReaderWriter>().Use <FullTrustConfigReaderWriter>();

            // Security
            x.For <IAuthorizationProvider>().Use <AuthorizationProvider>();
            x.For <IActiveDirectoryProvider>().Use <ActiveDirectoryProvider>();
        }
Exemple #5
0
 private static void Initialize(IInitializationExpression initializer)
 {
     initializer.Scan(Initialize);
     initializer.ForRequestedType<TextWriter>().TheDefault.Is.ConstructedBy(() => Console.Out);
     initializer.InstanceOf<IGitRepository>().Is.OfConcreteType<GitRepository>();
     AddGitChangeTypes(initializer);
     DoCustomConfiguration(initializer);
 }
Exemple #6
0
 private void ConfigureStructureMap(IInitializationExpression initializer)
 {
     initializer.Scan(y =>
     {
         y.Assembly("TodayIShall.Core");
         y.WithDefaultConventions();
     });
     initializer.ForRequestedType<IAuthCookieGenerator>().TheDefaultIsConcreteType<AuthCookieGenerator>();
     initializer.AddRegistry(new MongoRegistry());
 }
Exemple #7
0
        private static void SetScanningPolicy(IInitializationExpression x)
        {
            x.Scan(scan =>
            {
                scan.AssembliesFromApplicationBaseDirectory(
                    filter => filter.FullName.StartsWith("CleanArchitecture"));

                scan.WithDefaultConventions();
            });
        }
 private static void InitializeStructureMap(IInitializationExpression x)
 {
     x.Scan(y =>
     {
         y.TheCallingAssembly();
         y.WithDefaultConventions();
         y.AddAllTypesOf(typeof(IConsumer <>));
     }
            );
 }
Exemple #9
0
 private static void InitializeStructureMap(IInitializationExpression x)
 {
     x.Scan(y =>
     {
         y.Assembly("ILeaf.Core");
         y.Assembly("ILeaf.Repository");
         y.Assembly("ILeaf.Service");
         //y.Assembly("Senparc.Models");
         y.WithDefaultConventions();
     });
 }
Exemple #10
0
        /// <summary>
        /// Configure repository for ISS
        /// </summary>
        /// <param name="initialize"></param>
        public void Configure(IInitializationExpression initialize)
        {
            AutoMapperConfiguration.Instance.Configure();

            initialize.Scan(x =>
            {
                x.Assembly("Db.Interfaces");
                x.Assembly("Db.ImplementSQL");

                x.WithDefaultConventions();
            });
        }
Exemple #11
0
        public void Configure(IInitializationExpression initialize)
        {
            initialize.AddRegistry<CommonRegistry>();

            Db.ImplementSQL.Configuration.Instance.Configure(initialize);

            initialize.Scan(x =>
            {
                x.Assembly("Service.ContractImplement");
                x.WithDefaultConventions();
            });
        }
 private static void InitializeStructureMap(IInitializationExpression x)
 {
     x.Scan(y =>
     {
         y.Assembly("ShortestPath.Web");
         y.Assembly("ShortestPath.Core");
         y.With<DefaultConventionScanner>();
     }
     );
     x.AddRegistry<NHibernateRegistry>();
     x.ForRequestedType<IThreadCache>().CacheBy(InstanceScope.Hybrid).TheDefaultIsConcreteType<ThreadCache>();
 }
Exemple #13
0
        private static void InitializeStructureMap(IInitializationExpression x)
        {
            x.Scan(y =>
            {
                y.Assembly("ChuangLiTou.Core.IDal");
                y.WithDefaultConventions();
            });

            x.Scan(y =>
            {
                y.Assembly("ChuangLiTou.Core.ImplDal");
                y.WithDefaultConventions();
            });

            x.Scan(y =>
            {
                y.TheCallingAssembly();
                y.AddAllTypesOf <IController>()
                .NameBy(type => type.FullName != null ? type.FullName.ToLowerInvariant() : null);
            });
        }
Exemple #14
0
 public static void ScanMyCqrsTypes(IInitializationExpression initializationExpression)
 {
     initializationExpression.Scan(scan =>
                                   {
                                       scan.Assembly("MyCqrs");
                                       scan.TheCallingAssembly();
                                       scan.WithDefaultConventions();
                                       scan.ConnectImplementationsToTypesClosing(typeof (IViewFactory<,>));
                                       scan.ConnectImplementationsToTypesClosing(typeof (IViewFactory<>));
                                       scan.ConnectImplementationsToTypesClosing(typeof (ICommandHandler<>));
                                       scan.ConnectImplementationsToTypesClosing(typeof (IEventHandler<>));
                                   });
 }
Exemple #15
0
        /// <summary>
        /// Initializes StructureMap to scan the assemblies and setup all the
        /// needed elements.
        /// </summary>
        /// <param name="init"></param>
        private static void InitializeStructureMap(IInitializationExpression init)
        {
            init.Scan(
                s =>
            {
                // Determine which assemblies contain types we need.
                s.AssembliesFromApplicationBaseDirectory(
                    a => a.FullName.Contains("AuthorIntrusion"));

                // List all the assemblies we need. Since most of the
                // plugins are required to register IPlugin, we can just
                // add those types.
                s.AddAllTypesOf <IPlugin>();
            });
        }
Exemple #16
0
        private static void InitializeContainer(IInitializationExpression exp)
        {
            exp.For <IDbContextManager>()
            .Use <DbContextManager>();

            exp.FillAllPropertiesOfType <IDbContextManager>()
            .Use <DbContextManager>();

            exp.For(typeof(ISimpleRepository <>))
            .Use(typeof(SimpleRepository <>));

            exp.For <IAuthentication>()
            .Use <Authentication>();

            exp.FillAllPropertiesOfType <IAuthentication>()
            .Use <Authentication>();

            exp.Scan(cfg =>
            {
                cfg.AssemblyContainingType <RepositoryBase>();
                cfg.IncludeNamespaceContainingType <RepositoryBase>();
                cfg.SingleImplementationsOfInterface();
            });
        }
Exemple #17
0
        private void Initialize(IInitializationExpression x)
        {
            x.Scan(Scan);

            // Web.config/app settings
            x.For<ApplicationSettings>().Singleton().Use(_applicationSettings);

            // Set the 2 core types to use HTTP/Thread-based lifetimes
            x.For<IRepository>().HybridHttpOrThreadLocalScoped();
            x.For<IUserContext>().HybridHttpOrThreadLocalScoped();

            // Plugins
            x.For<IPluginFactory>().Singleton().Use<PluginFactory>();

            // Screwturn importer
            x.For<IWikiImporter>().Use<ScrewTurnImporter>();

            // Cache
            x.For<ObjectCache>().Use(new MemoryCache("Roadkill"));
            x.For<ListCache>().Singleton();
            x.For<SiteCache>().Singleton();
            x.For<PageViewModelCache>().Singleton();
            x.For<IPluginCache>().Use<SiteCache>();

            // Site sttings
            x.For<ConfigReaderWriter>().Use<FullTrustConfigReaderWriter>();

            // Security
            x.For<IAuthorizationProvider>().Use<AuthorizationProvider>();

            #if !MONO
            x.For<IActiveDirectoryProvider>().Use<ActiveDirectoryProvider>();
            #endif
        }