public PersonalCommunication ProcessAndValidate(PersonalCommunication instance, out List <Exception> exceptions, out bool shouldSuppressProcessing) { ProcessAndValidateCommon(instance, out exceptions, out shouldSuppressProcessing); return(instance); }
/// <summary> /// Performs a JSON-to-Object conversion. /// </summary> /// <param name="reader"> /// A JsonReader object. /// </param> /// <param name="objectType"> /// The type of the object. /// </param> /// <param name="existingValue"> /// The existing value. /// </param> /// <param name="serializer"> /// A JsonSerializer object. /// </param> /// <returns> /// A converted object. /// </returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { const string ITEM_TYPE_KEY = "ItemType"; const string ARGUMENT_EXCEPTON = "Invalid Or Missing ItemType"; ContentItem contentItem = null; ItemType itemType = ItemType.Unknown; JObject jObject = JObject.Load(reader); JToken jToken = null; if (jObject.TryGetValue(ITEM_TYPE_KEY, StringComparison.CurrentCultureIgnoreCase, out jToken) && jToken != null && Enum.TryParse(jToken.Value <string>(), true, out itemType)) { switch (itemType) { case ItemType.Unknown: throw new ArgumentException(ARGUMENT_EXCEPTON); case ItemType.Book: contentItem = new Book(); break; case ItemType.Chapter: contentItem = new Chapter(); break; case ItemType.Journal: contentItem = new Journal(); break; case ItemType.Magazine: contentItem = new Magazine(); break; case ItemType.Newspaper: contentItem = new Newspaper(); break; case ItemType.Webpage: contentItem = new Webpage(); break; case ItemType.Encyclopedia: contentItem = new Encyclopedia(); break; case ItemType.Graphic: contentItem = new Graphic(); break; case ItemType.AudioRecording: contentItem = new AudioRecording(); break; case ItemType.VideoRecording: contentItem = new VideoRecording(); break; case ItemType.Broadcast: contentItem = new Broadcast(); break; case ItemType.PersonalCommunication: contentItem = new PersonalCommunication(); break; case ItemType.Interview: contentItem = new Interview(); break; case ItemType.Presentation: contentItem = new Presentation(); break; case ItemType.Map: contentItem = new Map(); break; case ItemType.Bill: contentItem = new Bill(); break; case ItemType.Legislation: contentItem = new Legislation(); break; case ItemType.LegalCase: contentItem = new LegalCase(); break; case ItemType.Report: contentItem = new Report(); break; case ItemType.ConferencePaper: contentItem = new ConferencePaper(); break; default: throw new NotImplementedException(); } } else { throw new ArgumentException(ARGUMENT_EXCEPTON); } if (serializer != null) { serializer.Populate(jObject.CreateReader(), contentItem); } return(contentItem); }