83 lines
2.3 KiB
C#
83 lines
2.3 KiB
C#
using System;
|
|
using System.Text;
|
|
using System.Configuration;
|
|
using System.Collections.Generic;
|
|
using MarketData.Utils;
|
|
|
|
namespace MarketData.DataAccess
|
|
{
|
|
[Serializable]
|
|
public sealed class DataSourceEx
|
|
{
|
|
private string key;
|
|
private string database;
|
|
private string datasource;
|
|
private string username;
|
|
private string password;
|
|
private string port;
|
|
public DataSourceEx()
|
|
{
|
|
}
|
|
public DataSourceEx(String configurationKey)
|
|
{
|
|
Dictionary<String, String> dictionary = CreateConfigurationSettings(configurationKey);
|
|
Database = dictionary["Database"];
|
|
Datasource = dictionary["Datasource"];
|
|
Username = dictionary["Username"];
|
|
Password = dictionary["Password"];
|
|
}
|
|
private static Dictionary<String, String> CreateConfigurationSettings(String configurationKey)
|
|
{
|
|
String marketData = ConfigurationManager.AppSettings[configurationKey];
|
|
String[] elements = marketData.Split(';');
|
|
Dictionary<String, String> dictionary = new Dictionary<string, string>();
|
|
foreach (String element in elements)
|
|
{
|
|
String[] valuePairs = element.Split('=');
|
|
dictionary.Add(valuePairs[0], valuePairs[1]);
|
|
}
|
|
return dictionary;
|
|
}
|
|
public string Key
|
|
{
|
|
get { return key; }
|
|
set { key = value; }
|
|
}
|
|
public string Database
|
|
{
|
|
get { return database; }
|
|
set { database = value; }
|
|
}
|
|
public string Datasource
|
|
{
|
|
get { return datasource; }
|
|
set { datasource = value; }
|
|
}
|
|
public string Port
|
|
{
|
|
get { return port; }
|
|
set { port = value; }
|
|
}
|
|
public string Password
|
|
{
|
|
get { return password; }
|
|
set { password = value; }
|
|
}
|
|
public string Username
|
|
{
|
|
get { return username; }
|
|
set { username = value; }
|
|
}
|
|
public override String ToString()
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("Key='").Append(key).Append("', ");
|
|
sb.Append("Database='").Append(database).Append("', ");
|
|
sb.Append("DataSource='").Append(datasource).Append("', ");
|
|
sb.Append("Port='").Append(port).Append("', ");
|
|
sb.Append("UserName='").Append(username).Append("', ");
|
|
sb.Append("Password='").Append(Utility.AsteriskForString(password)).Append("'");
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
} |