Bg/#67/support email and phone types without type kw#73
Open
ManolisKoufidakis wants to merge 2 commits intobolorundurowb:masterfrom
Open
Bg/#67/support email and phone types without type kw#73ManolisKoufidakis wants to merge 2 commits intobolorundurowb:masterfrom
ManolisKoufidakis wants to merge 2 commits intobolorundurowb:masterfrom
Conversation
Comment on lines
28
to
+45
| var (key, data) = DataSplitHelpers.SplitDatum(datum, '='); | ||
|
|
||
| if (key.EqualsIgnoreCase(FieldKeyConstants.TypeKey) && data != null) | ||
| if (key.EqualsIgnoreCase(FieldKeyConstants.PreferenceKey)) | ||
| { | ||
| var emailTypes = data.Split(FieldKeyConstants.ConcatenationDelimiter); | ||
|
|
||
| type = emailTypes | ||
| .Select(parsedType => parsedType.ParseEmailAddressType()) | ||
| .Aggregate(type, (current, emailType) => current.HasValue ? current.Value | emailType : emailType); | ||
| } | ||
| else if (key.EqualsIgnoreCase(FieldKeyConstants.PreferenceKey)) | ||
| preference = 1; | ||
| continue; | ||
| } | ||
|
|
||
| var emailTypes = key.EqualsIgnoreCase(FieldKeyConstants.TypeKey) && data != null | ||
| ? data.Split(',') | ||
| : key != null && data == null | ||
| ? key.Split(';') | ||
| : null; | ||
|
|
||
| type = emailTypes? | ||
| .Select(parsedType => parsedType.ParseEmailAddressType()) | ||
| .Where(parsedType => parsedType != null) | ||
| .Aggregate(type, (current, emailType) => current.HasValue ? current.Value | emailType : emailType); |
Owner
There was a problem hiding this comment.
Hi @ManolisKoufidakis I think this can be simplified using the helper methods
var (key, data) = DataSplitHelpers.ExtractKeyValue(metadatum, '=');
if (key is null || key.EqualsIgnoreCase(FieldKeyConstants.TypeKey))
{
var parsedType = data.ParseEmailAddressType();
type = type is null ? parsedType : type | parsedType;
}
else if (key.EqualsIgnoreCase(FieldKeyConstants.PreferenceKey))
pref = int.Parse(data);
Comment on lines
+31
to
+46
| if (key.EqualsIgnoreCase(FieldKeyConstants.PreferenceKey)) | ||
| { | ||
| if (string.IsNullOrWhiteSpace(data)) | ||
| continue; | ||
|
|
||
| var typeGroup = data!.Split(FieldKeyConstants.ConcatenationDelimiter); | ||
| preference = 1; | ||
| continue; | ||
| } | ||
|
|
||
| foreach (var individualType in typeGroup) | ||
| { | ||
| var phoneType = individualType.ParseTelephoneNumberType(); | ||
| var phoneTypes = key.EqualsIgnoreCase(FieldKeyConstants.TypeKey) && data != null | ||
| ? data.Split(',') | ||
| : key != null && data == null | ||
| ? key.Split(';') | ||
| : null; | ||
|
|
||
| if (phoneType.HasValue) | ||
| type = type.HasValue ? type.Value | phoneType : phoneType; | ||
| } | ||
| } | ||
| else if (key.EqualsIgnoreCase(FieldKeyConstants.PreferenceKey)) | ||
| preference = 1; | ||
| type = phoneTypes? | ||
| .Select(parsedType => parsedType.ParseTelephoneNumberType()) | ||
| .Where(parsedType => parsedType != null) | ||
| .Aggregate(type, (current, phoneType) => current.HasValue ? current.Value | phoneType : phoneType); |
Owner
There was a problem hiding this comment.
Hi @ManolisKoufidakis I think this can be simplified similar to the above
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.
Feature: Identify email and phone types when Type keyword is not present. This is to support proper v2.1 and v3.0 vcards.