/// <summary>
        /// 应用。
        /// </summary>
        /// <param name="context">组合策略应用上下文。</param>
        public void Apply(CompositionStrategyApplyContext context)
        {
            var controllers     = context.BuildBlueprint(IsController, BuildController);
            var httpControllers = context.BuildBlueprint(IsHttpController, BuildController);

            context.ShellBlueprint.SetControllers(controllers);
            context.ShellBlueprint.SetHttpControllers(httpControllers);
        }
        /// <summary>
        /// 应用。
        /// </summary>
        /// <param name="context">组合策略应用上下文。</param>
        public void Apply(CompositionStrategyApplyContext context)
        {
            var controllers = context.BuildBlueprint(IsController, BuildController);
            var httpControllers = context.BuildBlueprint(IsHttpController, BuildController);

            context.ShellBlueprint.SetControllers(controllers);
            context.ShellBlueprint.SetHttpControllers(httpControllers);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 组合外壳蓝图。
        /// </summary>
        /// <param name="settings">外壳设置。</param>
        /// <param name="descriptor">外壳描述符。</param>
        /// <returns>外壳蓝图。</returns>
        public ShellBlueprint Compose(ShellSettings settings, ShellDescriptor descriptor)
        {
            Logger.Debug("组合外壳蓝图");

            var enabledFeatures = _extensionManager.EnabledFeatures(descriptor);
            var features        = _extensionManager.LoadFeatures(enabledFeatures).ToArray();

            if (descriptor.Features.Any(feature => feature.Name == "SuperRocket.Framework"))
            {
                features = features.Concat(BuiltinFeatures()).ToArray();
            }

            var excludedTypes = GetExcludedTypes(features).ToArray();

            var modules      = BuildBlueprint(features, IsModule, BuildModule, excludedTypes);
            var dependencies = BuildBlueprint(features, IsDependency, BuildDependency, excludedTypes);

            var result = new ShellBlueprint
            {
                Settings     = settings,
                Descriptor   = descriptor,
                Dependencies = dependencies.Concat(modules).ToArray()
            };

            Logger.Debug("准备应用外部组合策略。");
            var context = new CompositionStrategyApplyContext
            {
                Features       = features,
                ExcludedTypes  = excludedTypes,
                ShellBlueprint = result
            };

            _compositionStrategyProviders.Invoke(i => i.Apply(context), Logger);
            Logger.Debug("应用外部组合策略成功。");

            Logger.Debug("组合外壳蓝图完成。");
            return(result);
        }
        /// <summary>
        /// 应用。
        /// </summary>
        /// <param name="context">组合策略应用上下文。</param>
        public void Apply(CompositionStrategyApplyContext context)
        {
            var records = context.BuildBlueprint(IsRecord, (t, f) => BuildRecord(t, f, context.ShellBlueprint.Settings));

            context.ShellBlueprint.SetRecords(records);
        }
 /// <summary>
 /// 应用。
 /// </summary>
 /// <param name="context">组合策略应用上下文。</param>
 public void Apply(CompositionStrategyApplyContext context)
 {
     var records = context.BuildBlueprint(IsRecord, (t, f) => BuildRecord(t, f, context.ShellBlueprint.Settings));
     context.ShellBlueprint.SetRecords(records);
 }