Repository navigation
Set patch value if the value comes from [value eq ] - #11
Ryanmeakins wants to merge 1 commit into
Conversation
| { | ||
| if(this.values == null) | ||
| { | ||
| this.values = this.Path.SubAttributes.First()?.ComparisonValue; |
There was a problem hiding this comment.
this.Path could also be null. A better approach to do this would be during deserialization. You should parse the web-request while de-serializing the object into a PATCH object. That would be a place where you could de-serialize it correctly and do other validations on it.
| { | ||
| if (!group.Members.Any(M => M.Value == member.Value)) | ||
| { | ||
| group.Members = group.Members.Concat(new [] {member}); |
There was a problem hiding this comment.
this is highly non-performant. For every member that needs to be added to the group, this code scans all the other members, so the time complexity is O(n). This shall scale really poorly for the groups of a decent size.
| { | ||
| if (!group.Members.Any(M => M.Value == member.Value)) | ||
| { | ||
| group.Members = group.Members.Concat(new [] {member}); |
There was a problem hiding this comment.
Avoid nested declarations for readability.
|
|
||
| foreach(Member member in newMembers) | ||
| { | ||
| if (!group.Members.Any(M => M.Value == member.Value)) |
There was a problem hiding this comment.
Format LINQ statements in the following way.
!group.Members.Any((member item) => string.Equals(item, member.Value, StringComparison.OrdinalIgnoreCase)
StringComparison instead of "==" because the SCIM client may or may not send the member id in the same case. If the SCIM server requires the string comparison to be case sensitive, then they may do so.
Another way would be to expose an Equals method on the Members and then compare the members for equality, where the Server decides how it wants to implement Equals.
Ankit K Chheda (ankitC)
left a comment
There was a problem hiding this comment.
Link the issue in the pull request.
Squash the commits into a single commit.
Add examples and a verbose explanation to the pull request description.
34f9cdb to
b038ab0
Compare
Initalization update Check for existing group membership before add. Used string equals with compariosn for string values, added new members to a list as they are found
b038ab0 to
4fcd080
Compare
| if (this.Path.SubAttributes.Any()) | ||
| { | ||
| this.values = this.Path.SubAttributes.First().ComparisonValue; | ||
| } |
There was a problem hiding this comment.
This should not be required given that the deserialization is working correctly.
| private void OnDeserialized(StreamingContext context) | ||
| { | ||
| this.OnInitialized(); | ||
| } |
There was a problem hiding this comment.
Not required
| { | ||
| //O(n) with the number of group members, so for large groups this is not optimal | ||
| if (!group.Members.Any((Member item) => | ||
| string.Equals(item.Value, member.Value, StringComparison.OrdinalIgnoreCase))) |
There was a problem hiding this comment.
Nit: Formatting.
if
(
group.Members.Any((Member item) =>
string.Equals(....)
)
{
//logic
}
| { | ||
| writer = new StreamWriter(stream); | ||
| stream = null; | ||
| writer.Write(serialized); |
There was a problem hiding this comment.
All the logic in this file is the same as the base method. The logic to set the correct attributes with the correct values should be set in this method.
No description provided.