예제 #1
0
        public void Prepare(AppSetup setup)
        {
            AutofacContainerBuilder autofacContainerBuilder
                = setup.GetAppContainerBuilder <AutofacContainerBuilder>();

            autofacContainerBuilder.Building += AutofacContainerBuilder_Building;
        }
        public void Handle(AppSetup appSetup, IAppModule appModule, MethodInfo method, Attribute attribute)
        {
            if (method.ReturnType == typeof(void))
            {
                return;
            }

            ConfigAppContainerBuilder builder = appSetup.GetAppContainerBuilder <ConfigAppContainerBuilder>();

            ConfigCreatorAttribute config = (ConfigCreatorAttribute)attribute;

            builder.AddConfig(appModule, method);
        }
        public void Handle(AppSetup appSetup, IAppModule appModule, MethodInfo method, Attribute attribute)
        {
            AutofacContainerBuilder autofacContainerBuilder
                = appSetup.GetAppContainerBuilder <AutofacContainerBuilder>();

            autofacContainerBuilder.RegisterByCreator(cm =>
            {
                ParameterInfo[] ps = method.GetParameters();
                if (ps.Length == 0)
                {
                    return(method.Invoke(appModule, null));
                }
                object[] values = new object[ps.Length];
                for (int i = 0; i < ps.Length; i++)
                {
                    Type pType   = ps[i].ParameterType;
                    object value = cm.CreateComponent(pType);
                    values[i]    = value;
                }
                return(method.Invoke(appModule, values));
            }, method.ReturnType);
        }
예제 #4
0
        public void Handle(AppSetup appSetup, IAppModule appModule, MethodInfo method, Attribute attribute)
        {
            var replaceBuilder = appSetup.GetAppContainerBuilder <ReplaceServiceContainerBuilder>();

            replaceBuilder.TryRegister(appModule, method);
        }
예제 #5
0
        public void Prepare(AppSetup setup)
        {
            AutofacContainerBuilder autofacContainerBuilder = setup.GetAppContainerBuilder <AutofacContainerBuilder>();

            autofacContainerBuilder.RegisterByCreator(cm => new ServiceRegistedInTestContainerBuilder(), typeof(IService));
        }