Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Enum support from QueryStrings #1953

Merged
merged 3 commits into from Nov 21, 2019
Merged

Adding Enum support from QueryStrings #1953

merged 3 commits into from Nov 21, 2019

Conversation

dansiegel
Copy link
Member

Description of Change

This is a rebased and fixed version of PR #1916. This adds tests both for ParametersBase and IAutoInitialize specifically. Be sure to note some of the behavior changes.

Bugs Fixed

  • no issue was created

API Changes

none

Behavioral Changes

Updates GetValue / TryGetValue from the ParametersBase. All Get Value methods now use a single internal TryGet method so that the conversion from the KeyValuePair's Value (which may be a string if it was from the QueryString) to whatever the requested type is will use the same exact logic. We now will be intentional in throwing an InvalidArgumentException when calling GetValue in the event that we could not convert the value to the requested type.

This also fixes a very incorrect assumption that at the event you got to the end of our type conversion logic that the value must be convertible. This now ensures that if we get to the point that we want to try Convert.ChangeType that we first validate that it implements IConvertible

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard

candidodmv and others added 3 commits November 20, 2019 09:51
…lue during conversion

Allow bind Enum values in IAutoInitialize ViewModels

Currently if anyone try pass through a enum value as raw type(value or name) within INavigationParameters get an error of conversion, to solve this problem was included the conditions above.

Allow bind Enum values in IAutoInitialize ViewModels

Currently if anyone try pass through a enum value as raw type(value or name) within INavigationParameters get an error of conversion, to solve this problem was included the conditions above.

Update ParametersExtensions.cs

force to use only enum name

I'm considering to use only the enum name because if the value is being considered during the conversion can cause side effect because the value as number can be refered to a lot of things in navigation parameters not the enum type searched.
@dansiegel dansiegel merged commit a2231be into master Nov 21, 2019
@dansiegel dansiegel deleted the enum-autoinitialize branch November 21, 2019 01:00
@lock
Copy link

lock bot commented Jan 28, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 28, 2020
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.

None yet

3 participants