<commit_before>﻿using System;
using System.Collections.Generic;
using System.Web.Routing;

namespace FluentSiteMap
{
    /// <summary>
    /// Carries state during a site map build process.
    /// </summary>
    public class BuilderContext
    {
        private readonly IDictionary<string, object> _metadata = new Dictionary<string, object>();

        /// <summary>
        /// Gets the <see cref="RequestContext"/> associated with the site map build.
        /// </summary>
        public RequestContext RequestContext { get; private set; }

        /// <summary>
        /// Gets the parent <see cref="BuilderContext"/> instance, if one exists.
        /// </summary>
        public BuilderContext Parent { get; private set; }

        /// <summary>
        /// Initializes a new instance of a root <see cref="BuilderContext"/>.
        /// </summary>
        /// <param name="requestContext">
        /// The <see cref="RequestContext"/> associated with the current HTTP request.
        /// </param>
        public BuilderContext(RequestContext requestContext)
        {
            if (requestContext == null) throw new ArgumentNullException("requestContext");

            RequestContext = requestContext;
        }

        /// <summary>
        /// Initializes a new instance of a child <see cref="BuilderContext"/>.
        /// </summary>
        /// <param name="parent">
        /// The parent <see cref="BuilderContext"/> instance.
        /// </param>
        public BuilderContext(BuilderContext parent)
        {
            if (parent == null) throw new ArgumentNullException("parent");

            Parent = parent;
            RequestContext = parent.RequestContext;
        }

        /// <summary>
        /// Gets a strongly-typed metadata value out of the context.
        /// </summary>
        /// <param name="key">
        /// The key used to get the value.
        /// </param>
        /// <returns>
        /// The obtained value either from this context or a parent context.
        /// </returns>
        /// <exception cref="InvalidOperationException">
        /// No value either in this context or any parent context could be found 
        /// with the specified <paramref name="key"/>.
        /// </exception>
        public T GetMetadata<T>(string key)
        {
            // recursively search for the metadata value in current node and ancestors
            var context = this;
            while (!context._metadata.ContainsKey(key))
            {
                context = context.Parent;
                if (context == null)<commit_msg>Fixed XML documentation for the GetMetadata method<commit_after>﻿using System;
using System.Collections.Generic;
using System.Web.Routing;

namespace FluentSiteMap
{
    /// <summary>
    /// Carries state during a site map build process.
    /// </summary>
    public class BuilderContext
    {
        private readonly IDictionary<string, object> _metadata = new Dictionary<string, object>();

        /// <summary>
        /// Gets the <see cref="RequestContext"/> associated with the site map build.
        /// </summary>
        public RequestContext RequestContext { get; private set; }

        /// <summary>
        /// Gets the parent <see cref="BuilderContext"/> instance, if one exists.
        /// </summary>
        public BuilderContext Parent { get; private set; }

        /// <summary>
        /// Initializes a new instance of a root <see cref="BuilderContext"/>.
        /// </summary>
        /// <param name="requestContext">
        /// The <see cref="RequestContext"/> associated with the current HTTP request.
        /// </param>
        public BuilderContext(RequestContext requestContext)
        {
            if (requestContext == null) throw new ArgumentNullException("requestContext");

            RequestContext = requestContext;
        }

        /// <summary>
        /// Initializes a new instance of a child <see cref="BuilderContext"/>.
        /// </summary>
        /// <param name="parent">
        /// The parent <see cref="BuilderContext"/> instance.
        /// </param>
        public BuilderContext(BuilderContext parent)
        {
            if (parent == null) throw new ArgumentNullException("parent");

            Parent = parent;
            RequestContext = parent.RequestContext;
        }

        /// <summary>
        /// Gets a strongly-typed metadata value out of the context.
        /// </summary>
        /// <param name="key">
        /// The key used to get the value.
        /// </param>
        /// <returns>
        /// The obtained value either from this context or a parent context 
        /// or a default value (ex: null) if no value is found.
        /// </returns>
        public T GetMetadata<T>(string key)
        {
            // recursively search for the metadata value in current node and ancestors
            var context = this;
            while (!context._metadata.ContainsKey(key))
            {
                context = context.Parent;
                if (context == null)
{'fraction_non_alphanumeric': 0.11950059453032105, 'fraction_numerical': 0.0, 'mean_word_length': 1.8322109988776656, 'pattern_counts': {'":': 0, '<': 64, '<?xml version=': 0, '>': 64, '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': '4023174', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1166, 'n_words': 415}