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

115 lines
3.3 KiB
C#

using System;
using System.Configuration;
using System.Xml.Serialization;
namespace Endpoint
{
/// <summary>
/// Defines a configuration for an html webpage endpoint
/// </summary>
public class HtmlEndpointConfiguration : ConfigurationElement, IHttpEndpointConfiguration
{
/// <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>
/// URI of the service
/// </summary>
[XmlIgnore]
public Uri Uri
{
get { return new Uri(UriString); }
}
/// <summary>
/// Gets or sets the URI string.
/// </summary>
/// <value>The URI string.</value>
[ConfigurationProperty("uri", DefaultValue = "", IsKey = false, IsRequired = true)]
public string UriString
{
get { return (string)base["uri"]; }
set { base["uri"] = value; }
}
/// <summary>
/// Gets or sets the xpath query for the html document
/// </summary>
/// <value>The xpath query.</value>
[ConfigurationProperty("xpathQuery", DefaultValue = "", IsKey = false, IsRequired = true)]
public string XpathQuery
{
get { return (string)base["xpathQuery"]; }
set { base["xpathQuery"] = value; }
}
/// <summary>
/// Gets or sets the expected query results.
/// </summary>
/// <value>The expected query results.</value>
[ConfigurationProperty("expectedXpathResult", DefaultValue = "", IsKey = false, IsRequired = true)]
public string ExpectedXpathResult
{
get { return (string)base["expectedXpathResult"]; }
set { base["expectedXpathResult"] = value; }
}
/// <summary>
/// Gets or sets the post.
/// </summary>
/// <value>The post.</value>
[ConfigurationProperty("requestContent", DefaultValue = "", IsKey = false, IsRequired = false)]
public string RequestContent
{
get { return (string)base["requestContent"]; }
set { base["requestContent"] = value; }
}
}
/// <summary>
///
/// </summary>
public class HtmlEndpointConfigurationCollection : 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 HtmlEndpointConfiguration();
}
/// <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 ((HtmlEndpointConfiguration)element).Name;
}
}
/// <summary>
///
/// </summary>
public class HtmlEndpointConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("endpoints")]
public HtmlEndpointConfigurationCollection Endpoints { get { return (HtmlEndpointConfigurationCollection)(base["endpoints"]); } }
}
}