93 lines
1.6 KiB
C#
93 lines
1.6 KiB
C#
using System;
|
|
using System.Configuration;
|
|
using AspClassic.Scripting.Utils;
|
|
|
|
namespace AspClassic.Scripting.Hosting.Configuration;
|
|
|
|
public class LanguageElement : ConfigurationElement
|
|
{
|
|
private const string _Names = "names";
|
|
|
|
private const string _Extensions = "extensions";
|
|
|
|
private const string _Type = "type";
|
|
|
|
private const string _DisplayName = "displayName";
|
|
|
|
private static ConfigurationPropertyCollection _Properties = new ConfigurationPropertyCollection
|
|
{
|
|
new ConfigurationProperty("names", typeof(string), null),
|
|
new ConfigurationProperty("extensions", typeof(string), null),
|
|
new ConfigurationProperty("type", typeof(string), null, ConfigurationPropertyOptions.IsRequired),
|
|
new ConfigurationProperty("displayName", typeof(string), null)
|
|
};
|
|
|
|
protected override ConfigurationPropertyCollection Properties => _Properties;
|
|
|
|
public string Names
|
|
{
|
|
get
|
|
{
|
|
return (string)base["names"];
|
|
}
|
|
set
|
|
{
|
|
base["names"] = value;
|
|
}
|
|
}
|
|
|
|
public string Extensions
|
|
{
|
|
get
|
|
{
|
|
return (string)base["extensions"];
|
|
}
|
|
set
|
|
{
|
|
base["extensions"] = value;
|
|
}
|
|
}
|
|
|
|
public string Type
|
|
{
|
|
get
|
|
{
|
|
return (string)base["type"];
|
|
}
|
|
set
|
|
{
|
|
base["type"] = value;
|
|
}
|
|
}
|
|
|
|
public string DisplayName
|
|
{
|
|
get
|
|
{
|
|
return (string)base["displayName"];
|
|
}
|
|
set
|
|
{
|
|
base["displayName"] = value;
|
|
}
|
|
}
|
|
|
|
public string[] GetNamesArray()
|
|
{
|
|
return Split(Names);
|
|
}
|
|
|
|
public string[] GetExtensionsArray()
|
|
{
|
|
return Split(Extensions);
|
|
}
|
|
|
|
private static string[] Split(string str)
|
|
{
|
|
if (str == null)
|
|
{
|
|
return ArrayUtils.EmptyStrings;
|
|
}
|
|
return str.Split(new char[2] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
|
}
|
|
}
|