Пример #1
0
        public static void CreateFactory <PLUGINTYPE>(this CreatePluginFamilyExpression <PLUGINTYPE> expression)
            where PLUGINTYPE : class
        {
            var callback = CreateFactoryCallback <PLUGINTYPE>();

            expression.Use(callback);
        }
        public static void CreateFactory <TPluginType>(this CreatePluginFamilyExpression <TPluginType> expression)
            where TPluginType : class
        {
            var callback = CreateFactoryCallback <TPluginType>();

            expression.Use(callback);
        }
Пример #3
0
        public static void CreateFactory <TPluginType>(this CreatePluginFamilyExpression <TPluginType> expression)
            where TPluginType : class
        {
            var callback = CreateFactoryCallback <TPluginType>();

            expression.Use("AutoFactory builder for " + typeof(TPluginType).GetFullName(), callback);
        }
        public static void CreateFactory <TPluginType>(this CreatePluginFamilyExpression <TPluginType> expression,
                                                       IAutoFactoryConventionProvider conventionProvider)
            where TPluginType : class
        {
            var callback = CreateFactoryCallback <TPluginType>(conventionProvider);

            expression.Use(GetDescription <TPluginType>(), callback);
        }
Пример #5
0
        public DecoratorHelper(CreatePluginFamilyExpression <TTarget> target)
        {
            ContextEnrichmentHandler <TTarget> callback = (ctx, t) => t;

            _decorateCommand = e =>
            {
                callback = e;
            };

            target.EnrichAllWith((ctx, t) => callback(ctx, t));
        }
        public void BuildPluginFamilyAsSingleton()
        {
            var registry = new Registry();
            CreatePluginFamilyExpression <IGateway> expression =
                registry.For <IGateway>().Singleton();

            Assert.IsNotNull(expression);

            PluginGraph  pluginGraph = registry.Build();
            PluginFamily family      = pluginGraph.Families[typeof(IGateway)];

            family.Lifecycle.ShouldBeOfType <SingletonLifecycle>();
        }
Пример #7
0
 internal void Register(
     CreatePluginFamilyExpression <TInter> @for,
     SmartInstance <TImpl, TInter> use,
     string instanceName,
     DILifeTime lifetime,
     Action <DILifeTime, LambdaInstance <TImpl, TInter> > setLifeTime)
 {
     this.@for         = @for;
     this.use          = use;
     this.instanceName = instanceName;
     this.lifetime     = lifetime;
     this.setLifeTime  = setLifeTime;
 }
        public void AsAnotherScope()
        {
            var registry = new Registry();
            CreatePluginFamilyExpression <IGateway> expression =
                registry.For <IGateway>(Lifecycles.ThreadLocal);

            Assert.IsNotNull(expression);

            PluginGraph pluginGraph = registry.Build();

            PluginFamily family = pluginGraph.Families[typeof(IGateway)];

            family.Lifecycle.ShouldBeOfType <ThreadLocalStorageLifecycle>();
        }
        public void AsAnotherScope()
        {
            var registry = new Registry();
            CreatePluginFamilyExpression <IGateway> expression =
                registry.BuildInstancesOf <IGateway>().CacheBy(InstanceScope.ThreadLocal);

            Assert.IsNotNull(expression);

            PluginGraph pluginGraph = registry.Build();

            PluginFamily family = pluginGraph.FindFamily(typeof(IGateway));

            family.Lifecycle.ShouldBeOfType <ThreadLocalStorageLifecycle>();
        }
        public void BuildPluginFamilyAsPerRequest()
        {
            var registry = new Registry();
            CreatePluginFamilyExpression <IGateway> expression =
                registry.BuildInstancesOf <IGateway>();

            Assert.IsNotNull(expression);

            PluginGraph pluginGraph = registry.Build();

            PluginFamily family = pluginGraph.FindFamily(typeof(IGateway));

            family.Lifecycle.ShouldBeNull();
        }
Пример #11
0
 public static void CreateFactory <TPluginType>(this CreatePluginFamilyExpression <TPluginType> expression)
     where TPluginType : class
 {
     CreateFactory(expression, new DefaultAutoFactoryConventionProvider());
 }
 public StructureMapMapping(Registry registry, Func <IServiceLocator, TInterface> function)
 {
     _for = registry.For <TInterface>();
     _for.Use(() => function(ServiceLocator.Current));
 }
 public StructureMapMapping(Registry registry, Func <TInterface> function)
 {
     _for = registry.For <TInterface>();
     _for.Use(function);
 }
 public StructureMapMapping(Registry registry)
 {
     _for     = registry.For <TInterface>();
     _mapping = _for.Use <TImplementation>();
 }
        public static CreatePluginFamilyExpression <TPlugin> TransientOrHybridHttpScoped <TPlugin>(this CreatePluginFamilyExpression <TPlugin> expression)
        {
            if (BootstrapRegistry.MaintainAspNetCompatibility)
            {
                return(expression.HybridHttpOrThreadLocalScoped());
            }

            return(expression);
        }
 public static DecoratorHelper <TTarget> Decorate <TTarget>(this CreatePluginFamilyExpression <TTarget> target)
 {
     return(new DecoratorHelper <TTarget>(target));
 }
Пример #17
0
 public FeatureTogglingContext(Predicate <ITpFeatureList> condition, CreatePluginFamilyExpression <TService> expression)
 {
     _condition  = condition;
     _expression = expression;
 }
Пример #18
0
 public static FeatureTogglingContext <TService> IfFeatureEnabled <TService>(this CreatePluginFamilyExpression <TService> expr, TpFeature feature)
 {
     return(new FeatureTogglingContext <TService>(features => features.IsEnabled(feature), expr));
 }
Пример #19
0
 public static FeatureTogglingContext <TService> IfFeatureEnabled <TService>(this CreatePluginFamilyExpression <TService> expr, Predicate <ITpFeatureList> condition)
 {
     return(new FeatureTogglingContext <TService>(condition, expr));
 }
Пример #20
0
 /// <summary>
 /// Convenience method to mark a PluginFamily as HttpContext scoped
 /// </summary>
 /// <returns></returns>
 public static CreatePluginFamilyExpression <TPluginType> HttpContextScoped <TPluginType>(this CreatePluginFamilyExpression <TPluginType> source)
 {
     return(source.LifecycleIs(WebLifecycles.HttpContext));
 }
Пример #21
0
 /// <summary>
 /// Convenience method to mark a PluginFamily as a Hybrid lifecycle
 /// </summary>
 /// <returns></returns>
 public static CreatePluginFamilyExpression <TPluginType> HybridHttpOrThreadLocalScoped <TPluginType>(this CreatePluginFamilyExpression <TPluginType> source)
 {
     return(source.LifecycleIs(WebLifecycles.Hybrid));
 }