|
' ******************************************************************************
' **
' ** 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 Finance.Support
''' <summary>
''' Stores informations about base and dependency currency. Implements IID.
''' </summary>
''' <remarks></remarks>
Public Class YCurrencyID
Implements IID
Private mBaseCurrency, mDepCurrency As Currency
Private mBaseName As String = String.Empty
Private mDepName As String = String.Empty
Friend mFinanceHelper As New FinanceHelper
''' <summary>
'''The Yahoo ID of the relation
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public ReadOnly Property ID() As String Implements IID.ID
Get
Return String.Format("{0}{1}=X", mBaseCurrency.ToString, mDepCurrency.ToString)
End Get
End Property
''' <summary>
''' The currency with the ratio value of 1
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property BaseCurrency() As Currency
Get
Return mBaseCurrency
End Get
Set(ByVal value As Currency)
mBaseCurrency = value
mBaseName = WorldMarket.DefaultCurrencies(value).Description
End Set
End Property
''' <summary>
''' The currency of the dependent value
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property DepCurrency() As Currency
Get
Return mDepCurrency
End Get
Set(ByVal value As Currency)
mDepCurrency = value
mDepName = WorldMarket.DefaultCurrencies(value).Description
End Set
End Property
''' <summary>
''' The full name of the base currency
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public ReadOnly Property BaseName() As String
Get
Return mBaseName
End Get
End Property
''' <summary>
''' The full name of the dependent currency
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public ReadOnly Property DepName() As String
Get
Return mDepName
End Get
End Property
''' <summary>
''' The display name of the relation
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public ReadOnly Property DisplayName() As String
Get
Return String.Format("{0} to {1}", mBaseName, mDepName)
End Get
End Property
''' <summary>
''' Default constructor
''' </summary>
''' <remarks></remarks>
Public Sub New()
mBaseCurrency = Currency.AED
mDepCurrency = Currency.AED
mBaseName = String.Empty
mDepName = String.Empty
End Sub
''' <summary>
''' Overloaded constructor
''' </summary>
''' <param name="baseCur"></param>
''' <param name="depCur"></param>
''' <remarks></remarks>
Public Sub New(ByVal baseCur As Currency, ByVal depCur As Currency)
Me.BaseCurrency = baseCur
Me.DepCurrency = depCur
End Sub
''' <summary>
''' Overloaded constructor
''' </summary>
''' <param name="id"></param>
''' <remarks></remarks>
Public Sub New(ByVal id As String)
Dim newRel As YCurrencyID = mFinanceHelper.YCurrencyIDFromString(id)
If newRel IsNot Nothing Then
Me.BaseCurrency = newRel.BaseCurrency
Me.DepCurrency = newRel.DepCurrency
Else : Throw New ArgumentException("The id is not valid", "id")
End If
End Sub
''' <summary>
''' Returns the ID of the currency relation
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Public Overrides Function ToString() As String
Return Me.ID
End Function
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.