refactor autocomplete to be flexible and reusable#54
Open
MomchilSt wants to merge 2 commits intoMinkov:mainfrom
Open
refactor autocomplete to be flexible and reusable#54MomchilSt wants to merge 2 commits intoMinkov:mainfrom
MomchilSt wants to merge 2 commits intoMinkov:mainfrom
Conversation
Minkov
requested changes
Nov 23, 2023
Comment on lines
243
to
249
| var parameter = Expression.Parameter(typeof(TEntity), "e"); | ||
| var propertyAccess = Expression.Property(parameter, searchedProperty); | ||
| var searchTermExpression = Expression.Constant(searchTerm, typeof(string)); | ||
|
|
||
| Expression body; | ||
|
|
||
| if (searchedProperty.PropertyType == typeof(string)) |
Owner
There was a problem hiding this comment.
Extract all the Expression building in ExpressionsBuilder.
| { | ||
| // If the property type is string, use Contains method | ||
| var containsMethod = typeof(string).GetMethod("Contains", new[] { typeof(string) }); | ||
| if (containsMethod != null) |
Owner
There was a problem hiding this comment.
This is strange. Is it possible to have a string without Contains?
| if (searchedProperty.PropertyType == typeof(string)) | ||
| { | ||
| // If the property type is string, use Contains method | ||
| var containsMethod = typeof(string).GetMethod("Contains", new[] { typeof(string) }); |
Owner
There was a problem hiding this comment.
- Move to
TypeExtensions - Use
nameof
Comment on lines
260
to
263
| else | ||
| { | ||
| // If the property type is not string, convert it to string and then use Contains method | ||
| var toStringMethod = typeof(object).GetMethod("ToString"); |
Owner
There was a problem hiding this comment.
Can't this be joined with the if above?
Comment on lines
411
to
417
| { | ||
| var shownFormControls = this.ShownFormControlNames.Concat(this.ShownFormControlNamesOnCreate); | ||
| var hiddenFormControls = this.HiddenFormControlNames.Concat(this.HiddenFormControlNamesOnCreate); | ||
| formControls = SetFormControlsVisibility(formControls, shownFormControls, hiddenFormControls) | ||
| .ToList(); | ||
| break; | ||
| } |
Owner
There was a problem hiding this comment.
We have a static analysis for those. Follow it.
| .ToList() | ||
| .ForEach(property => property.SetValue(existingEntity, property.GetValue(newEntity, null), null)); | ||
|
|
||
| private IEnumerable<DropDownViewModel> FilterAutocompleteResults(int maxResults, PropertyInfo searchedProperty, IEnumerable<PropertyInfo> keys, Expression<Func<TEntity, bool>> lambda) |
Owner
There was a problem hiding this comment.
Rename lambda to expression as it is more accurate.
Comment on lines
888
to
889
| Value = keys!.Count() == 1 | ||
| ? keys.First().GetValue(x) !.ToString() ! |
Owner
There was a problem hiding this comment.
Why is an explicit check for a single value needed?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #41
Summary of changes: