public ContentTypeDefinitionBuilder WithPart(ContentPartDefinition partDefinition, Action<ContentTypePartDefinitionBuilder> configuration) {
     var existingPart = _parts.SingleOrDefault(x => x.PartDefinition.Name == partDefinition.Name);
     if (existingPart != null) {
         _parts.Remove(existingPart);
     }
     else {
         existingPart = new ContentTypePartDefinition(partDefinition, new SettingsDictionary());
     }
     var configurer = new PartConfigurerImpl(existingPart);
     configuration(configurer);
     _parts.Add(configurer.Build());
     return this;
 }
        public ContentTypeDefinitionBuilder WithPart(ContentPartDefinition partDefinition, Action <ContentTypePartDefinitionBuilder> configuration)
        {
            var existingPart = _parts.SingleOrDefault(x => x.PartDefinition.Name == partDefinition.Name);

            if (existingPart != null)
            {
                _parts.Remove(existingPart);
            }
            else
            {
                existingPart = new ContentTypePartDefinition(partDefinition, new SettingsDictionary());
            }
            var configurer = new PartConfigurerImpl(existingPart);

            configuration(configurer);
            _parts.Add(configurer.Build());
            return(this);
        }
        public ContentTypeDefinitionBuilder WithPart(string name, ContentPartDefinition partDefinition, Action <ContentTypePartDefinitionBuilder> configuration)
        {
            var existingPart = _parts.FirstOrDefault(x => x.Name == name);

            if (existingPart != null)
            {
                _parts.Remove(existingPart);
            }
            else
            {
                existingPart = new ContentTypePartDefinition(name, partDefinition, new JObject());
                existingPart.ContentTypeDefinition = Current;
            }

            var configurer = new PartConfigurerImpl(existingPart);

            configuration(configurer);
            _parts.Add(configurer.Build());
            return(this);
        }
        public async Task <ContentTypeDefinitionBuilder> WithPartAsync(string name, ContentPartDefinition partDefinition, Func <ContentTypePartDefinitionBuilder, Task> configurationAsync)
        {
            var existingPart = _parts.FirstOrDefault(x => x.Name == name);

            if (existingPart != null)
            {
                _parts.Remove(existingPart);
            }
            else
            {
                existingPart = new ContentTypePartDefinition(name, partDefinition, new JObject());
                existingPart.ContentTypeDefinition = Current;
            }

            var configurer = new PartConfigurerImpl(existingPart);

            await configurationAsync(configurer);

            _parts.Add(configurer.Build());

            return(this);
        }
        public ContentTypeDefinitionBuilder WithPart(string name, ContentPartDefinition partDefinition, Action<ContentTypePartDefinitionBuilder> configuration)
        {
            var existingPart = _parts.FirstOrDefault(x => x.Name == name );
            if (existingPart != null)
            {
                _parts.Remove(existingPart);
            }
            else
            {
                existingPart = new ContentTypePartDefinition(name, partDefinition, new JObject());
                existingPart.ContentTypeDefinition = Current;
            }

            var configurer = new PartConfigurerImpl(existingPart);
            configuration(configurer);
            _parts.Add(configurer.Build());
            return this;
        }