コード例 #1
0
        public CommandAutomationSettings(BindingConfiguration binding)
        {
            Guard.NotNull(() => binding, binding);

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

            this.Binding = binding;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
ファイル: BindingFixture.cs プロジェクト: NuPattern/CodeFirst
        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);
        }
コード例 #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;
        }
コード例 #5
0
 public static BindingConfiguration Expression(this ProvidedBy provided, BindingConfiguration providedExpression)
 {
     return new BindingConfiguration<ExpressionProvider>()
         .Property(x => x.Expression, providedExpression)
         .Configuration;
 }
コード例 #6
0
        public BindingConfiguration Property(string propertyName, BindingConfiguration valueProvider)
        {
            Properties.Add(new PropertyBindingConfiguration(propertyName) { ValueProvider = valueProvider });

            return this;
        }
コード例 #7
0
ファイル: CommandFor.cs プロジェクト: NuPattern/CodeFirst
 internal CommandFor(BindingConfiguration configuration)
 {
     this.Configuration = configuration;
 }