Пример #1
0
        /// <summary>
        /// Start micake application.
        /// Must provider <see cref="IServiceProvider"/>
        /// </summary>
        public virtual void Start()
        {
            if (AppServiceProvider == null)
            {
                throw new ArgumentNullException(nameof(AppServiceProvider));
            }

            if (_isStarted)
            {
                throw new InvalidOperationException($"MiCake has already started.");
            }

            //Pre activation ServiceLocator
            AppServiceProvider.GetService(typeof(IServiceLocator));

            //Module Inspection.
            var inspectContext = new ModuleInspectionContext(AppServiceProvider, ModuleContext.AllModules);

            foreach (var module in ModuleContext.AllModules)
            {
                if (module is IModuleSelfInspection selfInspection)
                {
                    selfInspection.Inspect(inspectContext);
                }
            }

            var context = new ModuleLoadContext(AppServiceProvider, ModuleContext.AllModules, ApplicationOptions);

            _miCakeModuleBoot.Initialization(context);

            //Release options additional infomation.
            ApplicationOptions.AdditionalInfo.Release();
        }
Пример #2
0
        public void Inspect(ModuleInspectionContext context)
        {
            var hasTransport = context.AppServiceProvider.GetService <ITransportSender>();

            if (hasTransport == null)
            {
                throw new InvalidOperationException($"It seems that you are using message bus, " +
                                                    $"but you have not chosen the corresponding implementation scheme." +
                                                    $"Please add the corresponding support services, such as rabbitmq.");
            }
        }