|
using System;
using System.Configuration;
using System.Configuration.Provider;
namespace Cli.Lsp.Provider.CurrencyProvider {
public class WSCurrencyConversion : CurrencyProviderBase {
private String url;
public String URL {
get { return url; }
set { url = value; }
}
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) {
#region Attributes check
if ((config == null) || (config.Count == 0))
throw new ArgumentNullException("You must supply a valid configuration parameters.");
this._name = name;
#endregion
#region Description
if (string.IsNullOrEmpty(config["description"])) {
throw new ProviderException("You must specify a description attribute.");
}
this._description = config["description"];
config.Remove("description");
#endregion
#region URL
if (String.IsNullOrEmpty(config["url"]))
throw new ProviderException("The url is invalid.");
this.url = config["url"];
config.Remove("url");
#endregion
#region Extra Attributes validations
if (config.Count > 0) {
string extraAttribute = config.GetKey(0);
if (!String.IsNullOrEmpty(extraAttribute))
throw new ProviderException("The following unrecognized attribute was found in " + Name + "'s configuration: '" +
extraAttribute + "'");
else
throw new ProviderException("An unrecognized attribute was found in the provider's configuration.");
}
#endregion
}
public override decimal Convert(Currency cur, decimal value) {
Console.WriteLine("---- Convert method was Invoked SQL Currency conversion ----");
Console.WriteLine("Provider Description ={0}", this.Description);
Console.WriteLine("URL ={0}", this.URL);
Console.WriteLine("Convert({0},{1}) ", Enum.GetName(typeof(Currency), cur), value);
Console.ReadLine();
return 3.4m;
}
public override void Add(Currency cur, DateTime date, decimal factor) {
Console.WriteLine("---- Add method was Invoked SQL Currency conversion ----");
Console.WriteLine("Provider Description ={0}", this.Description);
Console.WriteLine("URL ={0}", this.URL);
Console.WriteLine("Add({0},{1},{2}) ", Enum.GetName(typeof(Currency), cur), date, factor);
Console.ReadLine();
}
public override void Remove(Currency cur, DateTime date) {
Console.WriteLine("---- Remove method was Invoked SQL Currency conversion ----");
Console.WriteLine("Provider Description ={0}", this.Description);
Console.WriteLine("URL ={0}", this.URL);
Console.WriteLine("Remove({0},{1}) ", Enum.GetName(typeof(Currency), cur), date);
Console.ReadLine();
}
public override CurrencyConversionItem[] List(Currency cur, DateTime startDate, DateTime endDate) {
Console.WriteLine("---- List method was Invoked SQL Currency conversion ----");
Console.WriteLine("Provider Description ={0}", this.Description);
Console.WriteLine("URL ={0}", this.URL);
Console.WriteLine("List({0},{1},{2}) ", Enum.GetName(typeof(Currency), cur), startDate, endDate);
Console.ReadLine();
return new CurrencyConversionItem[0];
}
}
}
|
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.