using System; using EPiServer.Core; using EPiServer.Framework.DataAnnotations; using EPiServer.PlugIn; namespace AlloyTemplates.Models.Properties { /// /// Property type for storing a list of strings /// /// For an example, see where this property type is used for the MetaKeywords property [EditorHint(Global.SiteUIHints.Strings)] [PropertyDefinitionTypePlugIn(Description = "A property for list of strings", DisplayName = "String List")] public class PropertyStringList : PropertyLongString { protected String Separator = "\n"; public String[] List { get { return (String[])Value; } } public override Type PropertyValueType { get { return typeof(String[]); } } public override object SaveData(PropertyDataCollection properties) { return LongString; } public override object Value { get { var value = base.Value as string; if (value == null) { return null; } return value.Split(Separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); } set { if (value is String[]) { var s = String.Join(Separator, value as String[]); base.Value = s; } else { base.Value = value; } } } } }