Пример #1
0
        public ContentPartOption AddContentPart(Type contentPartType)
        {
            if (!contentPartType.IsSubclassOf(typeof(ContentPart)))
            {
                throw new ArgumentException("The type must inherit from " + nameof(ContentPart));
            }

            var option = new ContentPartOption(contentPartType);

            _contentParts.Add(option);

            return(option);
        }
Пример #2
0
        internal ContentPartOption GetOrAddContentPart(Type contentPartType)
        {
            if (!contentPartType.IsSubclassOf(typeof(ContentPart)))
            {
                throw new ArgumentException("The type must inherit from " + nameof(ContentPart));
            }

            var option = _contentParts.FirstOrDefault(x => x.Type == contentPartType);

            if (option == null)
            {
                option = new ContentPartOption(contentPartType);
                _contentParts.Add(option);
            }

            return(option);
        }