<commit_before>﻿namespace Superscribe.Models
{
    using System;
    using System.Collections.Concurrent;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.RegularExpressions;

    using Superscribe.Utils;

    public class SuperscribeNode : IEquatable<SuperscribeNode>
    {
        public Func<dynamic, string, bool> activationFunction;

        /// <summary>
        /// Base constructor for superscribe states
        /// </summary>
        public SuperscribeNode()
        {
            this.Edges = new ConcurrentQueue<SuperscribeNode>();
            this.QueryString = new ConcurrentQueue<SuperscribeNode>();
            this.AllowedMethods = new ConcurrentQueue<string>();
            this.FinalFunctions = new List<FinalFunction>();

            this.activationFunction = (routedata, segment) =>
            {
                if (this.Pattern != null)
                {
                    return this.Pattern.IsMatch(segment);
                }

                return string.Equals(this.Template, segment, StringComparison.OrdinalIgnoreCase);
            };
        }

        #region Properties

        /// <summary>
        /// The parent state
        /// </summary>
        protected SuperscribeNode Parent { get; set; }

        /// <summary>
        /// Boolean flag indicating if the transition into this state is optional
        /// </summary>
        public bool IsOptional { get; private set; }

        /// <summary>
        /// Concurrent queue of available transitions from this state
        /// </summary>
        public ConcurrentQueue<SuperscribeNode> Edges { get; set; }

        /// <summary>
        /// Concurrent queue of available querystring transitions
        /// </summary>
        public ConcurrentQueue<SuperscribeNode> QueryString { get; set; }

        /// <summary>
        /// Regex pattern to use when matching
        /// </summary>
        public Regex Pattern { get; set; }

        /// <summary>
        /// String template to use when matching
        /// </summary>
        public string Template { get; set; }

        public object Result { get; set; }

        public Action<dynamic, string> ActionFunction { get; set; }

        public List<FinalFunction> FinalFunctions { get; set; }

        public bool ActivationFunctionChanged { set; get; }

        public Func<dynamic, string, bool> ActivationFunction
        {
            get
            {
                return activationFunction;
            }
            set
            {<commit_msg>Converted ActionFunction of superscribe node to property with backing field<commit_after>﻿namespace Superscribe.Models
{
    using System;
    using System.Collections.Concurrent;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.RegularExpressions;

    using Superscribe.Utils;

    public class SuperscribeNode : IEquatable<SuperscribeNode>
    {
        protected Func<dynamic, string, bool> activationFunction;

        protected Action<dynamic, string> actionFunction;

        /// <summary>
        /// Base constructor for superscribe states
        /// </summary>
        public SuperscribeNode()
        {
            this.Edges = new ConcurrentQueue<SuperscribeNode>();
            this.QueryString = new ConcurrentQueue<SuperscribeNode>();
            this.AllowedMethods = new ConcurrentQueue<string>();
            this.FinalFunctions = new List<FinalFunction>();

            this.activationFunction = (routedata, segment) =>
            {
                if (this.Pattern != null)
                {
                    return this.Pattern.IsMatch(segment);
                }

                return string.Equals(this.Template, segment, StringComparison.OrdinalIgnoreCase);
            };
        }

        #region Properties

        /// <summary>
        /// The parent state
        /// </summary>
        protected SuperscribeNode Parent { get; set; }

        /// <summary>
        /// Boolean flag indicating if the transition into this state is optional
        /// </summary>
        public bool IsOptional { get; private set; }

        /// <summary>
        /// Concurrent queue of available transitions from this state
        /// </summary>
        public ConcurrentQueue<SuperscribeNode> Edges { get; set; }

        /// <summary>
        /// Concurrent queue of available querystring transitions
        /// </summary>
        public ConcurrentQueue<SuperscribeNode> QueryString { get; set; }

        /// <summary>
        /// Regex pattern to use when matching
        /// </summary>
        public Regex Pattern { get; set; }

        /// <summary>
        /// String template to use when matching
        /// </summary>
        public string Template { get; set; }

        public object Result { get; set; }

        public Action<dynamic, string> ActionFunction
        {
            get
            {
                return this.actionFunction;
            }
            set
            {
                this.actionFunction = value;
            }
        }

        public List<FinalFunction> FinalFunctions { get; set; }

        public bool ActivationFunctionChanged { set; get; }

        public Func<dynamic, string, bool> ActivationFunction
        {
            get
            {
                return activationFunction;
            }
            set
            {
{'fraction_non_alphanumeric': 0.09422040512915815, 'fraction_numerical': 0.0, 'mean_word_length': 1.7045226130653266, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 56, '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': '113180', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1251, 'n_words': 359}