public CommandAutomationSettings(BindingConfiguration binding)
        {
            Guard.NotNull(() => binding, binding);

            if (!typeof(ICommand).IsAssignableFrom(binding.Type))
                throw new ArgumentException();

            this.Binding = binding;
        }
        public static BindingConfiguration TraceMessage(this CommandFor configuration, BindingConfiguration messageProvider)
        {
            // TODO: setting the entry directly allows to have generics-based configuration, which will be easier to update later.
            // The problem is how to deal with replace vs add behavior: when setting, should we remove the existing config
            // from the component? should we just leave it there? Maybe we should always add, and upon building the actual
            // settings/schema object, we only bring over the ones that are used/referenced?
            //configuration.Configuration = new CommandConfiguration<TraceMessageCommand, TraceMessageSettings>(new TraceMessageSettings(message));

            return new BindingConfiguration<TraceMessageCommand>(configuration.Configuration)
                .Property(x => x.Message, messageProvider)
                .Configuration;
        }
Ejemplo n.º 3
0
        public void when_resolving_binding_then_resolves_type()
        {
            var config = new BindingConfiguration(typeof(GenerateCode))
            {
                Properties =
                {
                    new PropertyBindingConfiguration("TargetFileName")
                    {
                        ValueProvider = new BindingConfiguration(typeof(ExpressionValueProvider))
                        {
                            Properties =
                            {
                                new PropertyBindingConfiguration("Expression")
                                {
                                    ValueProvider = new BindingConfiguration(typeof(ExpressionValueProvider))
                                    {
                                        Properties =
                                        {
                                            new PropertyBindingConfiguration("Expression")
                                            {
                                                Value = "{Name}Controller",
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    new PropertyBindingConfiguration("TargetPath")
                    {
                        Value = "~",
                    },
                }
            };

            var context = new ComponentContext();
            var factory = new BindingFactory();
            var binding = factory.CreateBinding<GenerateCode>(context, config);

            var command = (GenerateCode)binding.Instance;

            binding.Refresh();

            Assert.Equal("~", command.TargetPath);
            Assert.Equal("{Name}Controller11", command.TargetFileName);

            binding.Refresh();

            Assert.Equal("~", command.TargetPath);

            Assert.Equal("{Name}Controller22", command.TargetFileName);
        }
Ejemplo n.º 4
0
        public EventAutomationSettings(BindingConfiguration binding,
            ICommandAutomationSettings commandSettings)
        {
            Guard.NotNull(() => binding, binding);

            // TODO: eventually, either command or wizard may be specified.
            Guard.NotNull(() => commandSettings, commandSettings);

            if (!(typeof(IObservable<IEventPattern<object, EventArgs>>).IsAssignableFrom(binding.Type)))
            {
                throw new ArgumentException(Strings.EventAutomationSettings.EventTypeMustBeObservable(
                    Stringly.ToTypeName(typeof(IObservable<IEventPattern<object, EventArgs>>))));
            }

            this.Binding = binding;
            this.CommandSettings = commandSettings;
        }
 public static BindingConfiguration Expression(this ProvidedBy provided, BindingConfiguration providedExpression)
 {
     return new BindingConfiguration<ExpressionProvider>()
         .Property(x => x.Expression, providedExpression)
         .Configuration;
 }
Ejemplo n.º 6
0
        public BindingConfiguration Property(string propertyName, BindingConfiguration valueProvider)
        {
            Properties.Add(new PropertyBindingConfiguration(propertyName) { ValueProvider = valueProvider });

            return this;
        }
Ejemplo n.º 7
0
 internal CommandFor(BindingConfiguration configuration)
 {
     this.Configuration = configuration;
 }