<commit_before>﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using GSoft.Dynamite.Binding;
using Microsoft.SharePoint;

namespace GSoft.Dynamite.Definitions
{
    /// <summary>
    /// Helper class for managing content types.
    /// </summary>
    public class ContentTypeBuilder
    {<commit_msg>Added an override to Ensure Content Type that takes a content type info object.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using GSoft.Dynamite.Binding;
using Microsoft.SharePoint;

namespace GSoft.Dynamite.Definitions
{
    /// <summary>
    /// Helper class for managing content types.
    /// </summary>
    public class ContentTypeBuilder
    {
        /// <summary>
        /// Ensure the content type based on its content type info. 
        /// Sets the description and Groups resource, adds the fields and calls update.
        /// </summary>
        /// <param name="contentTypeCollection">The content type collection.</param>
        /// <param name="contentTypeInfo">The content type information.</param>
        /// <returns>
        /// The created and configured content type.
        /// </returns>
        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Use of statics is discouraged - this favors more flexibility and consistency with dependency injection.")]
        public SPContentType EnsureContentType(SPContentTypeCollection contentTypeCollection, ContentTypeInfo contentTypeInfo)
        {
            SPContentType contentType = this.EnsureContentType(
                contentTypeCollection,
                contentTypeInfo.ContentTypeId,
                contentTypeInfo.TitleResourceString);

            this.EnsureFieldInContentType(contentType, contentTypeInfo.Fields);

            contentType.Description = contentTypeInfo.DescriptionResourceString;
            contentType.Group = contentTypeInfo.ContentGroupResourceString;
            contentType.Update();

            return contentType;
        }

{'fraction_non_alphanumeric': 0.08660351826792964, 'fraction_numerical': 0.0018042399639152007, 'mean_word_length': 3.0847145488029466, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1458168', 'n_tokens_mistral': 525, 'n_tokens_neox': 527, 'n_words': 151}