Skip to content

Commit 6402a04

Browse files
committed
Ticket #48 : AttributesList != null && AttributeList.Any()
1 parent f46a222 commit 6402a04

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>1.1.6</VersionPrefix>
3+
<VersionPrefix>1.1.7</VersionPrefix>
44
<Authors>SimpleIdServer</Authors>
55
<Owners>SimpleIdServer</Owners>
66
</PropertyGroup>

src/Scim/SimpleIdServer.Scim/Extensions/SCIMRepresentationExtensions.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,20 @@ public static void EnrichResponse(IQueryable<SCIMRepresentationAttribute> attrib
446446
switch (representationAttr.SchemaAttribute.Type)
447447
{
448448
case SCIMSchemaAttributeTypes.STRING:
449-
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesString) : representationAttr.ValuesString.First());
449+
if (representationAttr.ValuesString != null && representationAttr.ValuesString.Any())
450+
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesString) : representationAttr.ValuesString.First());
450451
break;
451452
case SCIMSchemaAttributeTypes.BOOLEAN:
452-
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesBoolean) : representationAttr.ValuesBoolean.First());
453+
if (representationAttr.ValuesBoolean != null && representationAttr.ValuesBoolean.Any())
454+
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesBoolean) : representationAttr.ValuesBoolean.First());
453455
break;
454456
case SCIMSchemaAttributeTypes.INTEGER:
455-
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesInteger) : representationAttr.ValuesInteger.First());
457+
if (representationAttr.ValuesInteger != null && representationAttr.ValuesInteger.Any())
458+
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesInteger) : representationAttr.ValuesInteger.First());
456459
break;
457460
case SCIMSchemaAttributeTypes.DATETIME:
458-
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesDateTime) : representationAttr.ValuesDateTime.First());
461+
if (representationAttr.ValuesDateTime != null && representationAttr.ValuesDateTime.Any())
462+
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesDateTime) : representationAttr.ValuesDateTime.First());
459463
break;
460464
case SCIMSchemaAttributeTypes.COMPLEX:
461465
if (representationAttr.SchemaAttribute.MultiValued == false)
@@ -478,10 +482,12 @@ public static void EnrichResponse(IQueryable<SCIMRepresentationAttribute> attrib
478482
}
479483
break;
480484
case SCIMSchemaAttributeTypes.DECIMAL:
481-
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesDecimal) : representationAttr.ValuesDecimal.First());
485+
if (representationAttr.ValuesDecimal != null && representationAttr.ValuesDecimal.Any())
486+
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesDecimal) : representationAttr.ValuesDecimal.First());
482487
break;
483488
case SCIMSchemaAttributeTypes.BINARY:
484-
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesBinary.Select(_ => Convert.ToBase64String(_))) : Convert.ToBase64String(representationAttr.ValuesBinary.First()));
489+
if (representationAttr.ValuesBinary != null && representationAttr.ValuesBinary.Any())
490+
jObj.Add(representationAttr.SchemaAttribute.Name, representationAttr.SchemaAttribute.MultiValued ? (JToken)new JArray(representationAttr.ValuesBinary.Select(_ => Convert.ToBase64String(_))) : Convert.ToBase64String(representationAttr.ValuesBinary.First()));
485491
break;
486492
}
487493
}

0 commit comments

Comments
 (0)