Exemplo n.º 1
0
 public virtual void LoadRegister(ICommandRegister register)
 {
     foreach (var item in register.Commands)
     {
         Commands.Add(item.Key, item.Value);
     }
 }
Exemplo n.º 2
0
        private static void BuildParts(IUIElementAdapter parent,
                                       IEnumerable <MenuItemDescriptor> descriptors,
                                       string addInTreePath,
                                       ICommandRegister register)
        {
            //try
            //{
            descriptors = descriptors.OrderBy(c => c.OrderNumber);
            foreach (MenuItemDescriptor descriptor in descriptors)
            {
                //System.Diagnostics.Debug.WriteLine(descriptor.Codon.ToString());
                object uiElement = CreateMenuItemFromDescriptor(descriptor, addInTreePath, register);

                object uiElementCreated = parent.Add(uiElement);
                InitializeUIElement(descriptor, uiElementCreated);
                var children = descriptor.SubItems;
                if (children != null)
                {
                    var subDescriptors = children.Cast <MenuItemDescriptor>();
                    if (!subDescriptors.Any())
                    {
                        continue;
                    }
                    var uiElementAapter = GetUIElementAdapter(uiElement);
                    BuildParts(uiElementAapter, subDescriptors, addInTreePath + "/" + descriptor.Codon.Id, register);
                }
            }
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
Exemplo n.º 3
0
 public AttributeBasedFlowExecutor(Type flowClass, IEventStore eventStore, ICommandRegister commandFactory)
 {
     this.eventStore       = eventStore;
     this.flowClass        = flowClass;
     eventToCommandMapping = new Dictionary <Type, List <EventToCommand> >();
     this.commandFactory   = commandFactory;
     eventStore.SubscribeToAllEvents().Subscribe(OnEventRaised);
 }
        public AttributeFlowTemplate(IEventStore eventStore)
        {
            commandFactory     = new CommandRegister(eventStore);
            eventRaiserFactory = eventStore.GetEventRaiserFactory();
            this.eventStore    = eventStore;

            RegisterCommands();
            annFlowExecutor = GetExecutor();
        }
Exemplo n.º 5
0
        public void Start(ICommandRegister commandRegister, bool isErrorLoggingOn = false)
        {
            errorLogger.IsEnabled = isErrorLoggingOn;

            if (!isStarted)
            {
                isStarted = true;
                this.commandProcessor.LoadCommands(commandRegister);
                executeOnStartup?.Invoke();
            }
        }
Exemplo n.º 6
0
        public static void AddItemsToMenu(object ribbon,
                                          object owner,
                                          string addInTreePath,
                                          ICommandRegister register)
        {
            //System.Diagnostics.Debug.WriteLine("Ribbon building:" + addInTreePath);
            var adapter     = GetUIElementAdapter(ribbon);
            var descriptors = AddInTree.BuildItems <MenuItemDescriptor>(addInTreePath, owner, false);

            BuildParts(adapter, descriptors, addInTreePath, register);
        }
 public RingCommandBusinessHandler(
     IContextCache contextCache
     , ICommandHandlerFactory commandHandlerFactory
     , IEventStore eventStore
     , IEventBus eventBus
     , ICommandRegister commandRegister
     , IAggregateRootRebuilder aggregateRootRebuilder
     , ILoggerFactory loggerFactory
     , int maxHandleCount)
     : base(maxHandleCount)
 {
     this.context                 = new RingCommandContext(contextCache, aggregateRootRebuilder);
     this._contextCache           = contextCache;
     this._commandHandlerFactory  = commandHandlerFactory;
     this._eventStore             = eventStore;
     this._eventBus               = eventBus;
     this._commandRegister        = commandRegister;
     this._aggregateRootRebuilder = aggregateRootRebuilder;
     this._logger                 = loggerFactory.CreateLogger <RingCommandBusinessHandler>();
 }
Exemplo n.º 8
0
 public void LoadCommands(ICommandRegister commandRegister)
 {
     this.commandFactory.Register = commandRegister;
 }
Exemplo n.º 9
0
        static object CreateMenuItemFromDescriptor(MenuItemDescriptor descriptor, string addinTreePath, ICommandRegister register)
        {
            Codon codon = descriptor.Codon;

            string cmdPath   = addinTreePath + "/" + codon.Id;
            string builderid = string.Empty;

            if (codon.Properties.Contains("builderid"))
            {
                builderid = codon.Properties["builderid"];
            }
            else if (codon.Properties.Contains("cmdId"))
            {
                string cmdId = codon.Properties["cmdId"];
                return(register.GetBarItem(cmdId));
            }
            else
            {
                throw new Exception(string.Format("BuiderID not found:codonid ={0},condonname = {1}", codon.Id, codon.Name));
            }
            if (builderid == string.Empty)
            {
                throw new Exception(string.Format("BuiderID is empty:codonid ={0},condonname = {1}", codon.Id, codon.Name));
            }

            IPartBuilder builder = RibbonBuilderManager.GetBuider(builderid);
            object       obj     = builder.Build(codon, descriptor.Caller, descriptor.Conditions);;

            try
            {
                if (obj is BarButtonItemEx)
                {
                    BarItem cmdBar = obj as BarItem;

                    string formats = "<MenuItem id ={0} checkForViewId =\"\" source =\"Ribbon\" cmdPath =\"{1}\"/>";
                    System.Diagnostics.Debug.WriteLine(string.Format(formats, codon.Id, cmdPath));
                    if (register != null)
                    {
                        //ICommand command = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
                        //command.Owner = register.owner;
                        ICommand command = cmdBar.Tag as ICommand;
                        if (command != null)
                        {
                            if (string.IsNullOrEmpty(codon.Properties["groupName"]))
                            {
                                bool registerSuc = register.RegisterCommand(cmdBar, cmdPath, command, descriptor.Conditions);
                            }
                            else
                            {
                                string groupName   = codon.Properties["groupName"];
                                bool   registerSuc = register.RegisterCommand(cmdBar, codon.Id, cmdPath, command, groupName);
                            }
                        }
                        //Debug.WriteLine("Register =" + registerSuc.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(obj);
        }