// A modifier is an array of objects, each object being the original // property name (key) and an object containing replacement name (value) // along with any custom marshal naming to apply. // "modify": [ // { // "modelPropertyName": { // "emitPropertyName": "userVisibleName", // "locationName": "customRequestMarshalName", // "emitFromMember": "subMember" // } // } // ] private static void ParseModifiers(ShapeModifier shapeModifier, JsonData data) { if (data == null) return; foreach (var modifier in data) { var m = modifier as JsonData; var key = m.PropertyNames.First(); shapeModifier.AddModifier(key, m[key]); } }
// Injection modifier is an array of objects, each object being the // name of the member to add plus any needed shape/marshalling data. // "inject": [ // { "propertyName": // { "type": "list", // "member": { "shape": "String", "locationName": "item" } // } // } // ] // Since we don't have access to the model at this point, we simply store // the json data for the shape type to be used and 'hydrate' it when needed // externally private static void ParseInjections(ShapeModifier shapeModifier, JsonData data) { if (data == null) return; foreach (var injection in data) { var i = injection as JsonData; var propertyName = i.PropertyNames.First(); shapeModifier.AddInjection(propertyName, i[propertyName]); } }
// Exclusion modifier is a simple array of property names. // "exclude": [ "propName1", "propName2" ] private static void ParseExclusions(ShapeModifier shapeModifier, JsonData data) { if (data == null) return; foreach (var exclusion in data) { shapeModifier.AddExclusion(exclusion.ToString()); } }