using System;
using System.Configuration;
namespace Endpoint
{
///
/// Defines a configuration for an oracle service endpoint
///
public class OracleEndpointConfiguration : ConfigurationElement, IServiceEndpointConfiguration
{
///
/// Gets or sets the name.
///
/// The name.
[ConfigurationProperty("name", DefaultValue = "", IsKey = true, IsRequired = true)]
public string Name
{
get { return (string)base["name"]; }
set { base["name"] = value; }
}
///
/// Gets or sets the connection string.
///
/// The connection string.
[ConfigurationProperty("connectionString", DefaultValue = "", IsKey = false, IsRequired = true)]
public string ConnectionString
{
get { return (string)base["connectionString"]; }
set { base["connectionString"] = value; }
}
///
/// Gets or sets the connection string.
///
/// The connection string.
[ConfigurationProperty("scalarQueryString", DefaultValue = "", IsKey = false, IsRequired = true)]
public string ScalarQueryString
{
get { return (string)base["scalarQueryString"]; }
set { base["scalarQueryString"] = value; }
}
///
/// Gets or sets the connection string.
///
/// The connection string.
[ConfigurationProperty("expectedQueryResult", DefaultValue = "", IsKey = false, IsRequired = true)]
public string ExpectedQueryResult
{
get { return (string)base["expectedQueryResult"]; }
set { base["expectedQueryResult"] = value; }
}
///
/// Initializes a new instance of the class.
///
internal protected OracleEndpointConfiguration()
{}
///
/// Initializes a new instance of the class.
///
/// Name of the service.
/// The connection string.
/// The scalar query string.
/// The expected query result.
public OracleEndpointConfiguration(string serviceName, string connectionString, string scalarQueryString, string expectedQueryResult)
{
if (serviceName == null)
throw new ArgumentNullException("serviceName");
if (connectionString == null)
throw new ArgumentNullException("connectionString");
if (scalarQueryString == null)
throw new ArgumentNullException("scalarQueryString");
if (expectedQueryResult == null)
throw new ArgumentNullException("expectedQueryResult");
ConnectionString = connectionString;
ScalarQueryString = scalarQueryString;
ExpectedQueryResult = expectedQueryResult;
}
///
/// Determines whether the specified is equal to the current .
///
/// The to compare with the current .
///
/// true if the specified is equal to the current ; otherwise, false.
///
/// The parameter is null.
public override bool Equals(object obj)
{
OracleEndpointConfiguration value = obj as OracleEndpointConfiguration;
if (value == null)
return false;
if (value.ConnectionString != ConnectionString || value.ScalarQueryString != ScalarQueryString)
return false;
return true;
}
///
/// Serves as a hash function for a OracleEndpointConfiguration.
///
///
/// A hash code for the current .
///
public override int GetHashCode()
{
return ConnectionString.GetHashCode() ^ ScalarQueryString.GetHashCode();
}
}
///
///
///
public class OracleEndpointConfigurationCollection : ConfigurationElementCollection
{
///
/// When overridden in a derived class, creates a new .
///
///
/// A new .
///
protected override ConfigurationElement CreateNewElement()
{
return new OracleEndpointConfiguration();
}
///
/// Gets the element key for a specified configuration element when overridden in a derived class.
///
///
/// An that acts as the key for the specified .
///
/// The to return the key for.
protected override object GetElementKey(ConfigurationElement element)
{
return ((OracleEndpointConfiguration)element).Name;
}
}
///
///
///
public class OracleEndpointConfigurationSection : ConfigurationSection
{
///
/// Gets the endpoints.
///
/// The endpoints.
[ConfigurationProperty("endpoints")]
public OracleEndpointConfigurationCollection Endpoints { get { return (OracleEndpointConfigurationCollection)(base["endpoints"]); } }
}
}