2018-02-16 12:00:45 +01:00
|
|
|
|
using System.Linq;
|
2017-05-30 15:46:25 +02:00
|
|
|
|
using Umbraco.Core.Composing;
|
2018-02-16 12:00:45 +01:00
|
|
|
|
using Umbraco.Core.Manifest;
|
2016-08-07 17:08:57 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.PropertyEditors
|
|
|
|
|
|
{
|
2018-02-25 10:43:16 +01:00
|
|
|
|
public class PropertyEditorCollection : BuilderCollectionBase<IDataEditor>
|
2016-08-07 17:08:57 +02:00
|
|
|
|
{
|
2018-02-16 12:00:45 +01:00
|
|
|
|
public PropertyEditorCollection(DataEditorCollection dataEditors, ManifestParser manifestParser)
|
|
|
|
|
|
: base(dataEditors
|
|
|
|
|
|
.Where(x => (x.Type & EditorType.PropertyValue) > 0)
|
|
|
|
|
|
.Union(manifestParser.Manifest.PropertyEditors))
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
public PropertyEditorCollection(DataEditorCollection dataEditors)
|
|
|
|
|
|
: base(dataEditors
|
2018-02-25 10:43:16 +01:00
|
|
|
|
.Where(x => (x.Type & EditorType.PropertyValue) > 0))
|
2016-08-07 17:08:57 +02:00
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
// note: virtual so it can be mocked
|
2018-02-25 10:43:16 +01:00
|
|
|
|
public virtual IDataEditor this[string alias]
|
2016-08-07 17:08:57 +02:00
|
|
|
|
=> this.SingleOrDefault(x => x.Alias == alias);
|
2018-02-16 12:00:45 +01:00
|
|
|
|
|
2018-02-25 10:43:16 +01:00
|
|
|
|
public virtual bool TryGet(string alias, out IDataEditor editor)
|
2017-05-12 14:49:44 +02:00
|
|
|
|
{
|
|
|
|
|
|
editor = this.FirstOrDefault(x => x.Alias == alias);
|
|
|
|
|
|
return editor != null;
|
|
|
|
|
|
}
|
2016-08-07 17:08:57 +02:00
|
|
|
|
}
|
2018-02-16 12:00:45 +01:00
|
|
|
|
}
|