Esempio n. 1
0
        /// <summary>
        /// 构建插件单元
        /// </summary>
        /// <param name="owner">拥有者</param>
        /// <param name="subItems">子对象</param>
        /// <returns>构建好的插件单元</returns>
        public object BuildItem(object owner, ArrayList subItems)
        {
            IBuilderService builderService = WorkItem.Services.Get <IBuilderService>();

            if (builderService != null)
            {
                IBuilder builder = builderService.GetBuilder(className);
                if (builder == null)
                {
                    throw new AddInException(String.Format("系统未注册类型为 [{0}] 的插件单元构建器", className));
                }

                if (builder.HandleConditions && conditions.Count > 0)
                {
                    ConditionFailedAction action = GetFailedAction(owner);
                    if (action != ConditionFailedAction.Nothing)
                    {
                        return(null);
                    }
                }

                if (objectRef == null)
                {
                    objectRef = builder.BuildItem(owner, workItem, this, subItems);
                }
                return(objectRef);
            }
            return(null);
        }
Esempio n. 2
0
 public void Construct(IBuilderService car)
 {
     car.CarType();
     car.ProvideACType();
     car.ProvideColorType();
     car.ProvideUpholsteryType();
     car.ProvideWheelType();
 }
Esempio n. 3
0
        public MainWindowViewModel(IControlsService controlsService,
                                   ILuxaryCarBuilder luxaryCarBuilder,
                                   IMediumCarBuilder mediumCarBuilder,
                                   INormalCarBuilder normalCarBuilder)
        {
            _controlsService = controlsService;
            _luxuryCar       = luxaryCarBuilder;
            _mediumCar       = mediumCarBuilder;
            _normalCar       = normalCarBuilder;

            SwitchCommnad   = new DelegateCommand(OnSwitchCommand);
            Builder1Command = new DelegateCommand(OnBuilderLuxuryCommand);
            Builder2Command = new DelegateCommand(OnBuilderMediumCommand);
            Builder3Command = new DelegateCommand(OnBuilderNormalCommand);
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of <see cref="Uploader"/>
 /// </summary>
 /// <param name="imageDataProvider">Image data provider</param>
 /// <param name="mappingFactory">Mapping factory</param>
 /// <param name="metadataExtractorFactory">Metadata extractor factory</param>
 /// <param name="builderService">Builder service</param>
 /// <param name="publishingService">Publishing service</param>
 /// <param name="imageWriteService">Image write service</param>
 /// <param name="writeService">Write service</param>
 public Uploader(IImageDataProvider imageDataProvider,
                 IMappingFactory mappingFactory,
                 IMetadataExtractorFactory metadataExtractorFactory,
                 IBuilderService builderService,
                 IPublishingService publishingService,
                 IImageWriteService imageWriteService,
                 IWriteService writeService)
 {
     _imageDataProvider        = imageDataProvider;
     _mappingFactory           = mappingFactory;
     _metadataExtractorFactory = metadataExtractorFactory;
     _builderService           = builderService;
     _publishingService        = publishingService;
     _imageWriteService        = imageWriteService;
     _writeService             = writeService;
 }
Esempio n. 5
0
        /// <summary>
        /// 解析构建器,在这里对注册到系统中的UI类工厂、命令适配器、构建器进行处理
        /// </summary>
        /// <param name="configuration">配置项</param>
        private void ParseBuilders(IConfiguration configuration)
        {
            Guard.ArgumentNotNull(configuration, "configuration");
            IBuilderService builderService = workItem.Services.Get <IBuilderService>();

            if (builderService != null)
            {
                foreach (IConfiguration config in configuration.Children)
                {
                    switch (config.Name)
                    {
                    case "UIAdapterFactories":      // UI类工厂
                        foreach (IConfiguration factory in config.Children)
                        {
                            if (factory.Attributes["name"] != null && factory.Attributes["type"] != null)
                            {
                                logger.Debug("注册UI类工厂," + factory.ToString());
                                // 根据配置文件注册UI类工厂
                                Type factoryType = Type.GetType(factory.Attributes["type"]);
                                if (factoryType != null)
                                {
                                    try
                                    {
                                        builderService.RegisterAdapterFactory((IUIElementAdapterFactory)Activator.CreateInstance(factoryType));
                                    }
                                    catch
                                    {
                                        logger.Error("注册UI类工厂," + factory.ToString() + "失败!");
                                    }
                                }
                            }
                        }
                        break;

                    case "CommandAdapters":     // 命令适配器
                        foreach (IConfiguration adapter in config.Children)
                        {
                            if (adapter.Attributes["name"] != null && adapter.Attributes["invokertype"] != null && adapter.Attributes["adaptertype"] != null)
                            {
                                //logger.Debug("注册命令适配器,Name[" + adapter.Attributes["name"] + "],InvokerType[" + adapter.Attributes["invokertype"]
                                //    + "],AdapterType[" + adapter.Attributes["adapterType"] + "]");
                                logger.Debug("注册命令适配器," + adapter.ToString());
                                Type invokerType = Type.GetType(adapter.Attributes["invokertype"]);
                                Type adapterType = Type.GetType(adapter.Attributes["adaptertype"]);
                                if (invokerType != null && adapterType != null)
                                {
                                    try
                                    {
                                        builderService.RegisterCommandAdapter(invokerType, adapterType);
                                    }
                                    catch
                                    {
                                        logger.Debug("注册命令适配器," + adapter.ToString() + "失败!");
                                    }
                                }
                            }
                        }
                        break;

                    case "UIBuilders":      // 插件构建器
                        foreach (IConfiguration builder in config.Children)
                        {
                            if (builder.Attributes["name"] != null && builder.Attributes["type"] != null)
                            {
                                logger.Debug("注册插件单元构建器," + builder.ToString());
                                Type builderType = Type.GetType(builder.Attributes["type"]);
                                if (builderType != null)
                                {
                                    try
                                    {
                                        IBuilder uibuilder = (IBuilder)Activator.CreateInstance(builderType);
                                        builderService.RegisterBuilder(uibuilder);
                                    }
                                    catch
                                    {
                                        logger.Debug("注册插件单元构建器," + builder.ToString() + "失败!");
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 6
0
 public BuilderController(IBuilderService builderService)
 {
     _builderService = builderService;
 }
Esempio n. 7
0
 public IndexModel(IBuilderService builderService)
 {
     _builderService = builderService;
 }
Esempio n. 8
0
 public BuilderController(IDataGenerator dataGenerator, IBuilderService builderService)
 {
     this.dataGenerator  = dataGenerator;
     this.builderService = builderService;
 }