<commit_before>﻿using AuctionService.Api.Helpers;
using AuctionService.Data.DataContexts;
using AuctionService.Data.Repositories;
using AuctionService.Domain.Contracts.Repositories;
using AuctionService.Domain.Contracts.Services;
using Microsoft.Practices.Unity;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Web.Http;

namespace AuctionService.Api
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            #region Dependency Injection
            var container = new UnityContainer();
            container.RegisterType<AuctionServiceContext, AuctionServiceContext>();

            container.RegisterType<IAuctionRepository, AuctionRepository>();

            container.RegisterType<IAuctionService, Business.Services.AuctionService>();

            config.DependencyResolver = new UnityResolver(container);
            #endregion

            ConfigureWebApi(config);
        }

        public static void ConfigureWebApi(HttpConfiguration config)
        {
            var formatters = config.Formatters;
            formatters.Remove(formatters.XmlFormatter);

            var jsonSettings = formatters.JsonFormatter.SerializerSettings;
            jsonSettings.Formatting = Formatting.Indented;
            jsonSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.Objects;

            config.EnableCors();

            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }
}<commit_msg>Ignore object references during serialization<commit_after>﻿using AuctionService.Api.Helpers;
using AuctionService.Data.DataContexts;
using AuctionService.Data.Repositories;
using AuctionService.Domain.Contracts.Repositories;
using AuctionService.Domain.Contracts.Services;
using Microsoft.Practices.Unity;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Web.Http;

namespace AuctionService.Api
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            #region Dependency Injection
            var container = new UnityContainer();
            container.RegisterType<AuctionServiceContext, AuctionServiceContext>();

            container.RegisterType<IAuctionRepository, AuctionRepository>();

            container.RegisterType<IAuctionService, Business.Services.AuctionService>();

            config.DependencyResolver = new UnityResolver(container);
            #endregion

            ConfigureWebApi(config);
        }

        public static void ConfigureWebApi(HttpConfiguration config)
        {
            var formatters = config.Formatters;
            formatters.Remove(formatters.XmlFormatter);

            var jsonSettings = formatters.JsonFormatter.SerializerSettings;
            jsonSettings.Formatting = Formatting.Indented;
            jsonSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;

            config.EnableCors();

            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }
}
{'fraction_non_alphanumeric': 0.07660961695191525, 'fraction_numerical': 0.0, 'mean_word_length': 2.8554973821989527, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2889648', 'n_tokens_mistral': 884, 'n_tokens_neox': 852, 'n_words': 158}