Imports System
Imports System.Text
Namespace DesignPatterns.Core.Composite
Public Class StoriesWriter
……中略……
' メソッドの抽出が行われたGetContentsメソッド
Public Function GetContents() As String
Dim xml As StringBuilder = New StringBuilder
WriteStoriesTo(xml)
Return xml.ToString()
End Function
' すべてのストーリーを出力する
Private Sub WriteStoriesTo(ByVal xml As StringBuilder)
xml.Append("<stories>")
For Each myStory As Story In _stories
xml.Append("<story")
xml.Append(" no=""")
xml.Append(myStory.No.ToString())
xml.Append("""")
xml.Append(" priority=""")
xml.Append(myStory.Priority.ToString())
xml.Append(""">")
WriteStoryContentTo(xml, myStory)
WriteTasksTo(xml, myStory)
xml.Append("</story>")
Next
xml.Append("</stories>")
End Sub
' ストーリーの内容を出力する
Private Sub WriteStoryContentTo(ByVal xml As StringBuilder, _
ByVal myStory As Story)
xml.Append("<content>")
xml.Append(myStory.Content)
xml.Append("</content>")
End Sub
' すべてのタスクを出力する
Private Sub WriteTasksTo(ByVal xml As StringBuilder, ByVal myStory As Story)
For Each myTask As Task In myStory
xml.Append("<task")
xml.Append(" no=""")
xml.Append(myTask.No.ToString())
xml.Append("""")
xml.Append(" storyNo=""")
xml.Append(myTask.StoryNo.ToString())
xml.Append(""">")
WriteTaskActualPointTo(xml, myTask)
WriteTaskEstimatedPointTo(xml, myTask)
WriteTaskContentTo(xml, myTask)
xml.Append("</task>")
Next
End Sub
' タスクの実測ポイントを出力する
Private Sub WriteTaskActualPointTo(ByVal xml As StringBuilder, _
ByVal myTask As Task)
xml.Append("<actualPoint")
xml.Append(" isOver=""")
xml.Append(myTask.IsOverPoint().ToString())
xml.Append(""">")
xml.Append(myTask.ActualPoint.ToString("##.0"))
xml.Append("</actualPoint>")
End Sub
' タスクの予定ポイントを出力する
Private Sub WriteTaskEstimatedPointTo(ByVal xml As StringBuilder, _
ByVal myTask As Task)
xml.Append("<estimatedPoint>")
xml.Append(myTask.EstimatedPoint.ToString("##.0"))
xml.Append("</estimatedPoint>")
End Sub
' タスクの内容を出力する
Private Sub WriteTaskContentTo(ByVal xml As StringBuilder, ByVal myTask As Task)
xml.Append("<content>")
xml.Append(myTask.Content)
xml.Append("</content>")
End Sub
End Class
End Namespace |
|