Exemplo n.º 1
0
        public ContentFieldOption AddContentField(Type contentFieldType)
        {
            if (!contentFieldType.IsSubclassOf(typeof(ContentField)))
            {
                throw new ArgumentException("The type must inherit from " + nameof(ContentField));
            }

            var option = new ContentFieldOption(contentFieldType);

            _contentFields.Add(option);

            return(option);
        }
Exemplo n.º 2
0
        internal ContentFieldOption GetOrAddContentField(Type contentFieldType)
        {
            if (!contentFieldType.IsSubclassOf(typeof(ContentField)))
            {
                throw new ArgumentException("The type must inherit from " + nameof(ContentField));
            }

            var option = _contentFields.FirstOrDefault(o => o.Type == contentFieldType);

            if (option == null)
            {
                option = new ContentFieldOption(contentFieldType);
                _contentFields.Add(option);
            }

            return(option);
        }