Skip to content

Commit 573c1b5

Browse files
Fix broken case with rest services returning SDT collection.
1 parent 0d4d13d commit 573c1b5

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

dotnet/src/dotnetframework/GxClasses/Services/GxRestWrapper.cs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -898,28 +898,27 @@ protected static object MakeRestType( object collectionValue, bool isApiObject)
898898
{
899899
restItemType = ClassLoader.FindType(Config.CommonAssemblyName, itemType.FullName + "_RESTLInterface", null);
900900
}
901-
else if (typeof(IGxGenericCollectionItem).IsAssignableFrom(vType))//Collection<SDTType> convert to GxGenericCollection<SDTType_RESTInterface>
901+
else //Collection<SDTType> convert to GxGenericCollection<SDTType_RESTInterface>
902902
{
903-
restItemType = ClassLoader.FindType(Config.CommonAssemblyName, itemType.FullName + "_RESTInterface", null);
904-
}
905-
else if (typeof(IGxJSONSerializable).IsAssignableFrom(vType))
906-
{
907-
collectionObject = collectionValue;
908-
}
909-
if (restItemType != null)
910-
{
911-
object[] attributes = restItemType.GetCustomAttributes(typeof(GxJsonSerialization), false);
912-
IEnumerable<object> serializationAttributes = attributes.Where(a => a.GetType() == typeof(GxJsonSerialization));
913-
if (serializationAttributes != null && serializationAttributes.Any<object>())
903+
if (typeof(GxUserType).IsAssignableFrom(itemType)){
904+
restItemType = ClassLoader.FindType(Config.CommonAssemblyName, itemType.FullName + "_RESTInterface", null);
905+
}
906+
else
914907
{
915-
GxJsonSerialization attFmt = (GxJsonSerialization)serializationAttributes.FirstOrDefault();
916-
wrappedStatus = attFmt.JsonUnwrapped;
917-
isWrapped = (isApiObject) ? ((wrappedStatus == "wrapped") ? true : false) : ((wrappedStatus == "unwrapped") ? false : true);
908+
restItemType = itemType;
918909
}
919-
isEmpty = !restItemType.IsDefined(typeof(GxOmitEmptyCollection), false);
920-
Type genericListItemType = typeof(GxGenericCollection<>).MakeGenericType(restItemType);
921-
collectionObject = Activator.CreateInstance(genericListItemType, new object[] { collectionValue, isWrapped, wrappedStatus });
922910
}
911+
object[] attributes = restItemType.GetCustomAttributes(typeof(GxJsonSerialization), false);
912+
IEnumerable<object> serializationAttributes = attributes.Where(a => a.GetType() == typeof(GxJsonSerialization));
913+
if (serializationAttributes != null && serializationAttributes.Any<object>())
914+
{
915+
GxJsonSerialization attFmt = (GxJsonSerialization)serializationAttributes.FirstOrDefault();
916+
wrappedStatus = attFmt.JsonUnwrapped;
917+
isWrapped = (isApiObject) ? ((wrappedStatus == "wrapped") ? true : false) : ((wrappedStatus == "unwrapped") ? false : true);
918+
}
919+
isEmpty = !restItemType.IsDefined(typeof(GxOmitEmptyCollection), false);
920+
Type genericListItemType = typeof(GxGenericCollection<>).MakeGenericType(restItemType);
921+
collectionObject = Activator.CreateInstance(genericListItemType, new object[] { collectionValue, isWrapped, wrappedStatus });
923922
}
924923
// Empty collection serialized w/ noproperty
925924
if (collectionObject is IList restList)

0 commit comments

Comments
 (0)