Example #1
0
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            CurrentComponent = CurrentElement.As <IComponent>();
            if (CurrentComponent == null)
            {
                CurrentComponent = CurrentElement.Parent.As <IComponent>();
            }

            var events     = CurrentComponent.Parent.Parent.Contract.Events.Event;
            var eventNames = events.Select(e => e.InstanceName).ToList();

            var viewModel = new ElementPickerViewModel(eventNames)
            {
                Title      = "Publish Event",
                MasterName = "Event name"
            };

            var picker = WindowFactory.CreateDialog <ElementPicker>(viewModel);

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().GetValueOrDefault())
                {
                    var selectedElement = viewModel.SelectedItem;
                    var selectedEvent   =
                        events.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase));
                    if (selectedEvent == null)
                    {
                        selectedEvent = CurrentComponent.Parent.Parent.Contract.Events.CreateEvent(selectedElement);
                    }

                    CurrentComponent.Publishes.CreateLink(selectedEvent);

                    // Code Generation Guidance
                    if (CurrentComponent.UnfoldedCustomCode)
                    {
                        var userCode = (UserCodeChangeRequired)WindowFactory.CreateDialog <UserCodeChangeRequired>();
                        userCode.UriService = UriService;
                        userCode.Solution   = Solution;
                        userCode.Component  = CurrentComponent;
                        userCode.Code       = String.Format("var {0} = new {1}.{2}();\r\nBus.Publish({0});",
                                                            selectedEvent.CodeIdentifier.LowerCaseFirstCharacter(),
                                                            selectedEvent.Parent.Namespace,
                                                            selectedEvent.CodeIdentifier);
                        userCode.ShowDialog();
                    }
                }
            }
            // Make initial trace statement for this command
            //tracer.Info(
            //    "Executing ShowElementTypePicker on current element '{0}' with AProperty '{1}'", this.CurrentElement.InstanceName, this.ElementType);

            //	TODO: Use tracer.Warning() to note expected and recoverable errors
            //	TODO: Use tracer.Verbose() to note internal execution logic decisions
            //	TODO: Use tracer.Info() to note key results of execution
            //	TODO: Raise exceptions for all other errors
        }
Example #2
0
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            CurrentService = CurrentElement.As <IService>();

            var events     = CurrentService.Contract.Events.Event;
            var eventNames = events.Select(e => e.InstanceName).ToList();

            var viewModel = new ElementPickerViewModel(eventNames)
            {
                Title      = "Publish Event",
                MasterName = "Event name"
            };

            var picker = WindowFactory.CreateDialog <ElementPicker>(viewModel);

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().GetValueOrDefault())
                {
                    var selectedElement = viewModel.SelectedItem;
                    var selectedEvent   =
                        events.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase));
                    if (selectedEvent == null)
                    {
                        selectedEvent = CurrentService.Contract.Events.CreateEvent(selectedElement);
                    }

                    var component = CurrentService.Components.Component.FirstOrDefault(x => x.InstanceName == selectedElement + "Sender");
                    if (component == null)
                    {
                        component = CurrentService.Components.CreateComponent(selectedElement + "Sender", c => c.Publishes.CreateLink(selectedEvent));
                    }
                    else
                    {
                        component.Publishes.CreateLink(selectedEvent);
                    }
                }
            }
            // Make initial trace statement for this command
            //tracer.Info(
            //    "Executing ShowElementTypePicker on current element '{0}' with AProperty '{1}'", this.CurrentElement.InstanceName, this.ElementType);

            //	TODO: Use tracer.Warning() to note expected and recoverable errors
            //	TODO: Use tracer.Verbose() to note internal execution logic decisions
            //	TODO: Use tracer.Info() to note key results of execution
            //	TODO: Raise exceptions for all other errors
        }
Example #3
0
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            CurrentService = CurrentElement.As <IService>();

            var commands     = CurrentService.Contract.Commands.Command;
            var commandNames = commands.Select(e => e.InstanceName).ToList();

            var viewModel = new ElementPickerViewModel(commandNames)
            {
                Title      = "Send Command",
                MasterName = "Command name"
            };

            var picker = WindowFactory.CreateDialog <ElementPicker>(viewModel);

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().GetValueOrDefault())
                {
                    var selectedElement = viewModel.SelectedItem;
                    if (!commandNames.Contains(selectedElement))
                    {
                        CurrentService.Contract.Commands.CreateCommand(selectedElement);
                    }
                }
            }
            // Make initial trace statement for this command
            //tracer.Info(
            //    "Executing ShowElementTypePicker on current element '{0}' with AProperty '{1}'", this.CurrentElement.InstanceName, this.ElementType);

            //	TODO: Use tracer.Warning() to note expected and recoverable errors
            //	TODO: Use tracer.Verbose() to note internal execution logic decisions
            //	TODO: Use tracer.Info() to note key results of execution
            //	TODO: Raise exceptions for all other errors
        }
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            CurrentService = CurrentElement.As<IService>();

            var commands = CurrentService.Contract.Commands.Command;
            var commandNames = commands.Select(e => e.InstanceName).ToList();

            var viewModel = new ElementPickerViewModel(commandNames)
            {
                Title = "Send Command",
                MasterName = "Command name"
            };

            var picker = WindowFactory.CreateDialog<ElementPicker>(viewModel);

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().GetValueOrDefault())
                {
                    var selectedElement = viewModel.SelectedItem;
                    if (!commandNames.Contains(selectedElement))
                    {
                        CurrentService.Contract.Commands.CreateCommand(selectedElement);
                    }
                }
            }
            // Make initial trace statement for this command
            //tracer.Info(
            //    "Executing ShowElementTypePicker on current element '{0}' with AProperty '{1}'", this.CurrentElement.InstanceName, this.ElementType);

            //	TODO: Use tracer.Warning() to note expected and recoverable errors
            //	TODO: Use tracer.Verbose() to note internal execution logic decisions
            //	TODO: Use tracer.Info() to note key results of execution
            //	TODO: Raise exceptions for all other errors
        }
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            CurrentComponent = CurrentElement.As<IComponent>();
            if (CurrentComponent == null)
            {
                CurrentComponent = CurrentElement.Parent.As<IComponent>();
            }

            var events = CurrentComponent.Parent.Parent.Contract.Events.Event;
            var eventNames = events.Select(e => e.InstanceName).ToList();

            var viewModel = new ElementPickerViewModel(eventNames)
            {
                Title = "Publish Event",
                MasterName = "Event name"
            };

            var picker = WindowFactory.CreateDialog<ElementPicker>(viewModel);

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().GetValueOrDefault())
                {
                    var selectedElement = viewModel.SelectedItem;
                    var selectedEvent =
                        events.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase));
                    if (selectedEvent == null)
                    {
                        selectedEvent = CurrentComponent.Parent.Parent.Contract.Events.CreateEvent(selectedElement);
                    }

                    CurrentComponent.Publishes.CreateLink(selectedEvent);

                    // Code Generation Guidance
                    if (CurrentComponent.UnfoldedCustomCode)
                    {
                        var userCode = (UserCodeChangeRequired)WindowFactory.CreateDialog<UserCodeChangeRequired>();
                        userCode.UriService = UriService;
                        userCode.Solution = Solution;
                        userCode.Component = CurrentComponent;
                        userCode.Code = String.Format("var {0} = new {1}.{2}();\r\nBus.Publish({0});",
                            selectedEvent.CodeIdentifier.LowerCaseFirstCharacter(),
                            selectedEvent.Parent.Namespace,
                            selectedEvent.CodeIdentifier);
                        userCode.ShowDialog();
                    }
                }
            }
            // Make initial trace statement for this command
            //tracer.Info(
            //    "Executing ShowElementTypePicker on current element '{0}' with AProperty '{1}'", this.CurrentElement.InstanceName, this.ElementType);

            //	TODO: Use tracer.Warning() to note expected and recoverable errors
            //	TODO: Use tracer.Verbose() to note internal execution logic decisions
            //	TODO: Use tracer.Info() to note key results of execution
            //	TODO: Raise exceptions for all other errors
        }