ConfigurationDocAttribute
using System;
namespace Relativity.Transfer
{
[AttributeUsage(AttributeTargets.Property)]
public sealed class ConfigurationDocAttribute : Attribute
{
public string Choices { get; }
public object DefaultValue { get; }
public string Description { get; }
public string Key { get; }
public ConfigurationDocAttribute(string key, string description)
: this(key, description, null, string.Empty)
{
}
public ConfigurationDocAttribute(string key, string description, object defaultValue)
: this(key, description, defaultValue, string.Empty)
{
}
public ConfigurationDocAttribute(string key, string description, object defaultValue, string choices)
{
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException("key");
if (string.IsNullOrEmpty(description))
throw new ArgumentNullException("description");
Choices = choices;
DefaultValue = (defaultValue?.ToString() ?? string.Empty);
Description = description;
Key = key;
}
public ConfigurationDocAttribute(string key, string description, object defaultValue, Type choices)
{
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException("key");
if (string.IsNullOrEmpty(description))
throw new ArgumentNullException("description");
if (choices != (Type)null && choices.IsEnum)
Choices = string.Join("|", Enum.GetNames(choices));
DefaultValue = (defaultValue?.ToString() ?? string.Empty);
Description = description;
Key = key;
}
}
}