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

namespace ESRI.ArcGIS.BaseClasses
{
    /// <summary>
    ///     An internal abstract class used to handle initialization the runtime licenses for use of ArcObjects
    ///     code outside of the ESRI environment.
    /// </summary>
    /// <typeparam name="TLicenseProduct">The type of the product codes.</typeparam>
    /// <typeparam name="TLicenseExtension">The type of the extension codes.</typeparam>
    /// <typeparam name="TLicenseStatus">The type of the status codes.</typeparam>
    public abstract class BaseRuntimeAuthorization<TLicenseProduct, TLicenseExtension, TLicenseStatus> : IDisposable
    {
        #region Constructors

        /// <summary>
        ///     Initializes a new instance of the
        ///     <see cref="BaseRuntimeAuthorization{TLicenseProduct, TLicenseExtension, TLicenseStatus}" /> class.
        /// </summary>
        protected BaseRuntimeAuthorization()
        {
            this.ProductStatus = new Dictionary<TLicenseProduct, TLicenseStatus>();
            this.ExtensionStatus = new Dictionary<TLicenseExtension, TLicenseStatus>();
            this.InitializeLowerProductFirst = true;
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///     Gets or sets the extension status.
        /// </summary>
        /// <value>
        ///     The extension status.
        /// </value>
        public Dictionary<TLicenseExtension, TLicenseStatus> ExtensionStatus { get; protected set; }

        /// <summary>
        ///     Get/Set the ordering of product code checking. If true, check from lowest to
        ///     highest license. True by default.
        /// </summary>
        public bool InitializeLowerProductFirst { get; set; }

        /// <summary>
        ///     Gets the product code that has been initialized.
        /// </summary>
        public virtual TLicenseProduct InitializedProduct { get; protected set; }

        /// <summary>
        ///     Gets or sets the product status.
        /// </summary>
        /// <value>
        ///     The product status.
        /// </value>
        public Dictionary<TLicenseProduct, TLicenseStatus> ProductStatus { get; protected set; }

        #endregion

        #region IDisposable Members

        /// <summary>
        ///     Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            this.Dispose(true);

            GC.SuppressFinalize(this);
        }

        #endregion

        #region Public Methods

        /// <summary>
        ///     Initialize the application with the specified product and extension license codes.
        /// </summary>
        /// <param name="licenseProducts">The product codes.</param>
        /// <param name="licenseExtensions">The extension codes.</param>
        /// <returns>
        ///     <c>true</c> when the initialization is successful; otherwise <c>false</c>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     productCodes
        ///     or
        ///     extensionCodes
        /// </exception>
        /// <remarks>
        ///     Make sure an active ArcGIS runtime has been bound before license initialization.
        /// </remarks>
        public bool Initialize(IEnumerable<TLicenseProduct> licenseProducts, TLicenseExtension[] licenseExtensions)
        {
            bool initializedProduct = false;

            if (licenseProducts == null) throw new ArgumentNullException("licenseProducts");
            if (licenseExtensions == null) throw new ArgumentNullException("licenseExtensions");

            this.ProductStatus.Clear();
            this.ExtensionStatus.Clear();

            // Enumerate through all of the product codes, initializing the product that is available.
            foreach (TLicenseProduct licenseProduct in licenseProducts)
            {
                // Initialize (or check out) the product.
                TLicenseStatus licenseStatus = this.InitializeProduct(licenseProduct);
                this.ProductStatus.Add(licenseProduct, licenseStatus);<commit_msg>Added support for checking out single license<commit_after>﻿using System;
using System.Collections.Generic;

namespace ESRI.ArcGIS.BaseClasses
{
    /// <summary>
    ///     An internal abstract class used to handle initialization the runtime licenses for use of ArcObjects
    ///     code outside of the ESRI environment.
    /// </summary>
    /// <typeparam name="TLicenseProduct">The type of the product codes.</typeparam>
    /// <typeparam name="TLicenseExtension">The type of the extension codes.</typeparam>
    /// <typeparam name="TLicenseStatus">The type of the status codes.</typeparam>
    public abstract class BaseRuntimeAuthorization<TLicenseProduct, TLicenseExtension, TLicenseStatus> : IDisposable
    {
        #region Constructors

        /// <summary>
        ///     Initializes a new instance of the
        ///     <see cref="BaseRuntimeAuthorization{TLicenseProduct, TLicenseExtension, TLicenseStatus}" /> class.
        /// </summary>
        protected BaseRuntimeAuthorization()
        {
            this.ProductStatus = new Dictionary<TLicenseProduct, TLicenseStatus>();
            this.ExtensionStatus = new Dictionary<TLicenseExtension, TLicenseStatus>();
            this.InitializeLowerProductFirst = true;
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///     Gets or sets the extension status.
        /// </summary>
        /// <value>
        ///     The extension status.
        /// </value>
        public Dictionary<TLicenseExtension, TLicenseStatus> ExtensionStatus { get; protected set; }

        /// <summary>
        ///     Get/Set the ordering of product code checking. If true, check from lowest to
        ///     highest license. True by default.
        /// </summary>
        public bool InitializeLowerProductFirst { get; set; }

        /// <summary>
        ///     Gets the product code that has been initialized.
        /// </summary>
        public virtual TLicenseProduct InitializedProduct { get; protected set; }

        /// <summary>
        ///     Gets or sets the product status.
        /// </summary>
        /// <value>
        ///     The product status.
        /// </value>
        public Dictionary<TLicenseProduct, TLicenseStatus> ProductStatus { get; protected set; }

        #endregion

        #region IDisposable Members

        /// <summary>
        ///     Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            this.Dispose(true);

            GC.SuppressFinalize(this);
        }

        #endregion

        #region Public Methods

        /// <summary>
        ///     Initialize the application with the specified product code.
        /// </summary>
        /// <param name="licenseProduct">The product codes.</param>
        /// <returns>
        ///     <c>true</c> when the initialization is successful; otherwise <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///     productCodes
        ///     or
        ///     extensionCodes
        /// </exception>
        /// <remarks>
        ///     Make sure an active ArcGIS runtime has been bound before license initialization.
        /// </remarks>
        public bool Initialize(TLicenseProduct licenseProduct)
        {
            return this.Initialize(new[] {licenseProduct}, new TLicenseExtension[] {});
        }

        /// <summary>
        ///     Initialize the application with the specified product and extension codes.
        /// </summary>
        /// <param name="licenseProduct">The product codes.</param>
        /// <param name="licenseExtensions">The license extensions.</param>
        /// <returns>
        ///     <c>true</c> when the initialization is successful; otherwise <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///     productCodes
        ///     or
        ///     extensionCodes
        /// </exception>
        /// <remarks>
        ///     Make sure an active ArcGIS runtime has been bound before license initialization.
        /// </remarks>
        public bool Initialize(TLicenseProduct licenseProduct, params TLicenseExtension[] licenseExtensions)
        {
            return this.Initialize(new[] {licenseProduct}, licenseExtensions);
        }

        /// <summary>
        ///     Initialize the application with the specified product and extension license codes.
        /// </summary>
        /// <param name="licenseProducts">The product codes.</param>
        /// <param name="licenseExtensions">The extension codes.</param>
        /// <returns>
        ///     <c>true</c> when the initialization is successful; otherwise <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///     productCodes
        ///     or
        ///     extensionCodes
        /// </exception>
        /// <remarks>
        ///     Make sure an active ArcGIS runtime has been bound before license initialization.
        /// </remarks>
        public bool Initialize(IEnumerable<TLicenseProduct> licenseProducts, TLicenseExtension[] licenseExtensions)
        {
            bool initializedProduct = false;

            if (licenseProducts == null) throw new ArgumentNullException("licenseProducts");
            if (licenseExtensions == null) throw new ArgumentNullException("licenseExtensions");

            this.ProductStatus.Clear();
            this.ExtensionStatus.Clear();

            // Enumerate through all of the product codes, initializing the product that is available.
            foreach (TLicenseProduct licenseProduct in licenseProducts)
            {
                // Initialize (or check out) the product.
                TLicenseStatus licenseStatus = this.InitializeProduct(licenseProduct);
                this.ProductStatus.Add(licenseProduct, licenseStatus);
{'fraction_non_alphanumeric': 0.10866803478940681, 'fraction_numerical': 0.0, 'mean_word_length': 1.963799594555459, 'pattern_counts': {'":': 0, '<': 127, '<?xml version=': 0, '>': 127, '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': '143620', 'n_tokens_mistral': 2343, 'n_tokens_neox': 2326, 'n_words': 717}