コード例 #1
0
        public static void RegisterWithCtorArgs(this ContainerBuilder @this, IManagedComponent component)
        {
            var target        = component.GetTarget();
            var classType     = target.Key;
            var interfaceType = target.Value;

            var args = component.GetCtorArgs();

            if (component.Info.RegistrationFlag.IsPerDependency())
            {
                @this.RegisterType(classType).As(interfaceType).WithParameters(args).InstancePerDependency();
            }
            else if (component.Info.RegistrationFlag.IsSingleton())
            {
                @this.RegisterType(classType).As(interfaceType).WithParameters(args).SingleInstance();
            }
            else if (component.Info.RegistrationFlag.IsSelf())
            {
                @this.RegisterType(classType).WithParameters(args).AsSelf();
            }
        }