@@ -809,6 +809,20 @@ public PropertyModifier GetPropertyModifier(string shapeName, string propertyNam
809
809
return null ;
810
810
}
811
811
812
+ /// <summary>
813
+ /// Gets the property modifier for a property if it exists. Otherwise returns false.
814
+ /// </summary>
815
+ /// <param name="shapeName"></param>
816
+ /// <param name="propertyName"></param>
817
+ /// <param name="propertyModifier"></param>
818
+ /// <returns></returns>
819
+ public bool TryGetPropertyModifier ( string shapeName , string propertyName , out PropertyModifier propertyModifier )
820
+ {
821
+ propertyModifier = null ;
822
+ propertyModifier = GetPropertyModifier ( shapeName , propertyName ) ?? null ;
823
+ return propertyModifier != null ? true : false ;
824
+ }
825
+
812
826
/// <summary>
813
827
/// Determines if the property has a customization to be set to nullable
814
828
/// </summary>
@@ -1020,6 +1034,7 @@ public class ShapeModifier
1020
1034
public const string ShapeModifierXmlNamespaceKey = "xmlNamespace" ;
1021
1035
public const string OriginalMemberIsOutsideContainingShapeKey = "originalMemberIsOutsideContainingShape" ;
1022
1036
public const string PredicateListUnmarshallersKey = "predicateListUnmarshallers" ;
1037
+ public const string ExcludeFromUnmarshallingKey = "excludeFromUnmarshalling" ;
1023
1038
1024
1039
private readonly HashSet < string > _excludedProperties ;
1025
1040
private readonly Dictionary < string , JsonData > _modifiedProperties ;
@@ -1030,6 +1045,7 @@ public class ShapeModifier
1030
1045
private readonly HashSet < string > _shapeDocumentation ;
1031
1046
private readonly string _shapeModifierXmlNamespace ;
1032
1047
private readonly Dictionary < string , JsonData > _predicateListUnmarshallers ;
1048
+ private readonly HashSet < string > _excludedUnmarshallingProperties ;
1033
1049
1034
1050
public string DeprecationMessage { get ; private set ; }
1035
1051
@@ -1049,6 +1065,7 @@ public ShapeModifier(JsonData data)
1049
1065
_shapeDocumentation = ParseShapeDocumentation ( data ) ;
1050
1066
_shapeModifierXmlNamespace = ParseXmlNamespace ( data ) ;
1051
1067
_predicateListUnmarshallers = ParsePredicateListUnmarshallers ( data ) ;
1068
+ _excludedUnmarshallingProperties = ParseExcludedUnmarshallingProperties ( data ) ;
1052
1069
Validate ( data ) ;
1053
1070
}
1054
1071
@@ -1317,6 +1334,7 @@ private static Dictionary<string, JsonData> ParsePredicateListUnmarshallers(Json
1317
1334
?? new Dictionary < string , JsonData > ( ) ;
1318
1335
1319
1336
}
1337
+
1320
1338
/// <summary>
1321
1339
/// This customization tells the generator that the member's shape is a filter type that has predicates
1322
1340
/// and operators and that it should be unmarshalled with the PredicateListUnmarshaller type that each
@@ -1327,6 +1345,35 @@ private static Dictionary<string, JsonData> ParsePredicateListUnmarshallers(Json
1327
1345
public Dictionary < string , JsonData > PredicateListUnmarshallers { get { return _predicateListUnmarshallers ; } }
1328
1346
1329
1347
#endregion
1348
+
1349
+ #region ExcludedUnmarshallingProperties
1350
+
1351
+ private static HashSet < string > ParseExcludedUnmarshallingProperties ( JsonData data )
1352
+ {
1353
+ var excludedUnmarshallingProperties = data [ ShapeModifier . ExcludeFromUnmarshallingKey ] ? . Cast < object > ( )
1354
+ . Select ( x => x . ToString ( ) ) ;
1355
+
1356
+ return new HashSet < string > ( excludedUnmarshallingProperties ?? new string [ 0 ] ) ;
1357
+ }
1358
+
1359
+ /// <summary>
1360
+ /// Properties that should be excluded from unmarshalling. Example usage:
1361
+ ///
1362
+ /// The members that should be excluded are in the array.
1363
+ /// "S3Grantee":{
1364
+ /// "modify": [
1365
+ /// {
1366
+ /// "ID": {"emitPropertyName": "CanonicalUser"}
1367
+ /// }
1368
+ /// ],
1369
+ /// "excludeFromUnmarshalling":
1370
+ /// [
1371
+ /// "Type"
1372
+ /// ]
1373
+ /// },
1374
+ /// </summary>
1375
+ public HashSet < string > ExcludedUnmarshallingProperties { get { return _excludedUnmarshallingProperties ; } }
1376
+ #endregion
1330
1377
}
1331
1378
1332
1379
/// <summary>
@@ -1393,14 +1440,17 @@ public class PropertyModifier
1393
1440
public const string EmitPropertyNameKey = "emitPropertyName" ;
1394
1441
public const string LocationNameKey = "locationName" ;
1395
1442
public const string AccessModifierKey = "accessModifier" ;
1443
+ public const string InjectXmlUnmarshallCodeKey = "injectXmlUnmarshallCode" ;
1444
+ public const string SkipContextTestExpressionUnmarshallingLogicKey = "skipContextTestExpressionUnmarshallingLogic" ;
1396
1445
1397
1446
private readonly string _modelPropertyName ; // for debug inspection assist
1398
1447
private readonly JsonData _modifierData ;
1399
-
1448
+ private readonly HashSet < string > _injectXmlUnmarshallCode ;
1400
1449
internal PropertyModifier ( string modelPropertyName , JsonData modifierData )
1401
1450
{
1402
1451
this . _modelPropertyName = modelPropertyName ;
1403
1452
this . _modifierData = modifierData ;
1453
+ _injectXmlUnmarshallCode = ParseInjectXmlUnmarshallCode ( ) ;
1404
1454
}
1405
1455
1406
1456
// The access modifier for the property. Defaults to public if not set in the customization.
@@ -1473,14 +1523,56 @@ public bool UseCustomMarshall
1473
1523
}
1474
1524
1475
1525
public string DeprecationMessage
1476
- {
1477
- get
1478
1526
{
1527
+ get
1528
+ {
1479
1529
return _modifierData [ ShapeModifier . DeprecatedMessageKey ] . CastToString ( ) ;
1530
+ }
1480
1531
}
1481
- }
1532
+
1533
+ private HashSet < string > ParseInjectXmlUnmarshallCode ( )
1534
+ {
1535
+ var data = _modifierData [ InjectXmlUnmarshallCodeKey ] ? . Cast < object > ( )
1536
+ . Select ( x => x . ToString ( ) ) ;
1537
+
1538
+ return new HashSet < string > ( data ?? new string [ 0 ] ) ;
1482
1539
}
1483
1540
1541
+ /// <summary>
1542
+ /// Use this customization for rest-xml services when you want to inject some code into the "Context.TestExpression" portion
1543
+ /// of the member.
1544
+ ///
1545
+ /// A prime example of this is here https://github.com/aws/aws-sdk-net/blob/79cbc392fc3f1c74fcdf34efd77ad681da8af328/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsV2ResponseUnmarshaller.cs#L85
1546
+ /// How to use this customization (within the modify array of a property) :
1547
+ /// Within the "Contents" member while this member is being unmarshalled the code in the "injectXmlUnmarshallCode" will be added line by line
1548
+ /// right before the "continue" statement within each "context.TestExpression" call.
1549
+ /// {
1550
+ /// "Contents" : {
1551
+ /// "emitPropertyName" : "S3Objects",
1552
+ /// "injectXmlUnmarshallCode":[
1553
+ /// "response.S3Objects[response.S3Objects.Count - 1].BucketName = response.Name;"
1554
+ /// ]
1555
+ /// }
1556
+ /// },
1557
+ /// </summary>
1558
+ public HashSet < string > InjectXmlUnmarshallCode
1559
+ {
1560
+ get { return _injectXmlUnmarshallCode ; }
1561
+ }
1562
+
1563
+ /// <summary>
1564
+ /// If this is set, all the logic inside of the "context.testExpression" code block for that member won't be generated. this is meant
1565
+ /// to be used in conjunction with InjectXmlUnmarshallCode, but can be used separately as well. For example:
1566
+ /// "Versions":{
1567
+ /// "skipContextTestExpressionUnmarshallingLogic" : true,
1568
+ /// "injectXmlUnmarshallCode" :[
1569
+ /// "VersionsItemCustomUnmarshall(context, response);"
1570
+ /// ]
1571
+ /// }
1572
+ /// </summary>
1573
+ public bool SkipContextTestExpressionUnmarshallingLogic { get { return _modifierData [ SkipContextTestExpressionUnmarshallingLogicKey ] != null ; } }
1574
+ }
1575
+
1484
1576
#endregion
1485
1577
// Injection modifier is an array of objects, each object being the
1486
1578
private Dictionary < string , ShapeModifier > _shapeModifiers = null ;
0 commit comments