<commit_before>﻿using System;
using System.Linq.Expressions;

namespace Jot.Configuration
{
    /*
     * Derives from TrackingConfiguration and adds a generic strongly typed API for configuring tracking.
     * This class does not provide any new functionality nor store any additional state. All calls are forwarded to the base class.
     */

        // TODO:
        // Make this a wrapper class that wraps a non-generic trackingconfiguration
        // Create instances of this class on-the-fly inside generic methods of the 
        // Tracker, but do not store references to instances of this class, they are
        // only for compile time convenience. 

    /// <summary>
    /// A TrackingConfiguration determines how a target object will be tracked.
    /// This includes list of properties to track, persist triggers and id getter.
    /// </summary>
    public sealed class TrackingConfiguration<T> : TrackingConfiguration
    {
        private readonly TrackingConfiguration inner;

        internal TrackingConfiguration(TrackingConfiguration inner)
        {
            this.inner = inner;
        }

        /// <summary>
        /// Allows value conversion and cancallation when applying a stored value to a property.
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public TrackingConfiguration<T> WhenApplyingProperty(Action<T, PropertyOperationData> action)
        {
            inner.WhenApplyingProperty((obj, prop) => action((T)obj, prop));
            return this;
        }

        /// <summary>
        /// Allows supplying a callback that will be called when all saved state is applied to a target object.
        /// </summary><commit_msg>Minor: adding a TrackingConfigurationGeneric.Track<T>() method<commit_after>﻿using System;
using System.Linq.Expressions;

namespace Jot.Configuration
{
    /*
     * Derives from TrackingConfiguration and adds a generic strongly typed API for configuring tracking.
     * This class does not provide any new functionality nor store any additional state. All calls are forwarded to the base class.
     */

        // TODO:
        // Make this a wrapper class that wraps a non-generic trackingconfiguration
        // Create instances of this class on-the-fly inside generic methods of the 
        // Tracker, but do not store references to instances of this class, they are
        // only for compile time convenience. 

    /// <summary>
    /// A TrackingConfiguration determines how a target object will be tracked.
    /// This includes list of properties to track, persist triggers and id getter.
    /// </summary>
    public sealed class TrackingConfiguration<T> : TrackingConfiguration
    {
        private readonly TrackingConfiguration inner;

        internal TrackingConfiguration(TrackingConfiguration inner)
        {
            this.inner = inner;
        }

        public void Track<T>(T target)
            => inner.Tracker.Track(target);

        /// <summary>
        /// Allows value conversion and cancallation when applying a stored value to a property.
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public TrackingConfiguration<T> WhenApplyingProperty(Action<T, PropertyOperationData> action)
        {
            inner.WhenApplyingProperty((obj, prop) => action((T)obj, prop));
            return this;
        }

        /// <summary>
        /// Allows supplying a callback that will be called when all saved state is applied to a target object.
        /// </summary>
{'fraction_non_alphanumeric': 0.08331011423794929, 'fraction_numerical': 0.0, 'mean_word_length': 2.389990557129367, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 34, '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': '5318536', 'n_tokens_mistral': 847, 'n_tokens_neox': 821, 'n_words': 342}