' ******************************************************************************
' **
' ** Yahoo Finance Managed
' ** Written by Marius Häusler 2010
' ** It would be pleasant, if you contact me when you are using this code.
' ** Contact: YahooFinanceManaged@gmail.com
' ** Project Home: http://code.google.com/p/yahoo-finance-managed/
' **
' ******************************************************************************
' **
' ** Copyright 2010 Marius Häusler
' **
' ** Licensed under the Apache License, Version 2.0 (the "License");
' ** you may not use this file except in compliance with the License.
' ** You may obtain a copy of the License at
' **
' ** http://www.apache.org/licenses/LICENSE-2.0
' **
' ** Unless required by applicable law or agreed to in writing, software
' ** distributed under the License is distributed on an "AS IS" BASIS,
' ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' ** See the License for the specific language governing permissions and
' ** limitations under the License.
' **
' ******************************************************************************
Namespace RSS
''' <summary>
''' Provides RSS feed data.
''' </summary>
''' <remarks></remarks>
<Serializable()> _
Public Class Feed
Private ReadOnly mHelper As New MyHelper
Private mDescription, mTitle, mCopyright, mGenerator, mRating, mName As String
Private mSkiphours(-1), mTtl As Integer
Private mPubDate, mLastBuildDate As DateTime
Private mLanguage As Globalization.CultureInfo
Private mDocs, mLink As Uri
Private mManagingEditor, mWebmaster As Mail.MailAddress
Private mSkipdays(-1) As DayOfWeek
Private mItems As List(Of FeedItem)
Private mImage As Image
Private mCategory As Category
Private mCloud As Cloud
Private mInputBox As TextInputBox
''' <summary>
''' Specify one or more categories that the channel belongs to.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Category() As Category
Get
Return mCategory
End Get
Set(ByVal value As Category)
mCategory = value
End Set
End Property
''' <summary>
''' Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Cloud() As Cloud
Get
Return mCloud
End Get
Set(ByVal value As Cloud)
mCloud = value
End Set
End Property
''' <summary>
''' Copyright notice for content in the channel.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Copyright() As String
Get
Return mCopyright
End Get
Set(ByVal value As String)
mCopyright = value
End Set
End Property
''' <summary>
''' Phrase or sentence describing the channel.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Description() As String
Get
Return mDescription
End Get
Set(ByVal value As String)
mDescription = value
End Set
End Property
''' <summary>
''' A URL that points to the documentation (http://www.rssboard.org/rss-specification) for the format used in the RSS file. It's probably a pointer to this page. It's for people who might stumble across an RSS file on a Web server 25 years from now and wonder what it is.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Documentation() As Uri
Get
Return mDocs
End Get
Set(ByVal value As Uri)
mDocs = value
End Set
End Property
''' <summary>
''' A string indicating the program used to generate the channel.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Generator() As String
Get
Return mGenerator
End Get
Set(ByVal value As String)
mGenerator = value
End Set
End Property
''' <summary>
''' Specifies a GIF, JPEG or PNG image that can be displayed with the channel.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Image() As Image
Get
Return mImage
End Get
Set(ByVal value As Image)
mImage = value
End Set
End Property
''' <summary>
''' A channel may contain any number of items. An item may represent a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Items() As List(Of FeedItem)
Get
Return mItems
End Get
Set(ByVal value As List(Of FeedItem))
mItems = value
End Set
End Property
''' <summary>
''' The language the channel is written in. This allows aggregators to group all Italian language sites, for example, on a single page.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Language() As Globalization.CultureInfo
Get
Return mLanguage
End Get
Set(ByVal value As Globalization.CultureInfo)
mLanguage = value
End Set
End Property
''' <summary>
''' The last time the content of the channel changed.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property LastBuildDate() As DateTime
Get
Return mLastBuildDate
End Get
Set(ByVal value As DateTime)
mLastBuildDate = value
End Set
End Property
''' <summary>
''' The URL to the HTML website corresponding to the channel.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Link() As Uri
Get
Return mLink
End Get
Set(ByVal value As Uri)
mLink = value
End Set
End Property
''' <summary>
''' Email address for person responsible for editorial content.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property ManagingEditor() As Mail.MailAddress
Get
Return mManagingEditor
End Get
Set(ByVal value As Mail.MailAddress)
mManagingEditor = value
End Set
End Property
Public Property Name() As String
Get
Return mName
End Get
Set(ByVal value As String)
mName = value
End Set
End Property
''' <summary>
''' The publication date for the content in the channel. For example, the New York Times publishes on a daily basis, the publication date flips once every 24 hours. That's when the pubDate of the channel changes.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property PublishDate() As DateTime
Get
Return mPubDate
End Get
Set(ByVal value As DateTime)
mPubDate = value
End Set
End Property
''' <summary>
''' The PICS (http://www.w3.org/PICS/) rating for the channel.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Rating() As String
Get
Return mRating
End Get
Set(ByVal value As String)
mRating = value
End Set
End Property
''' <summary>
''' A hint for aggregators telling them which hours they can skip. This element contains up to 24 hour sub-elements whose value is a number between 0 and 23, representing a time in GMT, when aggregators, if they support the feature, may not read the channel on hours listed in the SkipHours element. The hour beginning at midnight is hour zero.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Skiphours() As Integer()
Get
Return mSkiphours
End Get
Set(ByVal value As Integer())
mSkiphours = value
End Set
End Property
''' <summary>
''' A hint for aggregators telling them which days they can skip. This element contains up to seven day sub-elements whose value is Monday, Tuesday, Wednesday, Thursday, Friday, Saturday or Sunday. Aggregators may not read the channel during days listed in the SkipDays element.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Skipdays() As DayOfWeek()
Get
Return mSkipdays
End Get
Set(ByVal value As DayOfWeek())
mSkipdays = value
End Set
End Property
''' <summary>
''' Specifies a text input box that can be displayed with the channel. The purpose of the TextInput element is something of a mystery. You can use it to specify a search engine box. Or to allow a reader to provide feedback. Most aggregators ignore it.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property TextInput() As TextInputBox
Get
Return mInputBox
End Get
Set(ByVal value As TextInputBox)
mInputBox = value
End Set
End Property
''' <summary>
''' The name of the channel. It's how people refer to your service. If you have an HTML website that contains the same information as your RSS file, the title of your channel should be the same as the title of your website.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Title() As String
Get
Return mTitle
End Get
Set(ByVal value As String)
mTitle = value
End Set
End Property
''' <summary>
''' ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Ttl() As Integer
Get
Return mTtl
End Get
Set(ByVal value As Integer)
mTtl = value
End Set
End Property
''' <summary>
''' Email address for person responsible for technical issues relating to channel.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Webmaster() As Mail.MailAddress
Get
Return mWebmaster
End Get
Set(ByVal value As Mail.MailAddress)
mWebmaster = value
End Set
End Property
Public Sub New()
Me.Clear()
End Sub
Public Sub Clear()
Me.Description = String.Empty
Me.Title = String.Empty
Me.Language = Nothing
Me.Documentation = Nothing
Me.PublishDate = #12:00:00 AM#
Me.Copyright = String.Empty
Me.Webmaster = Nothing
Me.LastBuildDate = #12:00:00 AM#
Me.Generator = String.Empty
Me.Rating = String.Empty
Me.ManagingEditor = Nothing
Me.Link = Nothing
Me.Name = String.Empty
Me.Skipdays = New DayOfWeek() {}
Me.Skiphours = New Integer() {}
Me.Items = New List(Of FeedItem)
Me.Image = Nothing
Me.Category = Nothing
End Sub
Public Sub CopyValues(ByVal original As Feed)
With Me
If original.Category IsNot Nothing Then
.Category = New Category
.Category.Domain = original.Category.Domain
.Category.Name = original.Category.Name
Else
.Category = Nothing
End If
.Description = original.Description
.Copyright = original.Copyright
.Documentation = original.Documentation
.Generator = original.Generator
If original.Image IsNot Nothing Then
.Image = New Image
.Image.Description = original.Image.Description
.Image.Height = original.Image.Height
.Image.Link = original.Image.Link
.Image.Title = original.Image.Title
.Image.URL = original.Image.URL
.Image.Width = original.Image.Width
Else
.Image = Nothing
End If
If original.Items IsNot Nothing Then
.Items = New List(Of FeedItem)
For Each item As FeedItem In original.Items
Dim newItem As New FeedItem
newItem.CopyValues(item)
.Items.Add(newItem)
Next
Else
.Items = Nothing
End If
.Language = original.Language
.LastBuildDate = original.LastBuildDate
.Link = original.Link
.ManagingEditor = original.ManagingEditor
.Name = original.Name
.PublishDate = original.PublishDate
.Rating = original.Rating
.Skipdays = mHelper.EnumToArray(original.Skipdays)
.Skiphours = mHelper.EnumToArray(original.Skiphours)
.Title = original.Title
.Ttl = original.Ttl
.Webmaster = original.Webmaster
End With
End Sub
Public Overrides Function ToString() As String
Return mTitle
End Function
End Class
''' <summary>
''' Provides RSS feed image data.
''' </summary>
''' <remarks></remarks>
<Serializable()> _
Public Class Image
Private mTitle, mDescription As String
Private mWidth, mHeight As Integer
Private mURL, mLink As Uri
''' <summary>
''' Gets or sets the URL of a GIF, JPEG or PNG image that represents the channel.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property URL() As Uri
Get
Return mURL
End Get
Set(ByVal value As Uri)
mURL = value
End Set
End Property
''' <summary>
''' Gets or sets the URL of the site, when the channel is rendered, the image is a link to the site.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks>In practice the image TITLE and LINK should have the same value as the channel's TITLE and LINK.</remarks>
Public Property Link() As Uri
Get
Return mLink
End Get
Set(ByVal value As Uri)
mLink = value
End Set
End Property
''' <summary>
'''
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Title() As String
Get
Return mTitle
End Get
Set(ByVal value As String)
mTitle = value
End Set
End Property
''' <summary>
''' Gets or sets the text that is included in the TITLE attribute of the link formed around the image in the HTML rendering.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Description() As String
Get
Return mDescription
End Get
Set(ByVal value As String)
mDescription = value
End Set
End Property
''' <summary>
''' Gets or sets the width of the image in pixels.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks>Maximum value is 144, default value is 88.</remarks>
Public Property Width() As Integer
Get
Return mWidth
End Get
Set(ByVal value As Integer)
mWidth = value
End Set
End Property
''' <summary>
''' Gets or sets the height of the image in pixels.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks>Maximum value is 400, default value is 31.</remarks>
Public Property Height() As Integer
Get
Return mHeight
End Get
Set(ByVal value As Integer)
mHeight = value
End Set
End Property
End Class
''' <summary>
''' It's purpose is to allow processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.
''' </summary>
''' <remarks></remarks>
<Serializable()> _
Public Class Cloud
Private mPath, mRegisterProcedure, mProtocol As String
Private mPort As Integer
Private mDomain As Uri
Public Property Domain() As Uri
Get
Return mDomain
End Get
Set(ByVal value As Uri)
mDomain = value
End Set
End Property
Public Property Path() As String
Get
Return mPath
End Get
Set(ByVal value As String)
mPath = value
End Set
End Property
Public Property RegisterProcedure() As String
Get
Return mRegisterProcedure
End Get
Set(ByVal value As String)
mRegisterProcedure = value
End Set
End Property
Public Property Protocol() As String
Get
Return mProtocol
End Get
Set(ByVal value As String)
mProtocol = value
End Set
End Property
Public Property Port() As Integer
Get
Return mPort
End Get
Set(ByVal value As Integer)
mPort = value
End Set
End Property
End Class
''' <summary>
''' Represents a text input box for doing something.
''' </summary>
''' <remarks>The purpose of the TextInputBox element is something of a mystery. You can use it to specify a search engine box. Or to allow a reader to provide feedback. Most aggregators ignore it.</remarks>
<Serializable()> _
Public Class TextInputBox
Private mTitle, mDescription, mName As String
Private mLink As Uri
''' <summary>
''' The label of the Submit button in the text input area.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Title() As String
Get
Return mTitle
End Get
Set(ByVal value As String)
mTitle = value
End Set
End Property
''' <summary>
''' Explains the text input area.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Description() As String
Get
Return mDescription
End Get
Set(ByVal value As String)
mDescription = value
End Set
End Property
''' <summary>
''' The name of the text object in the text input area.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Name() As String
Get
Return mName
End Get
Set(ByVal value As String)
mName = value
End Set
End Property
''' <summary>
''' The URL of the CGI script that processes text input requests.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Link() As Uri
Get
Return mLink
End Get
Set(ByVal value As Uri)
mLink = value
End Set
End Property
End Class
End Namespace