/// <summary> /// Verify Entry.Core.4060 /// </summary> /// <param name="context">Service context</param> /// <param name="info">out parameter to return violation information when rule fail</param> /// <returns>true if rule passes; false otherwise</returns> public override bool?Verify(ServiceContext context, out ExtensionRuleViolationInfo info) { if (context == null) { throw new ArgumentNullException("context"); } bool?passed = null; info = null; JObject entry; context.ResponsePayload.TryToJObject(out entry); if (entry != null && entry.Type == JTokenType.Object) { if (ODataVersion.V3 == context.Version) { JsonParserHelper.ClearPropertyNamesList(); List <string> odataMediaAnnotations = JsonParserHelper.GetSpecifiedPropertyNamesFromEntryPayload(entry, Constants.OdataMedia, MatchType.Contained); if (0 < odataMediaAnnotations.Count) { if (odataMediaAnnotations.Contains(Constants.OdataMediaContentType)) { passed = true; } else { passed = false; info = new ExtensionRuleViolationInfo(this.ErrorMessage, context.Destination, context.ResponsePayload); } } } else if (ODataVersion.V4 == context.Version) { JsonParserHelper.ClearPropertyNamesList(); List <string> odataMediaAnnotations = JsonParserHelper.GetSpecifiedPropertyNamesFromEntryPayload(entry, Constants.V4OdataMedia, MatchType.Contained); if (0 < odataMediaAnnotations.Count) { if (odataMediaAnnotations.Contains(Constants.V4OdataMediaContentType)) { passed = true; } else { passed = false; info = new ExtensionRuleViolationInfo(this.ErrorMessage, context.Destination, context.ResponsePayload); } } } } return(passed); }