105 lines
2.1 KiB
C#
105 lines
2.1 KiB
C#
using System;
|
|
using System.Configuration;
|
|
using AspClassic.Scripting.Runtime;
|
|
|
|
namespace AspClassic.Scripting.Hosting.Configuration;
|
|
|
|
public class OptionElement : ConfigurationElement
|
|
{
|
|
internal sealed class Key : IEquatable<Key>
|
|
{
|
|
private readonly string _option;
|
|
|
|
private readonly string _language;
|
|
|
|
public string Option => _option;
|
|
|
|
public string Language => _language;
|
|
|
|
public Key(string option, string language)
|
|
{
|
|
_option = option;
|
|
_language = language;
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
return Equals(obj as Key);
|
|
}
|
|
|
|
public bool Equals(Key other)
|
|
{
|
|
if (other != null && DlrConfiguration.OptionNameComparer.Equals(_option, other._option))
|
|
{
|
|
return DlrConfiguration.LanguageNameComparer.Equals(_language, other._language);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return _option.GetHashCode() ^ (_language ?? string.Empty).GetHashCode();
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return (string.IsNullOrEmpty(_language) ? string.Empty : (_language + ":")) + _option;
|
|
}
|
|
}
|
|
|
|
private const string _Option = "option";
|
|
|
|
private const string _Value = "value";
|
|
|
|
private const string _Language = "language";
|
|
|
|
private static ConfigurationPropertyCollection _Properties = new ConfigurationPropertyCollection
|
|
{
|
|
new ConfigurationProperty("option", typeof(string), string.Empty, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey),
|
|
new ConfigurationProperty("value", typeof(string), string.Empty, ConfigurationPropertyOptions.IsRequired),
|
|
new ConfigurationProperty("language", typeof(string), string.Empty, ConfigurationPropertyOptions.IsKey)
|
|
};
|
|
|
|
protected override ConfigurationPropertyCollection Properties => _Properties;
|
|
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
return (string)base["option"];
|
|
}
|
|
set
|
|
{
|
|
base["option"] = value;
|
|
}
|
|
}
|
|
|
|
public string Value
|
|
{
|
|
get
|
|
{
|
|
return (string)base["value"];
|
|
}
|
|
set
|
|
{
|
|
base["value"] = value;
|
|
}
|
|
}
|
|
|
|
public string Language
|
|
{
|
|
get
|
|
{
|
|
return (string)base["language"];
|
|
}
|
|
set
|
|
{
|
|
base["language"] = value;
|
|
}
|
|
}
|
|
|
|
internal object GetKey()
|
|
{
|
|
return new Key(Name, Language);
|
|
}
|
|
}
|