Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Create custom collections for several MVC types#6459

Closed
henkmollema wants to merge 7 commits intoaspnet:devfrom
henkmollema:henk/6161
Closed

Create custom collections for several MVC types#6459
henkmollema wants to merge 7 commits intoaspnet:devfrom
henkmollema:henk/6161

Conversation

@henkmollema
Copy link
Copy Markdown
Contributor

@henkmollema henkmollema commented Jun 28, 2017

Resolves #6161.

  • Conventions
  • ModelBinderProviders
  • ModelMetadataDetailsProviders
  • ModelValidatorProviders
  • ValueProviderFactories
  • Update FormatterCollection to include a non-generic RemoveType(Type) overload.
  • Review duplicate code
  • Review breaking changes (and update JSON file?)

/// as a wrapper for the specified list.
/// </summary>
/// <param name="modelBinderProviders">The list that is wrapped by the new collection.</param>
public ModelBinderProviderCollection(IList<IModelBinderProvider> modelBinderProviders)
Copy link
Copy Markdown
Contributor Author

@henkmollema henkmollema Jun 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented these constructors according to FormatterCollection, do we always need them?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to have for completeness any time you're extending Collection<>

/// <summary>
/// Represents a collection of model binder providers.
/// </summary>
public class ModelBinderProviderCollection : Collection<IModelBinderProvider>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type lives in Microsoft.AspNetCore.Mvc.Core. Is that correct? I noticed that some collection types are in Abstractions and some in Core.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the right place.

/// Removes all model binder providers of the specified type.
/// </summary>
/// <param name="modelBinderType">The type to remove.</param>
public void RemoveType(Type modelBinderType)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented this like

public void RemoveType<T>() where T : TFormatter
. Except it uses GetType() rather than a type check, is that OK?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we need to be consistent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use two different implementations? One generic and one non generic?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see the issue, yeah we should change all of this code (FormatterCollection and FilterCollection to use GetType() == for comparison.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@henkmollema
Copy link
Copy Markdown
Contributor Author

@rynowak this is a draft of the design for #6161. I've left some comments, could you take a look and tell me what you think?

@henkmollema
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! I'll try to finish this tomorrow.

@henkmollema henkmollema changed the title [WIP] Create custom collections for several MVC types Create custom collections for several MVC types Jun 30, 2017
@henkmollema
Copy link
Copy Markdown
Contributor Author

henkmollema commented Jun 30, 2017

@rynowak I think that's all of them. Is the amount of duplicate acceptable?

And how should we update the breaking changes file to reflect these changes?

Copy link
Copy Markdown
Member

@rynowak rynowak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thanks again

@rynowak
Copy link
Copy Markdown
Member

rynowak commented Jun 30, 2017

@pranavkm can you take a look at this as well

Copy link
Copy Markdown
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I can get this merged in and add these methods to PageConventionCollection

/// Removes all application model conventions of the specified type.
/// </summary>
/// <typeparam name="TApplicationModelConvention">The type to remove.</typeparam>
public void RemoveType<TApplicationModelConvention>() where TApplicationModelConvention : IApplicationModelConvention
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should port these over to Pages as well.

@rynowak
Copy link
Copy Markdown
Member

rynowak commented Jun 30, 2017

Ok thanks, please do the needful. Thanks again @henkmollema

@pranavkm pranavkm self-assigned this Jun 30, 2017
@henkmollema
Copy link
Copy Markdown
Contributor Author

Cool! Let me know if you need me to do anything.

@pranavkm
Copy link
Copy Markdown
Contributor

Merged in 948982e. Thanks @henkmollema

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants