protected virtual void InitializeStructureMap(IInitializationExpression ex)
 {
     ex.ForSingletonOf<SparkViewFactory>();
     ex.For<IServiceLocator>().Use<StructureMapServiceLocator>();
     ex.For<ISparkSettings>().Use(GetSparkSettings);
     ex.For(typeof(ISparkViewRenderer<>)).Use(typeof(SparkViewRenderer<>));
 }
Exemplo n.º 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 ConfigureConfiguration(IInitializationExpression x)
        {
            var outputLanguage = ConfigurationManager.AppSettings["OutputLanguage"];
            switch (outputLanguage)
            {
                case "C#":
                    x.For<ICodeWriter>().Use<CSharpCodeWriter>();
                    break;
                case "VB":
                    x.For<ICodeWriter>().Use<VBCodeWriter>();
                    break;
                default:
                    throw new NotImplementedException("OutputLanguage value in config file must be one of the following: C#, VB.");
            }

            var testFramework = ConfigurationManager.AppSettings["TestFramework"];
            switch (testFramework)
            {
                case "MSTest":
                    x.For<IConfiguration>().Use<MSTestConfiguration>();
                    break;
                case "NUnit":
                    x.For<IConfiguration>().Use<NUnitConfiguration>();
                    break;
                default:
                    throw new NotImplementedException("TestFramework value in config file must be one of the following: MSTest, NUnit.");
            }
        }
Exemplo n.º 5
0
 static void wire_up_domain(IInitializationExpression x)
 {
     x.For<IQuoteRepository>().Use<QuoteRepository>();
     //x.For<ISqlJobMetricRepository>().Use<MockupSqlJobMetricRepository>();
     x.For<ISqlJobMetricRepository>().Use<SqlJobMetricRepository>();
     //x.For<IErrorLogRepository>().Use<mockupErrorLogRepository>();
     x.For<IErrorLogRepository>().Use<ErrorLogRepository>();
 }
Exemplo n.º 6
0
 private static void InitializeInfrastructure(IInitializationExpression e)
 {
     e.For<IMessageHandler>().Use<MessageHandler>();
     e.For<IChannelWrapper>().Use<ChannelWrapper>();
     e.For<IRuleLoader>().Use<RuleLoader>();
     e.For<IRuleEngine>().Use<RuleEngine>();
     e.For<NotificationConsumer>().Use<NotificationConsumer>();
 }
Exemplo n.º 7
0
        private static void InitializeInfrastructure(IInitializationExpression e)
        {
            // Transient
            e.For<IHttpContextHandler>().Use<HttpContextHandler>();
            e.For<IChannelWrapper>().Use<ChannelWrapper>();

            // Singleton
            e.For<IMessageBusSender>().Singleton().Use<MessageBusSender>();
            e.For<IUrlBuilder>().Singleton().Use<UrlBuilder>();
            e.For<IJavaScriptTimeCalculator>().Singleton().Use<JavaScriptTimeCalculator>();
        }
        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);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Facilitate manual configuration of container
        /// </summary>
        /// <param name="exp"></param>
        public static void ManualStructuremapSetup(IInitializationExpression exp, string hubConnectionString, string localConnectionString)
        {
            exp.For<CokeDataContext>()
                .Use<CokeDataContext>()
                 .Ctor<string>("connectionString")
                .Is(hubConnectionString);
            exp.For<DistributrLocalContext>().Use<DistributrLocalContext>().Ctor<string>("connectionString").Is(localConnectionString);
            //exp.For<ICacheProvider>().Use(DefaultCacheProvider.GetInstance());
            exp.For<IDTOToEntityMapping>().Use<DTOToEntityMapping>();

            foreach (var item in WPFRepositoryDefaultServices.DefaultServiceList())
            {
                exp.For(item.Item1).Use(item.Item2);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Called when [initialize].
        /// </summary>
        /// <param name="x">The x.</param>
        private static void OnInitialize(IInitializationExpression x)
        {
            ////MainWindow
            x.For <IMainWindow>().Singleton().Use <MainWindow>();
            x.For <IMainWindowViewModel>().Singleton().Use <MainWindowViewModel>();

            ////PWPMain
            x.For <IPWPMainView>().Singleton().Use <PWPMain>();
            x.For <IPWPMainViewModel>().Singleton().Use <PWPMainViewModel>();

            ////PromptOrigin
            x.For <IPromptOriginView>().Use <PromptOrigin>();
            x.For <IPromptOriginViewModel>().Use <PromptOriginViewModel>();

            ////PromptWindow
            x.For <IPromptWindow>().Use <PromptWindow>();
            x.For <IPromptWindowViewModel>().Use <PromptWindowViewModel>();

            ////Prompt
            x.For <IPromptView>().Use <Prompt>();
            x.For <IPromptViewModel>().Use <PromptViewModel>();
        }
Exemplo n.º 11
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();
            });
        }
Exemplo n.º 12
0
        static void wire_up_database(IInitializationExpression r)
        {
            var encrypted_connection_strings = ConfigurationManager.ConnectionStrings;

            r.ForSingletonOf<ICrypto>().Use<Crypto>()
                .Ctor<String>("masterCipher").EqualToAppSetting("PassPhrase");

            r.ForSingletonOf<IConnectionStringManager>()
              .Use<ConnectionStringManager>()
              .Ctor<ConnectionStringSettingsCollection>("encryptedConnections").Is(encrypted_connection_strings)
              .Ctor<bool>("ignoreLocalSqlServer").Is(true);

            r.For<IDbConnection>().Use<SqlConnection>()
                .Ctor<string>("connectionString").Is(
                    x => x.GetInstance<IConnectionStringManager>().Find("dashboard_connection_string").ConnectionString);
        }
		protected override void InitializeContainer(IInitializationExpression initializationExpression)
		{
			base.InitializeContainer(initializationExpression);
			initializationExpression.For<IPluginContext>().HybridHttpOrThreadLocalScoped().Use<PluginContext>();
		}
Exemplo n.º 14
0
 public static void Activate(this IInitializationExpression expression, string description, Action activation)
 {
     expression.For <IActivator>().Add <LambdaActivator>()
     .Ctor <string>().Is(description)
     .Ctor <Action>().Is(activation);
 }
Exemplo n.º 15
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>();
            x.For <IActiveDirectoryProvider>().Use <ActiveDirectoryProvider>();
        }
Exemplo n.º 16
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
        }
Exemplo n.º 17
0
 protected override void InitializeContainer(IInitializationExpression initializationExpression)
 {
     base.InitializeContainer(initializationExpression);
     initializationExpression.For <IPluginContext>().HybridHttpOrThreadLocalScoped().Use <PluginContext>();
 }
 private static void InitStructureMap(IInitializationExpression x)
 {
     x.For<IFileSystem>().Use(() => TestContext.Current.FileSystemMoq.Object);
 }
Exemplo n.º 19
0
 public static void Initialize(IInitializationExpression x)
 {
     x.For<IDataStore>().Use<TellHerDb>();
 }
Exemplo n.º 20
0
        private static void OnInitialize(IInitializationExpression x)
        {
            x.For <IMainWindow>().Singleton().Use <MainWindow>();
            x.For <IMainWindowViewModel>().Singleton().Use <MainWindowViewModel>();

            x.For <ILoadDataView>().Use <LoadDataView>();
            x.For <ILoadDataViewModel>().Use <LoadDataViewModel>();

            x.For <IGetRecommendationValueView>().Use <GetRecommendationValueView>();
            x.For <IGetRecommendationValueViewModel>().Use <GetRecommendationValueViewModel>();

            x.For <IAddUserView>().Use <AddUserView>();
            x.For <IAddUserViewModel>().Use <AddUserViewModel>();

            x.For <IAddMovieView>().Use <AddMovieView>();
            x.For <IAddMovieViewModel>().Use <AddMovieViewModel>();

            x.For <IAddRatingView>().Use <AddRatingView>();
            x.For <IAddRatingViewModel>().Use <AddRatingViewModel>();

            x.For <IRecommendView>().Use <RecommendView>();
            x.For <IRecommendViewModel>().Use <RecommendViewModel>();

            x.For <IEvaluateView>().Use <EvaluateView>();
            x.For <IEvaluateViewModel>().Use <EvaluateViewModel>();

            x.For <ILoadResultsView>().Use <LoadResultsView>();
            x.For <ILoadResultsViewModel>().Use <LoadResultsViewModel>();

            x.For <IDataRepository>().Singleton().Use <InMemoryDataRepository>();
            x.Policies.SetAllProperties(y => y.OfType <IDataRepository>());

            x.For <IRecommendationsProvider>().Use <RecommendationsProvider>();

            x.For <IEvaluatorsProvider>().Singleton().Use <EvaluatorsProvider>();
        }
Exemplo n.º 21
0
 public static void ConfigureDependencies(IInitializationExpression init)
 {
     init.For<IGlobalData>().Use<UnitData>().Named("Unit");
     init.For<IGlobalData>().Use<ArticleData>().Named("Article");
 }
Exemplo n.º 22
0
 public static void Initialize(IInitializationExpression obj)
 {
     obj.For<IJobService>().Use(JobServiceProxyBuilder.Build);
 }
Exemplo n.º 23
0
 protected override void InitializeStructureMap(IInitializationExpression ex)
 {
     ex.For<IHttpSession>().Use<CurrentHttpContextSession>();
 }
Exemplo n.º 24
0
 public static void Initialize(IInitializationExpression x)
 {
     x.For <IDataStore>().Use <TellHerDb>();
 }
Exemplo n.º 25
0
 private static void InitializeInfrastructure(IInitializationExpression e)
 {
     e.For<IMessageBusSender>().Use<MessageBusSender>();
 }