1 //----------------------------------------------------------------------- 2 // <copyright file="TwitterUserCollection.cs" company="Patrick Ricky Smith"> 3 // This file is part of the Twitterizer library (http://www.twitterizer.net/) 4 // 5 // Copyright (c) 2010, Patrick "Ricky" Smith (ricky@digitally-born.com) 6 // All rights reserved. 7 // 8 // Redistribution and use in source and binary forms, with or without modification, are 9 // permitted provided that the following conditions are met: 10 // 11 // - Redistributions of source code must retain the above copyright notice, this list 12 // of conditions and the following disclaimer. 13 // - Redistributions in binary form must reproduce the above copyright notice, this list 14 // of conditions and the following disclaimer in the documentation and/or other 15 // materials provided with the distribution. 16 // - Neither the name of the Twitterizer nor the names of its contributors may be 17 // used to endorse or promote products derived from this software without specific 18 // prior written permission. 19 // 20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 // POSSIBILITY OF SUCH DAMAGE. 30 // </copyright> 31 // <author>Ricky Smith</author> 32 // <summary>The collection class containing zero or more TwitterUser objects.</summary> 33 //----------------------------------------------------------------------- 34 namespace Twitterizer 35 { 36 using Twitterizer.Core; 37 using Newtonsoft.Json.Linq; 38 using Newtonsoft.Json; 39 using System.Runtime.Serialization; 40 41 /// <summary> 42 /// The TwitterUserCollection class. 43 /// </summary> 44 #if !SILVERLIGHT 45 [System.Serializable] 46 #endif 47 [DataContract] 48 public class TwitterUserCollection : TwitterCollection<TwitterUser>, ITwitterObject 49 { 50 /// <summary> 51 /// Gets or sets the next cursor. 52 /// </summary> 53 /// <value>The next cursor.</value> 54 [DataMember] 55 public long NextCursor { get; internal set; } 56 57 /// <summary> 58 /// Gets or sets the previous cursor. 59 /// </summary> 60 /// <value>The previous cursor.</value> 61 [DataMember] 62 public long PreviousCursor { get; internal set; } 63 64 /// <summary> 65 /// Gets or sets information about the user's rate usage. 66 /// </summary> 67 /// <value>The rate limiting object.</value> 68 [DataMember] 69 public RateLimiting RateLimiting { get; internal set; } 70 71 /// <summary> 72 /// Deserializes the specified value. 73 /// </summary> 74 /// <param name="value">The value.</param> 75 /// <returns></returns> DeserializeWrapper(JObject value)76 internal static TwitterUserCollection DeserializeWrapper(JObject value) 77 { 78 if (value == null || value.SelectToken("users") == null) 79 { 80 return null; 81 } 82 83 TwitterUserCollection result = JsonConvert.DeserializeObject<TwitterUserCollection>(value.SelectToken("users").ToString()); 84 result.NextCursor = value.SelectToken("next_cursor").Value<long>(); 85 result.PreviousCursor = value.SelectToken("previous_cursor").Value<long>(); 86 87 return result; 88 } 89 } 90 } 91