Binda.Binder.AddRegistration C# (CSharp) Method

AddRegistration() public method

Add a Custom Binda Strategy for specific controls
public AddRegistration ( BindaStrategy strategy ) : void
strategy BindaStrategy
return void
        public void AddRegistration(BindaStrategy strategy, params Control[] controls)
        {
            Array.ForEach(controls, x => _controlStrategies[x] = strategy);
        }

Same methods

Binder::AddRegistration ( Type controlType, BindaStrategy strategy ) : void
Binder::AddRegistration ( Type controlType, string propertyName ) : void

Usage Example

Esempio n. 1
0
        public void When_binding_an_object_to_a_form_with_a_property_and_a_collection_with_a_pluralized_name_of_the_property_using_prefixes_aliases_and_with_custom_registrations()
        {
            var binder = new Binder();
            binder.AddControlPrefix(new HungarianNotationControlPrefix());
            binder.AddRegistration(typeof(FluxCapacitor), "PopularityRanking");
            var aliases = new List<BindaAlias> { new BindaAlias("Location", "PostLocation") };
            var form = new PostWithOptionsPrefixForm();
            var post = NeededObjectsFactory.CreatePost();
            post.PopularityRanking = TestVariables.PopularityRanking;
            post.PublishStates.Add(new PublishState { State = "Published" });
            post.PublishStates.Add(new PublishState { State = "Reviewed" });
            post.PublishStates.Add(new PublishState { State = "Pending Review" });
            post.PublishStates.Add(new PublishState { State = "Draft" });
            post.PublishState = post.PublishStates[2];

            binder.Bind(post, form, aliases);

            Assert.That(form.cbPublishState.DataSource, Is.SameAs(post.PublishStates));
            Assert.That(form.cbPublishState.SelectedItem, Is.SameAs(post.PublishState));
            Assert.That(form.txtTitle.Text, Is.EqualTo(TestVariables.Title));
            Assert.That(form.txtAuthor.Text, Is.EqualTo(TestVariables.Author));
            Assert.That(form.dpDate.Value, Is.EqualTo(TestVariables.Posted));
            Assert.That(form.txtBody.Text, Is.EqualTo(TestVariables.Body));
            Assert.That(form.txtPostLocation.Text, Is.EqualTo(TestVariables.Location));
            Assert.That(form.fcPopularityRanking.PopularityRanking, Is.EqualTo(TestVariables.PopularityRanking));
        }
All Usage Examples Of Binda.Binder::AddRegistration