コード例 #1
0
    /// <summary>
    /// Constructor to use when troubleshooting possible configuration issues.
    /// </summary>
    /// <param name="family"></param>
    public InstanceFactory(PluginFamily family)
    {
        if (family == null)
            {
                throw new ArgumentNullException("family");
            }

            try
            {
                _lifecycle = family.Lifecycle;

                _pluginType = family.PluginType;
                MissingInstance = family.MissingInstance;

                family.Instances.Each(AddInstance);
            }
            catch (StructureMapException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new StructureMapException(115, e, family.PluginType.AssemblyQualifiedName);
            }
    }
コード例 #2
0
        private void RegisterInitialOrConfigure(Type serviceType, ILifecycle lifecycle, Action<GenericFamilyExpression> use)
        {
            var registry = this.initialRegistry ?? new Registry();
            use(registry.For(serviceType).LifecycleIs(lifecycle));

            if (this.container != null)
                this.container.Configure(c => c.AddRegistry(registry));
        }
コード例 #3
0
    public void SetScopeTo(InstanceScope scope)
    {
        if (scope == InstanceScope.Transient)
            {
                _lifecycle = null;
                return;
            }

            _lifecycle = Lifecycles.GetLifecycle(scope);
    }
コード例 #4
0
ファイル: PluginFamily.cs プロジェクト: stgwilli/structuremap
        public void SetScopeTo(InstanceScope scope)
        {
            if (scope == InstanceScope.Transient)
            {
                _lifecycle = null;
                return;
            }

            _lifecycle = Lifecycles.GetLifecycle(scope);
        }
コード例 #5
0
        /// <summary>
        /// Treat the current registration to use the passed lifecycle. (e.g. SingletonLifecycle, TrainsientLifecycle, ...).
        /// </summary>
        /// <param name="livecycle">The lifecycle instance</param>
        /// <returns>The instance itself to get fluent working.</returns>
        public IFluentRegistration ControlledBy(ILifecycle livecycle)
        {
            if (livecycle == null)
            {
                throw new ArgumentNullException(nameof(livecycle));
            }

            this._registrationItem.Lifecycle = livecycle;
            return(this);
        }
コード例 #6
0
 public ConventionServiceDefinition(
     Predicate <Type> predicate,
     Func <Type, IEnumerable <Type> > typeFinder,
     ILifecycle lifecycle,
     Func <ServiceRequest, bool> precondition)
 {
     _predicate    = predicate;
     _typeFinder   = typeFinder;
     _lifecycle    = lifecycle;
     _precondition = precondition;
 }
コード例 #7
0
        private void RegisterInitialOrConfigure(Type serviceType, ILifecycle lifecycle, Action <GenericFamilyExpression> use)
        {
            var registry = this.initialRegistry ?? new Registry();

            use(registry.For(serviceType).LifecycleIs(lifecycle));

            if (this.container != null)
            {
                this.container.Configure(c => c.AddRegistry(registry));
            }
        }
コード例 #8
0
ファイル: Container.cs プロジェクト: zhech2/towerInject
        /// <summary>
        /// Registers type <paramref name="implementationType"/> to be created when
        /// <paramref name="serviceType" /> is resolved.
        /// </summary>
        /// <param name="serviceType">The basetype or interface to register.</param>
        /// <param name="implementationType">The type that will be created or returned when resolving the service type.</param>
        /// <param name="lifecycle">The lifecycle object used to create the <see cref="IInstanceResolver"/>s and <see cref="InstanceResolver"/>s.</param>
        /// <param name="conflictBehavior">The behavior to use when there is another type already registered for the given service type.</param>
        /// <remarks>
        /// See <seealso cref="RegistratorExtensions"/> for additional ways to register types.
        /// </remarks>
        public void Register(Type serviceType,
                             Type implementationType,
                             ILifecycle lifecycle,
                             RegistrationConflictBehavior conflictBehavior)
        {
            if (serviceType == null)
            {
                throw new ArgumentNullException(nameof(serviceType));
            }
            if (implementationType == null)
            {
                throw new ArgumentNullException(nameof(implementationType));
            }
            if (!serviceType.IsAssignableFrom(implementationType))
            {
                throw new InvalidOperationException($"Cannot register '{implementationType.FullName}' as '{serviceType.FullName}' because it does not implement the service type.");
            }
            if (implementationType.IsAbstract || implementationType.IsInterface)
            {
                throw new InvalidOperationException($"Cannot create an instance of type '{implementationType.FullName}'.");
            }

            lifecycle = lifecycle ?? _options.DefaultLifecycle;

            var registration = lifecycle.CreateRegistration(serviceType, implementationType);

            _registrationMap.AddOrUpdate(serviceType,
                                         registration,
                                         (type, oldRegistration) =>
            {
                if (oldRegistration != null)
                {
                    conflictBehavior = conflictBehavior == RegistrationConflictBehavior.Default
                            ? _options.DefaultRegistrationConflictBehavior
                            : conflictBehavior;

                    switch (conflictBehavior)
                    {
                    case RegistrationConflictBehavior.Keep:
                        return(oldRegistration);

                    case RegistrationConflictBehavior.Replace:
                        return(registration);

                    default:
                    case RegistrationConflictBehavior.Throw:
                        throw new InvalidOperationException($"Service '{type}' has already been registered");
                    }
                }

                return(registration);
            });
        }
コード例 #9
0
ファイル: ModelHistory.cs プロジェクト: kiquenet/B4F
 public ModelHistory(IAccountTypeCustomer account, ILifecycle lifecycle, IPortfolioModel model, 
     bool isExecOnlyCustomer, AccountEmployerRelationship employerRelationship,
     IInternalEmployeeLogin employee, DateTime changeDate)
 {
     Account = account;
     Lifecycle = lifecycle;
     ModelPortfolio = model;
     IsExecOnlyCustomer = isExecOnlyCustomer;
     EmployerRelationship = employerRelationship;
     Employee = employee;
     ChangeDate = changeDate.Date;
 }
コード例 #10
0
        public async Task MixedShutdown()
        {
            var        stoppedBeans = new ConcurrentQueue <ILifecycle>();
            ILifecycle bean1        = TestLifecycleBean.ForShutdownTests(stoppedBeans);
            ILifecycle bean2        = TestSmartLifecycleBean.ForShutdownTests(500, 200, stoppedBeans);
            ILifecycle bean3        = TestSmartLifecycleBean.ForShutdownTests(int.MaxValue, 100, stoppedBeans);
            ILifecycle bean4        = TestLifecycleBean.ForShutdownTests(stoppedBeans);
            ILifecycle bean5        = TestSmartLifecycleBean.ForShutdownTests(1, 200, stoppedBeans);
            ILifecycle bean6        = TestSmartLifecycleBean.ForShutdownTests(-1, 100, stoppedBeans);
            ILifecycle bean7        = TestSmartLifecycleBean.ForShutdownTests(int.MinValue, 300, stoppedBeans);

            var processor = new DefaultLifecycleProcessor(CreateApplicationContext(new List <ILifecycle>()
            {
                bean1, bean2, bean3, bean4, bean5, bean6, bean7
            }, new List <ISmartLifecycle>()));
            await processor.OnRefresh();

            Assert.True(bean2.IsRunning);
            Assert.True(bean3.IsRunning);
            Assert.True(bean5.IsRunning);
            Assert.True(bean6.IsRunning);
            Assert.True(bean7.IsRunning);
            Assert.False(bean1.IsRunning);
            Assert.False(bean4.IsRunning);

            await bean1.Start();

            await bean4.Start();

            Assert.True(bean1.IsRunning);
            Assert.True(bean4.IsRunning);

            await processor.Stop();

            Assert.False(bean2.IsRunning);
            Assert.False(bean3.IsRunning);
            Assert.False(bean5.IsRunning);
            Assert.False(bean6.IsRunning);
            Assert.False(bean7.IsRunning);
            Assert.False(bean1.IsRunning);
            Assert.False(bean4.IsRunning);

            var stopped = stoppedBeans.ToArray();

            Assert.Equal(7, stopped.Length);
            Assert.Equal(int.MaxValue, GetPhase(stopped[0]));
            Assert.Equal(500, GetPhase(stopped[1]));
            Assert.Equal(1, GetPhase(stopped[2]));
            Assert.Equal(0, GetPhase(stopped[3]));
            Assert.Equal(0, GetPhase(stopped[4]));
            Assert.Equal(-1, GetPhase(stopped[5]));
            Assert.Equal(int.MinValue, GetPhase(stopped[6]));
        }
コード例 #11
0
        public GenericFamilyExpression(Type pluginType, ILifecycle scope, Registry registry)
        {
            _pluginType = pluginType;
            _registry = registry;

            alterAndContinue(f => { });

            if (scope != null)
            {
                alterAndContinue(family => family.SetLifecycleTo(scope));
            }
        }
コード例 #12
0
 /// <summary>
 ///  Creates a new instance of the <see cref="ConfigurationOptions"/>
 ///  class.
 /// </summary>
 /// <param name="constructorSelector">
 ///  Indicates that unregistered types should be automatically resolved
 ///  where possible.
 /// </param>
 /// <param name="expressionBuilder">
 ///  The mechanism by which constructors are selected.
 /// </param>
 /// <param name="defaultLifecycle">
 ///  The default lifecycle to apply to unregistered types.
 /// </param>
 /// <param name="autoResolve">
 ///  true if we are to auto-resolve unregistered types, otherwise false.
 /// </param>
 public ConfigurationOptions(
     IConstructorSelector constructorSelector = null,
     IExpressionBuilder expressionBuilder     = null,
     ILifecycle defaultLifecycle = null,
     bool autoResolve            = false
     )
 {
     AutoResolve         = autoResolve;
     ConstructorSelector = constructorSelector ?? new DefaultConstructorSelector();
     DefaultLifecycle    = defaultLifecycle ?? Lifecycle.Default;
     ExpressionBuilder   = expressionBuilder ?? new ExpressionBuilder();
 }
コード例 #13
0
        /// <summary>
        /// Ensures that there is a default for each option.
        /// </summary>
        public void EnsureDefaults()
        {
            if (DefaultLifecycle == null)
            {
                DefaultLifecycle = Lifecycle.Transient;
            }

            if (ConstructorSelector == null)
            {
                ConstructorSelector = new SinglePublicConstructorSelector();
            }
        }
コード例 #14
0
ファイル: LifecycleLine.cs プロジェクト: kiquenet/B4F
        internal LifecycleLine(ILifecycle parent, int ageFrom, IPortfolioModel model)
        {
            if (ageFrom == 0)
                throw new ApplicationException("Age From is mandatory");
            if (model == null)
                throw new ApplicationException("Model is mandatory");

            Parent = parent;
            AgeFrom = ageFrom;
            Model = model;
            CreatedBy = B4F.TotalGiro.Security.SecurityManager.CurrentUser;
        }
コード例 #15
0
        public GenericFamilyExpression(Type pluginType, ILifecycle scope, Registry registry)
        {
            _pluginType = pluginType;
            _registry   = registry;

            alterAndContinue(f => { });

            if (scope != null)
            {
                alterAndContinue(family => family.SetScopeTo(scope));
            }
        }
コード例 #16
0
        public object NewInstance(IContainer container)
        {
            if (this.Lifecycle == null)
            {
                this.Lifecycle = new TransientLifecycle();
            }

            return(this.Lifecycle.InitializeInstance(() =>
            {
                return this.Activator.ActivateInstance(container);
            }));
        }
コード例 #17
0
 public DefaultProducingMessageChannelBinding(
     AbstractMessageChannelBinder binder,
     string destination,
     IMessageChannel target,
     ILifecycle lifecycle,
     IProducerOptions options,
     IProducerDestination producerDestination)
     : base(destination, target, lifecycle)
 {
     this.binder              = binder;
     this.options             = options;
     this.producerDestination = producerDestination;
 }
コード例 #18
0
ファイル: DefaultBinding.cs プロジェクト: qinfengzhu/Steeltoe
        public DefaultBinding(string name, string group, T target, ILifecycle lifecycle)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            Name         = name;
            Group        = group;
            _target      = target;
            _lifecycle   = lifecycle;
            _restartable = !string.IsNullOrEmpty(group);
        }
コード例 #19
0
 public ConventionServiceDescriptor(
     Predicate <Type> predicate,
     Func <Type, IEnumerable <Type> > typeFinder,
     ILifecycle lifecycle,
     ServiceLifetime lifetime,
     Func <ServiceRequest, bool> precondition)
     : base(typeof(Dummy), svc => Dummy.Instance, lifetime)
 {
     _predicate   = predicate;
     _typeFinder  = typeFinder;
     _lifecycle   = lifecycle;
     Precondition = precondition;
 }
コード例 #20
0
 private async Task DoStart(ILifecycle bean)
 {
     if (bean != null && bean != this && !bean.IsRunning && (!_autoStartupOnly || bean is not ISmartLifecycle lifecycle || lifecycle.IsAutoStartup))
     {
         try
         {
             await bean.Start();
         }
         catch (Exception ex)
         {
             throw new LifecycleException("Failed to start bean(service) '" + bean + "'", ex);
         }
     }
 }
コード例 #21
0
 public DefaultConsumerMessageChannelBinding(
     AbstractMessageChannelBinder binder,
     string name,
     string group,
     IMessageChannel inputChannel,
     ILifecycle lifecycle,
     IConsumerOptions options,
     IConsumerDestination consumerDestination)
     : base(name, group, inputChannel, lifecycle)
 {
     this.binder  = binder;
     this.options = options;
     destination  = consumerDestination;
 }
コード例 #22
0
 public DefinitionServiceDescriptor(
     Type serviceType,
     Type implementationType,
     ServiceLifetime?lifetime,
     ILifecycle lifecycle,
     Func <ServiceRequest, bool> precondition)
     : base(serviceType, implementationType, lifetime ?? ServiceLifetime.Transient)
 {
     Lifecycle = lifecycle ??
                 (lifetime.HasValue
                     ? FactoryFactory.Lifecycle.Get(lifetime.Value)
                     : FactoryFactory.Lifecycle.Default);
     Precondition = precondition;
 }
コード例 #23
0
 public DefaultPollableChannelBinding(
     AbstractMessageChannelBinder binder,
     string name,
     string group,
     IPollableSource <IMessageHandler> inboundBindTarget,
     ILifecycle lifecycle,
     IConsumerOptions options,
     IConsumerDestination consumerDestination)
     : base(name, group, inboundBindTarget, lifecycle)
 {
     _binder      = binder;
     _options     = options;
     _destination = consumerDestination;
 }
コード例 #24
0
 private async Task DoStart(ILifecycle bean)
 {
     if (bean != null && bean != this && !bean.IsRunning && (!autoStartupOnly || !(bean is ISmartLifecycle) || ((ISmartLifecycle)bean).IsAutoStartup))
     {
         try
         {
             await bean.Start();
         }
         catch (Exception ex)
         {
             throw new LifecycleException("Failed to start bean '" + bean + "'", ex);
         }
     }
 }
コード例 #25
0
 public DefaultProducingMessageChannelBinding(
     AbstractMessageChannelBinder binder,
     string destination,
     IMessageChannel target,
     ILifecycle lifecycle,
     IProducerOptions options,
     IProducerDestination producerDestination,
     ILogger logger = null)
     : base(destination, target, lifecycle)
 {
     _binder              = binder;
     _options             = options;
     _producerDestination = producerDestination;
     _logger              = logger;
 }
コード例 #26
0
            public TransientRegistration(Type serviceType, Type implementationType, ILifecycle lifecycle)
            {
                if (serviceType == null)
                {
                    throw new ArgumentNullException(nameof(serviceType));
                }
                if (implementationType == null)
                {
                    throw new ArgumentNullException(nameof(implementationType));
                }

                ServiceType        = serviceType;
                ImplementationType = implementationType;
                Lifecycle          = lifecycle;
            }
コード例 #27
0
 public DefinitionServiceDescriptor(
     Type serviceType,
     Expression <Func <ServiceRequest, object> > implementationFactory,
     ServiceLifetime?lifetime,
     ILifecycle lifecycle,
     Func <ServiceRequest, bool> precondition)
     : base(serviceType, svc => null, lifetime ?? ServiceLifetime.Transient)
 {
     _implementationFactory = implementationFactory;
     Lifecycle = lifecycle ??
                 (lifetime.HasValue
                     ? FactoryFactory.Lifecycle.Get(lifetime.Value)
                     : FactoryFactory.Lifecycle.Default);
     Precondition = precondition;
 }
コード例 #28
0
 public DefaultConsumerMessageChannelBinding(
     AbstractMessageChannelBinder binder,
     string name,
     string group,
     IMessageChannel inputChannel,
     ILifecycle lifecycle,
     IConsumerOptions options,
     IConsumerDestination consumerDestination,
     ILogger logger = null)
     : base(name, group, inputChannel, lifecycle)
 {
     _binder      = binder;
     _options     = options;
     _destination = consumerDestination;
     _logger      = logger;
 }
コード例 #29
0
        public CreatePluginFamilyExpression(Registry registry, ILifecycle scope)
        {
            _pluginType = typeof(TPluginType);

            registry.alter = graph => {
                var family = graph.Families[_pluginType];

                _children.Each(action => action(graph));
                _alterations.Each(action => action(family));
            };

            if (scope != null)
            {
                lifecycleIs(scope);
            }
        }
コード例 #30
0
        /* ====== Constructors ====== */

        /// <summary>
        ///  Creates a new default instance of the <see cref="ServiceDefinition"/>
        ///  class.
        /// </summary>
        public ServiceDefinition(Type serviceType,
                                 Expression <Func <ServiceRequest, object> > implementationFactory = null,
                                 Type implementationType                  = null,
                                 object implementationInstance            = null,
                                 ILifecycle lifecycle                     = null,
                                 Func <ServiceRequest, bool> precondition = null)
        {
            ServiceType  = serviceType;
            Precondition = precondition;

            ImplementationFactory  = implementationFactory;
            ImplementationInstance = implementationInstance;
            ImplementationType     = implementationType ?? (implementationFactory == null ? implementationType : null);
            Lifecycle = lifecycle ?? FactoryFactory.Lifecycle.Default;

            Validate();
        }
コード例 #31
0
        public void do_not_replace_the_build_Lifecycle_if_it_is_the_same_type_as_the_imported_family()
        {
            var originalFamily = new PluginFamily(typeof(IWidget));

            originalFamily.SetScopeTo(InstanceScope.Singleton);
            var factory = new InstanceFactory(originalFamily);

            ILifecycle originalLifecycle = factory.Lifecycle;


            var family = new PluginFamily(typeof(IWidget));

            family.SetScopeTo(InstanceScope.Singleton);

            factory.ImportFrom(family);

            factory.Lifecycle.ShouldBeTheSameAs(originalLifecycle);
        }
コード例 #32
0
ファイル: SessionCache.cs プロジェクト: valmont/structuremap
        public object GetObject(Type pluginType, Instance instance, ILifecycle lifecycle)
        {
            if (lifecycle is UniquePerRequestLifecycle)
            {
                return(_resolver.BuildNewInSession(pluginType, instance));
            }

            var key = instance.InstanceKey(pluginType);

            if (!_cachedObjects.ContainsKey(key))
            {
                var o = _resolver.ResolveFromLifecycle(pluginType, instance);
                _cachedObjects[key] = o;

                return(o);
            }

            return(_cachedObjects[key]);
        }
コード例 #33
0
ファイル: Swasey.cs プロジェクト: markchipman/Swasey
        public async Task Generate(Uri resourceListingUri)
        {
            ILifecycle lifecycle = null;

            if (SwaggerVersion == SwaggerVersion.Version12)
            {
                lifecycle = new GenerationLifecycle()
                            .Enqueue(new LoadResourceListingJsonCommand())
                            .Enqueue(new ValidateSwaggerResourceListingCommand())
                            .Enqueue(new LoadApiJsonCommand())
                            .Enqueue(new ValidateSwaggerApiDefinitionCommand())
                            .Enqueue(new ExtractApiModelsCommand())
                            .Enqueue(new ExtractApiOperationsCommand())
                            .Enqueue(new NormalizeEnumsCommand())
                            .Enqueue(new NormalizeModelsCommand())
                            .Enqueue(new NormalizeOperationsCommand())
                            .Enqueue(new GenerateApiSourcesCommand())
                            .Enqueue(new GenerateModelSourcesCommand())
                ;
            }
            else if (SwaggerVersion == SwaggerVersion.Version20)
            {
                lifecycle = new GenerationLifecycle()
                            .Enqueue(new LoadResourceListingJsonCommand20())
                            .Enqueue(new ValidateSwaggerResourceListingCommand20())
                            .Enqueue(new ValidateSwaggerApiDefinitionCommand20())
                            .Enqueue(new ExtractApiModelsCommand20())
                            .Enqueue(new ExtractApiOperationsCommand20())
                            .Enqueue(new NormalizeEnumsCommand())
                            .Enqueue(new NormalizeModelsCommand20())
                            .Enqueue(new NormalizeOperationsCommand20())
                            .Enqueue(new GenerateApiSourcesCommand20())
                            .Enqueue(new GenerateModelSourcesCommand())
                ;
            }

            await lifecycle.Execute(
                new LifecycleContext(Options)
            {
                ResourceListingUri = resourceListingUri
            });
        }
コード例 #34
0
        public void ImportFrom(PluginFamily family)
        {
            if (_lifecycle == null)
            {
                _lifecycle = family.Lifecycle;
            }
            else if (_lifecycle != null && family.Lifecycle != null &&
                     !_lifecycle.GetType().Equals(family.Lifecycle.GetType()))
            {
                // TODO:  Might need to clear out the existing policy when it's ejected
                _lifecycle = family.Lifecycle;
            }


            family.Instances.Each(instance => _instances.Fill(instance.Name, instance));

            if (family.MissingInstance != null)
            {
                MissingInstance = family.MissingInstance;
            }
        }
コード例 #35
0
        private ILifecycle GetLifecycle(RegistrationLifestyle lifestyle)
        {
            ILifecycle lifecycle = null;

            switch (lifestyle)
            {
            case RegistrationLifestyle.Singleton:
                lifecycle = new SingletonLifecycle();
                break;

            case RegistrationLifestyle.SingletonPerScope:
                lifecycle = new ContainerLifecycle();
                break;

            case RegistrationLifestyle.SingletonPerObjectGraph:
            case RegistrationLifestyle.Transient:
                lifecycle = new TransientLifecycle();
                break;
            }

            return(lifecycle);
        }
コード例 #36
0
        public static void Init(ILifecycle serviceLifecycle, string connectionString)
        {
            try
            {
                var mapperConfig = new AutoMapperConfig();
                var config       = mapperConfig.CreateConfiguration();
                var mapper       = config.CreateMapper();

                CurrentContainer = new Container(x =>
                {
                    x.For <IMapper>().Singleton().Use(() => mapper);
                    x.AddRegistry(new RepositoryRegistry(serviceLifecycle, connectionString));
                    x.AddRegistry(new ServiceRegistry(serviceLifecycle));
                });
            }
            catch (Exception ex)
            {
                try
                {
                }
                catch (Exception) { }
                throw;
            }
        }
コード例 #37
0
ファイル: Instance.cs プロジェクト: Kingefosa/structuremap
 public ILifecycle DetermineLifecycle(ILifecycle parent)
 {
     return Lifecycle ?? parent ?? Lifecycles.Transient;
 }
コード例 #38
0
    public void ImportFrom(PluginFamily source)
    {
        if (source.Lifecycle != null)
            {
                Lifecycle = source.Lifecycle;
            }

            source.Instances.Each(instance => _instances.Fill(instance.Name, instance));

            if (source.MissingInstance != null)
            {
                MissingInstance = source.MissingInstance;
            }
    }
コード例 #39
0
ファイル: ThreadData.cs プロジェクト: peterbucher/LightCore
 public ThreadData(ILifecycle lifecycle, Func<object> factory)
 {
     this._lifecycle = lifecycle;
     this._factory = factory;
 }
コード例 #40
0
 public void SetScopeTo(ILifecycle lifecycle)
 {
     _lifecycle = lifecycle;
 }
コード例 #41
0
 /// <summary>
 /// Assign a lifecycle to the PluginFamily
 /// </summary>
 /// <param name="lifecycle"></param>
 /// <returns></returns>
 public GenericFamilyExpression LifecycleIs(ILifecycle lifecycle)
 {
     return alterAndContinue(family => family.SetLifecycleTo(lifecycle));
 }
コード例 #42
0
ファイル: AccountTypeCustomer.cs プロジェクト: kiquenet/B4F
        /// <summary>
        /// The method to alter the Model portfolio
        /// </summary>
        /// <param name="lifecycle">The current lifecycle</param>
        /// <param name="newModelPortfolio">The new model portfolio</param>
        /// <param name="isExecOnlyCustomer">Is this an execution only customer</param>
        /// <param name="employerRelationship">The relationship that the account has to the company</param>
        /// <param name="employee">The employee who performs the change</param>
        /// <param name="changeDate">The date of the change</param>
        /// <returns></returns>
        public bool SetModelPortfolio(ILifecycle lifecycle, IPortfolioModel newModelPortfolio,
            bool isExecOnlyCustomer, AccountEmployerRelationship employerRelationship,
            IInternalEmployeeLogin employee, DateTime changeDate)
        {
            ModelPortfolioChanges.Add(new ModelHistory.ModelHistory(this, lifecycle, newModelPortfolio, isExecOnlyCustomer, employerRelationship, employee, changeDate));
            IsExecOnlyCustomer = isExecOnlyCustomer;
            if (this.AccountType == AccountTypes.Customer)
                ((ICustomerAccount)this).EmployerRelationship = employerRelationship;
            ModelPortfolio = newModelPortfolio;

            if (CurrentManagementFeePeriod == null && Util.IsNotNullDate(FirstManagementStartDate) && Util.IsNullDate(FinalManagementEndDate))
                createManagementFeePeriod(changeDate);
            return true;
        }
コード例 #43
0
ファイル: InstanceTester.cs プロジェクト: e-tobi/structuremap
        private bool nestedIsValidForLifecycle(ILifecycle lifecycle)
        {
            var instance = new InstanceUnderTest();
            instance.SetLifecycleTo(lifecycle);

            return instance.IsValidInNestedContainer();
        }
コード例 #44
0
ファイル: HasScope.cs プロジェクト: smerrell/structuremap
 public void SetScopeTo(ILifecycle lifecycle)
 {
     _lifecycle = new Lazy<ILifecycle>(() => lifecycle);
 }
コード例 #45
0
 private static void isLifecycleOnActiveCustomers(ILifecycle lifecycle, IDalSession session)
 {
     // check if lifecycle is on active accounts
     long activeAccounts = session.Session.GetNamedQuery(
         "B4F.TotalGiro.ApplicationLayer.DataMaintenance.LifecycleOnActiveCustomers")
         .SetParameter("lifecycleId", lifecycle.Key)
         .UniqueResult<long>();
     if (activeAccounts > 0)
         throw new ApplicationException(string.Format("It is not possible to inactivate/delete this lifecycle since {0} active accounts are attached to it.", activeAccounts));
 }
コード例 #46
0
    public void ImportFrom(PluginFamily family)
    {
        if (_lifecycle == null)
            {
                _lifecycle = family.Lifecycle;
            }
            else if ((family.Lifecycle != null &&
                     !_lifecycle.GetType().Equals(family.Lifecycle.GetType())) ||
                ((family.Scope != null) && (family.Scope.Value.ToString() != _lifecycle.ToName())))
            {
                // TODO:  Might need to clear out the existing policy when it's ejected
                _lifecycle = family.Lifecycle;
            }

            family.Instances.Each(instance => _instances.Fill(instance.Name, instance));

            if (family.MissingInstance != null)
            {
                MissingInstance = family.MissingInstance;
            }
    }
コード例 #47
0
ファイル: LifecycleMapper.cs プロジェクト: kiquenet/B4F
 public static bool Update(IDalSession session, ILifecycle obj)
 {
     return session.InsertOrUpdate(obj);
 }