<commit_before>﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NFig
{
    /// <summary>
    /// Provides methods for consuming NFig settings within an application.
    /// </summary>
    public class NFigAppClient<TSettings, TTier, TDataCenter>
        where TSettings : class, INFigSettings<int, TTier, TDataCenter>, new() // todo remove TSubApp
        where TTier : struct
        where TDataCenter : struct
    {
        /// <summary>
        /// The method signature of callback functions passed to <see cref="Subscribe"/>.
        /// </summary>
        /// <param name="ex">An Exception object if there was a problem getting or applying overrides. This parameter will be null in most cases</param>
        /// <param name="settings">A hydrated settings object which represents the current active setting values.</param>
        /// <param name="client">A reference to the app client which generated the settings object.</param>
        public delegate void UpdateDelegate(
            Exception ex,
            TSettings settings,
            NFigAppClient<TSettings, TTier, TDataCenter> client);

        /// <summary>
        /// The method signature for of callbacks passed to <see cref="SubscribeToSubApps"/>.
        /// </summary>
        /// <param name="ex">An Exception object if there was a problem getting or applying overrides. This parameter will be null in most cases</param>
        /// <param name="settingsBySubAppId">A dictionary of hydrated settings object by sub-app.</param>
        /// <param name="client">A reference to the app client which generated the settings object.</param>
        public delegate void SubAppsUpdateDelegate(
            Exception ex,
            Dictionary<int, TSettings> settingsBySubAppId,
            NFigAppClient<TSettings, TTier, TDataCenter> client);

        /// <summary>
        /// The backing store for NFig overrides and metadata.
        /// </summary>
        public NFigStore<TTier, TDataCenter> Store { get; }
        /// <summary>
        /// The name of your application.
        /// </summary>
        public string AppName { get; }
        /// <summary>
        /// The deployment tier of your application.
        /// </summary>
        public TTier Tier { get; }
        /// <summary>
        /// The data center where your application resides.
        /// </summary>
        public TDataCenter DataCenter { get; }

        internal NFigAppClient(NFigStore<TTier, TDataCenter> store, string appName, TTier tier, TDataCenter dataCenter)
        {
            Store = store;
            AppName = appName;
            Tier = tier;
            DataCenter = dataCenter;
        }

        /// <summary>
        /// Returns a hydrated settings object based on the current defaults and overrides.
        /// </summary>
        /// <param name="subAppId">
        /// The ID of a sub-app. This is only applicable in multi-tenancy environments. If not null, this sub-app must have been previously declared via one of<commit_msg>Make NFigAppClient protected and internal<commit_after>﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NFig
{
    /// <summary>
    /// Provides methods for consuming NFig settings within an application.
    /// </summary>
    public class NFigAppClient<TSettings, TTier, TDataCenter>
        where TSettings : class, INFigSettings<int, TTier, TDataCenter>, new() // todo remove TSubApp
        where TTier : struct
        where TDataCenter : struct
    {
        /// <summary>
        /// The method signature of callback functions passed to <see cref="Subscribe"/>.
        /// </summary>
        /// <param name="ex">An Exception object if there was a problem getting or applying overrides. This parameter will be null in most cases</param>
        /// <param name="settings">A hydrated settings object which represents the current active setting values.</param>
        /// <param name="client">A reference to the app client which generated the settings object.</param>
        public delegate void UpdateDelegate(
            Exception ex,
            TSettings settings,
            NFigAppClient<TSettings, TTier, TDataCenter> client);

        /// <summary>
        /// The method signature for of callbacks passed to <see cref="SubscribeToSubApps"/>.
        /// </summary>
        /// <param name="ex">An Exception object if there was a problem getting or applying overrides. This parameter will be null in most cases</param>
        /// <param name="settingsBySubAppId">A dictionary of hydrated settings object by sub-app.</param>
        /// <param name="client">A reference to the app client which generated the settings object.</param>
        public delegate void SubAppsUpdateDelegate(
            Exception ex,
            Dictionary<int, TSettings> settingsBySubAppId,
            NFigAppClient<TSettings, TTier, TDataCenter> client);

        /// <summary>
        /// The backing store for NFig overrides and metadata.
        /// </summary>
        public NFigStore<TTier, TDataCenter> Store { get; }
        /// <summary>
        /// The name of your application.
        /// </summary>
        public string AppName { get; }
        /// <summary>
        /// The deployment tier of your application.
        /// </summary>
        public TTier Tier { get; }
        /// <summary>
        /// The data center where your application resides.
        /// </summary>
        public TDataCenter DataCenter { get; }

        /// <summary>
        /// Initializes the app client.
        /// </summary>
        protected internal NFigAppClient(NFigStore<TTier, TDataCenter> store, string appName, TTier tier, TDataCenter dataCenter)
        {
            Store = store;
            AppName = appName;
            Tier = tier;
            DataCenter = dataCenter;
        }

        /// <summary>
        /// Returns a hydrated settings object based on the current defaults and overrides.
        /// </summary>
        /// <param name="subAppId">
        /// The ID of a sub-app. This is only applicable in multi-tenancy environments. If not null, this sub-app must have been previously declared via one of
{'fraction_non_alphanumeric': 0.10101498308361527, 'fraction_numerical': 0.0, 'mean_word_length': 2.1901336073997943, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 81, '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': '3354052', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1507, 'n_words': 582}