Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Yahoo! Managed

, 1 May 2012
Download financial data, managing online portfolio or using Search BOSS from Yahoo! with .NET
Documentation_0.11.2.0.zip
market.xml.zip
market_xml.zip
Release_0.11.2.0.zip
Desktop
AnyCPU
x64
x86
Silverlight
WP7
MaasOne7.dll
MaasOne7.Yahoo.dll
MaasOne7.Microsoft.dll
MaasOneSL.dll
MaasOneSL.Yahoo.dll
System.Xml.Linq.dll
MaasOneSL.Microsoft.dll
MaasOne.dll
MaasOne.Yahoo.dll
MaasOne.Microsoft.dll
MaasOne.dll
MaasOne.Yahoo.dll
MaasOne.Microsoft.dll
MaasOne.Microsoft.dll
MaasOne.dll
MaasOne.Yahoo.dll
Release_0.7.5.zip
x64
YahooManaged.Finance.dll
x86
YahooManaged.Finance.dll
CF
YahooManagedCF.Finance.dll
Release_0.7.6.zip
YahooManaged.Finance.dll
YahooManaged.Finance.dll
YahooManagedCF.Finance.dll
Release_0.7.7.zip
Mobile
CF20
YahooManagedCF20.Finance.dll
CF35
YahooManagedCF35.Finance.dll
YahooManaged.Finance.dll
YahooManaged.Finance.dll
Release_0.7.zip
YahooManaged.Finance.dll
YahooManaged.Finance.dll
Release_0.7_x86.zip
Source_Code_0.11.2.0.zip
MaasOne
Base
bin
Class Diagrams
IDownload.cd
Finance
Indicators
Geo
MaasOne.csproj.user
obj
Properties
RSS
ImportExport
Search
Xml
MaasOne.Yahoo
Base
bin
Class Diagrams
QuotesDownload.cd
WorldMarket.cd
Finance
YahooFinance
Support
YahooPortfolio
YahooScreener
Criterias
Geo
GeoPlanet
PlaceFinder
localization.csv
MaasOne.Yahoo.csproj.user
obj
Properties
Search
BOSS
Weather
YahooWeather
Source_Code_0.7.5.zip
YahooManaged.Finance
Base
bin
Finance
API
ImportExport
NonAPI
Support
My Project
Application.myapp
Settings.settings
RSS
ImportExport
YahooManaged.Finance.vbproj.user
Source_Code_0.7.6.zip
Application.myapp
Settings.settings
YahooManaged.Finance.vbproj.user
Source_Code_0.7.7.zip
Application.myapp
Settings.settings
YahooManaged.Finance.vbproj.user
Source_Code_0.7.zip
Application.myapp
Settings.settings
YahooManaged.Finance.vbproj.user
Yahoo_Managed_Showcase.zip
Yahoo Managed Showcase
BaseControls.dll
MaasOne.dll
MaasOne.Yahoo.dll
Visiblox.Charts.dll
WPFToolkit.dll
YahooManaged_TestApp_WPF.exe
YahooManaged_TestApp_WPF_Controls.dll
' ******************************************************************************
' ** 
' **  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.
' ** 
' ******************************************************************************
Imports System.ComponentModel
Imports System.Reflection


Namespace RSS

    ''' <summary>
    ''' Serializable. Class for storing data of a rss feed item
    ''' </summary>
    ''' <remarks></remarks>
    <Serializable()> _
    Public Class FeedItem
        Private mTitle, mLink, mDescription, mAuthor As String
        Private mComments As Uri
        Private mCategory As Category
        Private mEnclosure As Enclosure
        Private mSource As Source
        Private mInsertDate, mPubDate As Date
        Private mGuid As GUID

        ''' <summary>
        ''' The title of the item.
        ''' </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>
        ''' The URL of the item.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Link() As String
            Get
                Return mLink
            End Get
            Set(ByVal value As String)
                mLink = value
            End Set
        End Property
        ''' <summary>
        ''' The item synopsis.
        ''' </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>
        ''' Email address of the author of the item.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Author() As String
            Get
                Return mAuthor
            End Get
            Set(ByVal value As String)
                mAuthor = value
            End Set
        End Property
        ''' <summary>
        ''' Includes the item in one or more categories.
        ''' </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>
        ''' URL of a page for comments relating to the item.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Comments() As Uri
            Get
                Return mComments
            End Get
            Set(ByVal value As Uri)
                mComments = value
            End Set
        End Property
        ''' <summary>
        ''' Describes a media object that is attached to the item.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Enclosure() As Enclosure
            Get
                Return mEnclosure
            End Get
            Set(ByVal value As Enclosure)
                mEnclosure = value
            End Set
        End Property
        ''' <summary>
        ''' A string that uniquely identifies the item.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property GUID() As GUID
            Get
                Return mGuid
            End Get
            Set(ByVal value As GUID)
                mGuid = value
            End Set
        End Property
        Public Property InsertDate() As Date
            Get
                Return mInsertDate
            End Get
            Set(ByVal value As Date)
                mInsertDate = value
            End Set
        End Property
        ''' <summary>
        ''' Indicates when the item was published.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property PubDate() As Date
            Get
                Return mPubDate
            End Get
            Set(ByVal value As Date)
                mPubDate = value
            End Set
        End Property
        ''' <summary>
        ''' The RSS channel that the item came from.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Source() As Source
            Get
                Return mSource
            End Get
            Set(ByVal value As Source)
                mSource = value
            End Set
        End Property

        Public Sub New()
            Me.Clear()
        End Sub

        Public Overridable Sub Clear()
            mTitle = String.Empty
            mLink = String.Empty
            mDescription = String.Empty
            mInsertDate = #12:00:00 AM#
            mPubDate = #12:00:00 AM#
            mAuthor = String.Empty
            mComments = Nothing
            mGuid = Nothing
            mCategory = Nothing
            mEnclosure = Nothing
            mSource = Nothing
        End Sub
        Public Overridable Sub CopyValues(ByVal n As FeedItem)
            With Me
                .Author = n.Author
                If n.Category IsNot Nothing Then
                    .Category = New Category
                    .Category.Domain = n.Category.Domain
                    .Category.Name = n.Category.Name
                Else
                    .Category = Nothing
                End If
                .Comments = n.Comments
                .Description = n.Description
                If n.Enclosure IsNot Nothing Then
                    .Enclosure = New Enclosure
                    .Enclosure.Length = n.Enclosure.Length
                    .Enclosure.Type = n.Enclosure.Type
                    .Enclosure.Url = n.Enclosure.Url
                Else
                    .Enclosure = Nothing
                End If
                .GUID = n.GUID
                .InsertDate = n.InsertDate
                .Link = n.Link
                .PubDate = n.PubDate
                .Source = n.Source
                .Title = n.Title
            End With
        End Sub

        Public Overrides Function ToString() As String
            Return mTitle
        End Function
    End Class

     ''' <summary>
    ''' Serializable. Class for storing the unique id of a feed item.
    ''' </summary>
    ''' <remarks></remarks>
    <Serializable()> _
    Public Class GUID
        Private mID As String
        Private mIsPermaLink As Boolean
        Public Property ID() As String
            Get
                Return mID
            End Get
            Set(ByVal value As String)
                mID = value
            End Set
        End Property
        Public Property IsPermaLink() As Boolean
            Get
                Return mIsPermaLink
            End Get
            Set(ByVal value As Boolean)
                mIsPermaLink = value
            End Set
        End Property
        Public Sub New()
            mID = String.Empty
            mIsPermaLink = True
        End Sub
        Public Overrides Function ToString() As String
            Return mID
        End Function
    End Class


    ''' <summary>
    ''' Serializable class for storing rss item enclosure data
    ''' </summary>
    ''' <remarks></remarks>
    <Serializable()> _
    Public Class Enclosure
        Private mType As String
        Private mURL As Uri
        Private mLength As Long
        Public Property Type() As String
            Get
                Return mType
            End Get
            Set(ByVal value As String)
                mType = value
            End Set
        End Property
        Public Property Url() As Uri
            Get
                Return mURL
            End Get
            Set(ByVal value As Uri)
                mURL = value
            End Set
        End Property
        Public Property Length() As Long
            Get
                Return mLength
            End Get
            Set(ByVal value As Long)
                mLength = value
            End Set
        End Property
        Public Sub New()
            mURL = Nothing
            mType = String.Empty
            mLength = 0
        End Sub
        Public Overrides Function ToString() As String
            Return mType
        End Function
    End Class

    ''' <summary>
    ''' Serializable. Class for storing rss item source data
    ''' </summary>
    ''' <remarks></remarks>
    <Serializable()> _
    Public Class Source
        Private mTitle As String
        Private mURL As Uri
        Public Property Title() As String
            Get
                Return mTitle
            End Get
            Set(ByVal value As String)
                mTitle = value
            End Set
        End Property
        Public Property Url() As Uri
            Get
                Return mURL
            End Get
            Set(ByVal value As Uri)
                mURL = value
            End Set
        End Property
        Public Sub New()
            mURL = Nothing
            mTitle = String.Empty
        End Sub
        Public Overrides Function ToString() As String
            Return mTitle
        End Function
    End Class

    ''' <summary>
    ''' Serializable. Class for storing rss category data
    ''' </summary>
    ''' <remarks></remarks>
    <Serializable()> _
     Public Class Category
        Private mName As String
        Private mDomain As Uri
        Public Property Name() As String
            Get
                Return mName
            End Get
            Set(ByVal value As String)
                mName = value
            End Set
        End Property
        Public Property Domain() As Uri
            Get
                Return mDomain
            End Get
            Set(ByVal value As Uri)
                mDomain = value
            End Set
        End Property
        Public Sub New()
            mName = String.Empty
            mDomain = Nothing
        End Sub
        Public Overrides Function ToString() As String
            Return mName
        End Function
    End Class

    Public Class FeedItemComparer
        Implements IComparer
        Private WithEvents mSortDescriptions As New List(Of SortDescription)
        Public ReadOnly Property SortDescriptions() As List(Of SortDescription)
            Get
                Return mSortDescriptions
            End Get
        End Property
        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
            If (x IsNot Nothing AndAlso TypeOf x Is FeedItem) AndAlso (y IsNot Nothing AndAlso TypeOf y Is FeedItem) Then
                Dim itemX As FeedItem = DirectCast(x, FeedItem)
                Dim itemY As FeedItem = DirectCast(y, FeedItem)
                If mSortDescriptions.Count > 0 Then
                    For Each desc In mSortDescriptions
                        Dim res As Integer = Me.CompareProp(itemX, itemY, desc)
                        If res <> 0 Then Return res
                    Next
                End If
            End If
            Return 0
        End Function
        Private Function CompareProp(ByVal itemX As FeedItem, ByVal itemY As FeedItem, ByVal desc As SortDescription) As Integer
            Dim res As Integer = 0
            Select Case desc.PropertyName
                Case "Author" : res = Me.CompareStrings(itemX.Author, itemY.Author)
                Case "Category" : If Me.ItemsNotNothing(itemX.Category, itemY.Category) Then res = Me.CompareStrings(itemX.Category.Name, itemY.Category.Name)
                Case "Category.Name" : If Me.ItemsNotNothing(itemX.Category, itemY.Category) Then res = Me.CompareStrings(itemX.Category.Name, itemY.Category.Name)
                Case "Category.Domain" : If Me.ItemsNotNothing(itemX.Category, itemY.Category) Then res = Me.CompareStrings(itemX.Category.Domain.ToString, itemY.Category.Domain.ToString)
                Case "Comments" : res = Me.CompareStrings(itemX.Comments.ToString, itemY.Comments.ToString)
                Case "Description" : res = Me.CompareStrings(itemX.Description, itemY.Description)
                Case "Enclosure" : If Me.ItemsNotNothing(itemX.Enclosure, itemY.Enclosure) Then res = Me.CompareStrings(itemX.Enclosure.Type, itemY.Enclosure.Type)
                Case "Enclosure.Type" : If Me.ItemsNotNothing(itemX.Enclosure, itemY.Enclosure) Then res = Me.CompareStrings(itemX.Enclosure.Type, itemY.Enclosure.Type)
                Case "Enclosure.Url" : If Me.ItemsNotNothing(itemX.Enclosure, itemY.Enclosure) Then res = Me.CompareStrings(itemX.Enclosure.Url.ToString, itemY.Enclosure.Url.ToString)
                Case "Enclosure.Length" : If Me.ItemsNotNothing(itemX.Enclosure, itemY.Enclosure) Then res = Me.CompareDigits(itemX.Enclosure.Length, itemY.Enclosure.Length)
                Case "GUID" : res = Me.CompareStrings(itemX.GUID.ID, itemY.GUID.ID)
                Case "GUID.ID" : res = Me.CompareStrings(itemX.GUID.ID, itemY.GUID.ID)
                Case "GUID.IsPermaLink" : res = Me.CompareBools(itemX.GUID.IsPermaLink, itemY.GUID.IsPermaLink)
                Case "InsertDate" : res = Me.CompareDates(itemX.InsertDate, itemY.InsertDate)
                Case "Link" : res = Me.CompareStrings(itemX.Link, itemY.Link)
                Case "PubDate" : res = Me.CompareDates(itemX.PubDate, itemY.PubDate)
                Case "Source" : If Me.ItemsNotNothing(itemX.Source, itemY.Source) Then res = Me.CompareStrings(itemX.Source.Title, itemY.Source.Title)
                Case "Source.Name" : If Me.ItemsNotNothing(itemX.Source, itemY.Source) Then res = Me.CompareStrings(itemX.Source.Title, itemY.Source.Title)
                Case "Source.Url" : If Me.ItemsNotNothing(itemX.Source, itemY.Source) Then res = Me.CompareStrings(itemX.Source.Url.ToString, itemY.Source.Url.ToString)
                Case "Title" : res = Me.CompareStrings(itemX.Title, itemY.Title)
            End Select
            If desc.Direction = ListSortDirection.Descending Then res *= -1
            Return res
        End Function
        Private Function CompareDigits(ByVal digX As Double, ByVal digY As Double) As Integer
            If digX > digY Then : Return 1
            ElseIf digX < digY Then : Return -1
            Else : Return 0
            End If
        End Function
        Private Function CompareDates(ByVal dateX As Date, ByVal dateY As Date) As Integer
            If dateX > dateY Then : Return 1
            ElseIf dateX < dateY Then : Return -1
            Else : Return 0
            End If
        End Function
        Private Function CompareStrings(ByVal stringX As String, ByVal stringY As String) As Integer
            Return String.Compare(stringX, stringY)
        End Function
        Private Function CompareBools(ByVal boolX As Boolean, ByVal boolY As Boolean) As Integer
            If boolX = True And boolY = False Then : Return 1
            ElseIf boolX = False And boolY = True Then : Return -1
            Else : Return 0
            End If
        End Function
        Private Function ItemsNotNothing(ByVal itemX As Object, ByVal itemY As Object) As Boolean
            Return itemX IsNot Nothing And itemY IsNot Nothing
        End Function
    End Class

    Public Class PropertyComparer(Of T)
        Implements IComparer(Of T)
        Private mSortDescriptions As New List(Of PropertySortDescription(Of T))
        Public ReadOnly Property SortDescriptions() As List(Of PropertySortDescription(Of T))
            Get
                Return mSortDescriptions
            End Get
        End Property
        Public Function Compare(ByVal x As T, ByVal y As T) As Integer Implements IComparer(Of T).Compare
            For Each desc In mSortDescriptions
                Dim xValue As Object = desc.Descriptor.GetValue(x)
                Dim yValue As Object = desc.Descriptor.GetValue(y)
                Dim res As Integer = desc.Direction * desc.Comparer.Compare(xValue, yValue)
                If res <> 0 Then Return res
            Next
            Return 0
        End Function
    End Class

    Public Class PropertySortDescription(Of T)
        Private mDescriptor As PropertyDescriptor
        Private mDirection As ListSortDirection
        Private mComparer As IComparer
        Public ReadOnly Property Comparer() As IComparer
            Get
                Return mComparer
            End Get
        End Property
        Public ReadOnly Property Descriptor() As PropertyDescriptor
            Get
                Return mDescriptor
            End Get
        End Property
        Public Property Direction() As ListSortDirection
            Get
                Return mDirection
            End Get
            Set(ByVal value As ListSortDirection)
                mDirection = value
            End Set
        End Property
        Public Sub New(ByVal pd As PropertyDescriptor, ByVal dir As ListSortDirection)
            mDescriptor = pd
            mDirection = dir
            mComparer = DirectCast(GetType(Comparer(Of T)).MakeGenericType(mDescriptor.PropertyType).InvokeMember("Default", BindingFlags.GetProperty Or BindingFlags.[Public] Or BindingFlags.[Static], Nothing, Nothing, Nothing), IComparer)
        End Sub
    End Class

End Namespace

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0

Share

About the Author

MaasOne

Germany Germany
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 2 May 2012
Article Copyright 2009 by MaasOne
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid