Files
ServiceDashBored/Endpoint/OracleEndpointConfiguration.cs
T
2025-10-11 09:44:08 -04:00

156 lines
5.3 KiB
C#

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