[Tween-svn] [1016] Source整形のコードを別メソッドにまとめ

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 11月 1日 (月) 13:46:02 JST


Revision: 1016
          http://sourceforge.jp/projects/tween/svn/view?view=rev&revision=1016
Author:   syo68k
Date:     2010-11-01 13:46:02 +0900 (Mon, 01 Nov 2010)

Log Message:
-----------
Source整形のコードを別メソッドにまとめ

Modified Paths:
--------------
    trunk/Tween/Twitter.vb


-------------- next part --------------
Modified: trunk/Tween/Twitter.vb
===================================================================
--- trunk/Tween/Twitter.vb	2010-11-01 04:10:04 UTC (rev 1015)
+++ trunk/Tween/Twitter.vb	2010-11-01 04:46:02 UTC (rev 1016)
@@ -610,25 +610,7 @@
             post.Data = HttpUtility.HtmlDecode(post.Data)
             post.Data = post.Data.Replace("<3", "♡")
             'Source整形
-            If post.Source.StartsWith("<") Then
-                'Dim rgS As New Regex(">(?<source>.+)<")
-                If Not post.Source.Contains("</a>") Then
-                    post.Source += "</a>"
-                End If
-                post.SourceHtml = String.Copy(post.Source)
-                Dim mS As Match = Regex.Match(post.Source, ">(?<source>.+)<")
-                If mS.Success Then
-                    post.Source = HttpUtility.HtmlDecode(mS.Result("${source}"))
-                End If
-            Else
-                If post.Source = "web" Then
-                    post.SourceHtml = My.Resources.WebSourceString
-                ElseIf post.Source = "Keitai Mail" Then
-                    post.SourceHtml = My.Resources.KeitaiMailSourceString
-                Else
-                    post.SourceHtml = String.Copy(post.Source)
-                End If
-            End If
+            CreateSource(post)
 
             post.IsRead = read
             post.IsReply = post.ReplyToList.Contains(_uid)
@@ -1544,25 +1526,7 @@
                 post.Data = HttpUtility.HtmlDecode(post.Data)
                 post.Data = post.Data.Replace("<3", "♡")
                 'Source整形
-                If post.Source.StartsWith("<") Then
-                    'Dim rgS As New Regex(">(?<source>.+)<")
-                    If Not post.Source.Contains("</a>") Then
-                        post.Source += "</a>"
-                    End If
-                    post.SourceHtml = String.Copy(post.Source)
-                    Dim mS As Match = Regex.Match(post.Source, ">(?<source>.+)<")
-                    If mS.Success Then
-                        post.Source = HttpUtility.HtmlDecode(mS.Result("${source}"))
-                    End If
-                Else
-                    If post.Source = "web" Then
-                        post.SourceHtml = My.Resources.WebSourceString
-                    ElseIf post.Source = "Keitai Mail" Then
-                        post.SourceHtml = My.Resources.KeitaiMailSourceString
-                    Else
-                        post.SourceHtml = String.Copy(post.Source)
-                    End If
-                End If
+                CreateSource(post)
 
                 post.IsRead = read
                 If gType = WORKERTYPE.Timeline OrElse tab IsNot Nothing Then
@@ -1700,25 +1664,7 @@
                 post.OriginalData = CreateHtmlAnchor(HttpUtility.HtmlEncode(post.Data), post.ReplyToList)
                 post.Data = HttpUtility.HtmlDecode(post.Data)
                 'Source整形
-                If post.Source.StartsWith("<") Then
-                    'Dim rgS As New Regex(">(?<source>.+)<")
-                    If Not post.Source.Contains("</a>") Then
-                        post.Source += "</a>"
-                    End If
-                    post.SourceHtml = String.Copy(post.Source)
-                    Dim mS As Match = Regex.Match(post.Source, ">(?<source>.+)<")
-                    If mS.Success Then
-                        post.Source = HttpUtility.HtmlDecode(mS.Result("${source}"))
-                    End If
-                Else
-                    If post.Source = "web" Then
-                        post.SourceHtml = My.Resources.WebSourceString
-                    ElseIf post.Source = "Keitai Mail" Then
-                        post.SourceHtml = My.Resources.KeitaiMailSourceString
-                    Else
-                        post.SourceHtml = String.Copy(post.Source)
-                    End If
-                End If
+                CreateSource(post)
 
                 post.IsRead = read
                 post.IsReply = post.ReplyToList.Contains(_uid)
@@ -2004,24 +1950,7 @@
                 post.Data = HttpUtility.HtmlDecode(post.Data)
                 post.Data = post.Data.Replace("<3", "♡")
                 'Source整形
-                If post.Source.StartsWith("<") Then
-                    If Not post.Source.Contains("</a>") Then
-                        post.Source += "</a>"
-                    End If
-                    post.SourceHtml = String.Copy(post.Source)
-                    Dim mS As Match = Regex.Match(post.Source, ">(?<source>.+)<")
-                    If mS.Success Then
-                        post.Source = HttpUtility.HtmlDecode(mS.Result("${source}"))
-                    End If
-                Else
-                    If post.Source = "web" Then
-                        post.SourceHtml = My.Resources.WebSourceString
-                    ElseIf post.Source = "Keitai Mail" Then
-                        post.SourceHtml = My.Resources.KeitaiMailSourceString 
-                    Else
-                        post.SourceHtml = String.Copy(post.Source)
-                    End If
-                End If
+                CreateSource(post)
 
                 post.IsRead = read
                 post.IsReply = post.ReplyToList.Contains(_uid)
@@ -2553,6 +2482,28 @@
         Return retStr
     End Function
 
+    'Source整形
+    Private Sub CreateSource(ByRef post As PostClass)
+        If post.Source.StartsWith("<") Then
+            If Not post.Source.Contains("</a>") Then
+                post.Source += "</a>"
+            End If
+            post.SourceHtml = String.Copy(post.Source)
+            Dim mS As Match = Regex.Match(post.Source, ">(?<source>.+)<")
+            If mS.Success Then
+                post.Source = HttpUtility.HtmlDecode(mS.Result("${source}"))
+            End If
+        Else
+            If post.Source = "web" Then
+                post.SourceHtml = My.Resources.WebSourceString
+            ElseIf post.Source = "Keitai Mail" Then
+                post.SourceHtml = My.Resources.KeitaiMailSourceString
+            Else
+                post.SourceHtml = String.Copy(post.Source)
+            End If
+        End If
+    End Sub
+
     Public Function GetInfoApi(ByVal info As ApiInfo) As Boolean
         If Twitter.AccountState <> ACCOUNT_STATE.Valid Then Return True
 



Tween-svn メーリングリストの案内
Back to archive index