/// <summary> /// Initializes a new image picker item based on the specified <paramref name="image"/>, <paramref name="title"/>, /// <paramref name="description"/> and <paramref name="link"/>. /// </summary> /// <param name="image">An instance of <see cref="IPublishedContent"/> representing the selected image.</param> /// <param name="title">The title of the item.</param> /// <param name="description">The description of the item.</param> /// <param name="link">An instance of <see cref="LinkPickerItem"/> representing the link of the item.</param> public ImagePickerItem(ImagePickerImage image, string title, string description, LinkPickerItem link) { Image = image; Title = title; Description = description; Link = link ?? LinkPickerItem.Parse(new JObject()); }
/// <summary> /// Initializes a new image picker item based on the specified <see cref="JObject"/>. /// </summary> /// <param name="obj">An instanceo of <see cref="JObject"/> representing the item.</param> protected ImagePickerItem(JObject obj) { JObject = obj; Image = obj.GetInt32("imageId", ImagePickerImage.GetFromId); Title = obj.GetString("title") ?? ""; Description = obj.GetString("description") ?? ""; Link = obj.GetObject("link", LinkPickerItem.Parse) ?? LinkPickerItem.Parse(new JObject()); NoCrop = obj.GetBoolean("nocrop"); }
private object ReadJsonObject(JsonReader reader, Type objectType) { JObject obj = JObject.Load(reader); if (!(objectType == typeof(LinkPickerItem))) { return(null); } if (obj != null) { return(LinkPickerItem.Parse(obj)); } return(new LinkPickerItem()); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { // Skip if the reader is not at the start of an object if (reader.TokenType != JsonToken.StartObject) { return(null); } // Load JObject from stream JObject obj = JObject.Load(reader); switch (objectType.FullName) { case "Skybrud.LinkPicker.LinkPickerList": return(LinkPickerList.Parse(obj)); case "Skybrud.LinkPicker.LinkPickerItem": return(LinkPickerItem.Parse(obj)); default: return(null); } }