OSDN Git Service

TwitterDataModel.ListElementData を TwitterList に移行
authorKimura Youichi <kim.upsilon@bucyou.net>
Mon, 5 May 2014 11:59:23 +0000 (20:59 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Mon, 5 May 2014 17:20:30 +0000 (02:20 +0900)
OpenTween/Api/TwitterDataModel.cs
OpenTween/Api/TwitterList.cs [new file with mode: 0644]
OpenTween/ListElement.cs
OpenTween/OpenTween.csproj
OpenTween/Twitter.cs

index e57ba12..378f15e 100644 (file)
@@ -282,25 +282,9 @@ namespace OpenTween.Api
         }
 
         [DataContract]
-        public class ListElementData
-        {
-            [DataMember(Name = "mode")] public string Mode;
-            [DataMember(Name = "uri")] public string Uri;
-            [DataMember(Name = "member_count")] public int MemberCount;
-            [DataMember(Name = "slug")] public string Slug;
-            [DataMember(Name = "full_name")] public string FullName;
-            [DataMember(Name = "user")] public TwitterUser User;
-            [DataMember(Name = "following")] public bool Following;
-            [DataMember(Name = "subscriber_count")] public int SubscriberCount;
-            [DataMember(Name = "description")] public string Description;
-            [DataMember(Name = "name")] public string Name;
-            [DataMember(Name = "id")] public long Id;
-        }
-
-        [DataContract]
         public class Lists
         {
-            [DataMember(Name = "lists")] public ListElementData[] lists;
+            [DataMember(Name = "lists")] public TwitterList[] lists;
             [DataMember(Name = "next_cursor")] public long NextCursor;
             [DataMember(Name = "previous_cursor")] public long PreviousCursor;
         }
diff --git a/OpenTween/Api/TwitterList.cs b/OpenTween/Api/TwitterList.cs
new file mode 100644 (file)
index 0000000..da01c61
--- /dev/null
@@ -0,0 +1,85 @@
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// All rights reserved.
+//
+// This file is part of OpenTween.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+    [DataContract]
+    public class TwitterList
+    {
+        [DataMember(Name = "user")]
+        public TwitterUser User { get; set; }
+
+        [DataMember(Name = "following")]
+        public bool Following { get; set; }
+
+        [DataMember(Name = "created_at")]
+        public string CreatedAt { get; set; }
+
+        [DataMember(Name = "full_name")]
+        public string FullName { get; set; }
+
+        [DataMember(Name = "slug")]
+        public string Slug { get; set; }
+
+        [DataMember(Name = "id")]
+        public long Id { get; set; }
+
+        [DataMember(Name = "id_str")]
+        public string IdStr { get; set; }
+
+        [DataMember(Name = "name")]
+        public string Name { get; set; }
+
+        [DataMember(Name = "uri")]
+        public string Uri { get; set; }
+
+        [DataMember(Name = "subscriber_count")]
+        public int SubscriberCount { get; set; }
+
+        [DataMember(Name = "member_count")]
+        public int MemberCount { get; set; }
+
+        [DataMember(Name = "mode")]
+        public string Mode { get; set; }
+
+        [DataMember(Name = "description")]
+        public string Description { get; set; }
+
+        /// <exception cref="SerializationException"/>
+        public static TwitterList ParseJson(string json)
+        {
+            return MyCommon.CreateDataFromJson<TwitterList>(json);
+        }
+
+        /// <exception cref="SerializationException"/>
+        public static TwitterList[] ParseJsonArray(string json)
+        {
+            return MyCommon.CreateDataFromJson<TwitterList[]>(json);
+        }
+    }
+}
index f0e02e4..7c67e28 100644 (file)
@@ -52,7 +52,7 @@ namespace OpenTween
         {
         }
 
-        public ListElement(TwitterDataModel.ListElementData listElementData, dynamic tw)
+        public ListElement(TwitterList listElementData, dynamic tw)
         {
             this.Description = listElementData.Description;
             this.Id = listElementData.Id;
index e60505b..abffadd 100644 (file)
@@ -63,6 +63,7 @@
   <ItemGroup>
     <Compile Include="Api\ApiLimit.cs" />
     <Compile Include="Api\TwitterEntity.cs" />
+    <Compile Include="Api\TwitterList.cs" />
     <Compile Include="Api\TwitterUser.cs" />
     <Compile Include="Api\TwitterApiAccessLevel.cs" />
     <Compile Include="Api\TwitterApiStatus.cs" />
index 8d5eca3..f753968 100644 (file)
@@ -2512,7 +2512,7 @@ namespace OpenTween
 
             try
             {
-                lists = MyCommon.CreateDataFromJson<List<TwitterDataModel.ListElementData>>(content)
+                lists = TwitterList.ParseJsonArray(content)
                     .Select(x => new ListElement(x, this));
             }
             catch (SerializationException ex)
@@ -2540,7 +2540,7 @@ namespace OpenTween
 
             try
             {
-                lists = lists.Concat(MyCommon.CreateDataFromJson<List<TwitterDataModel.ListElementData>>(content)
+                lists = lists.Concat(TwitterList.ParseJsonArray(content)
                     .Select(x => new ListElement(x, this)));
             }
             catch (SerializationException ex)
@@ -2597,7 +2597,7 @@ namespace OpenTween
 
             try
             {
-                var le = MyCommon.CreateDataFromJson<TwitterDataModel.ListElementData>(content);
+                var le = TwitterList.ParseJson(content);
                 var newList = new ListElement(le, this);
                 list.Description = newList.Description;
                 list.Id = newList.Id;
@@ -2683,7 +2683,7 @@ namespace OpenTween
 
             try
             {
-                var le = MyCommon.CreateDataFromJson<TwitterDataModel.ListElementData>(content);
+                var le = TwitterList.ParseJson(content);
                 TabInformations.GetInstance().SubscribableLists.Add(new ListElement(le, this));
                 return "";
             }