<commit_before>﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AppServiceInfo.cs" company="Kephas Software SRL">
//   Copyright (c) Kephas Software SRL. All rights reserved.
//   Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>
// <summary>
//   Implements the application service information class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Kephas.Services.Reflection
{
    using System;

    using Kephas.Composition;
    using Kephas.Diagnostics.Contracts;
    using Kephas.Dynamic;

    /// <summary>
    /// Information about the application service.
    /// </summary>
    public class AppServiceInfo : Expando, IAppServiceInfo
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AppServiceInfo"/> class.
        /// </summary>
        /// <param name="contractType">The contract type of the export.</param>
        /// <param name="lifetime">Optional. The application service lifetime.</param>
        /// <param name="allowMultiple">Optional.
        ///                             <c>true</c> if multiple services are allowed; otherwise,
        ///                             <c>false</c>.
        /// </param>
        /// <param name="asOpenGeneric">Optional.
        ///                             <c>true</c> if the contract should be exported as an open generic;
        ///                             otherwise, <c>false</c>.
        /// </param>
        public AppServiceInfo(Type contractType, AppServiceLifetime lifetime = AppServiceLifetime.Singleton, bool allowMultiple = false, bool asOpenGeneric = false)
        {
            Requires.NotNull(contractType, nameof(contractType));

            this.SetContractType(contractType);
            this.AllowMultiple = allowMultiple;
            this.AsOpenGeneric = asOpenGeneric;
            this.SetLifetime(lifetime);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AppServiceInfo"/> class.
        /// </summary>
        /// <param name="contractType">The contract type of the export.</param>
        /// <param name="serviceInstance">The service instance.</param>
        public AppServiceInfo(Type contractType, object serviceInstance)
        {
            Requires.NotNull(contractType, nameof(contractType));
            Requires.NotNull(serviceInstance, nameof(serviceInstance));

            this.SetContractType(contractType);
            this.Instance = serviceInstance;
            this.SetLifetime(AppServiceLifetime.Singleton);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AppServiceInfo"/> class.
        /// </summary>
        /// <param name="contractType">The contract type of the export.</param>
        /// <param name="serviceInstanceFactory">The service instance factory.</param>
        /// <param name="lifetime">Optional. The application service lifetime.</param>
        public AppServiceInfo(Type contractType, Func<ICompositionContext, object> serviceInstanceFactory, AppServiceLifetime lifetime = AppServiceLifetime.Transient)
        {
            Requires.NotNull(contractType, nameof(contractType));
            Requires.NotNull(serviceInstanceFactory, nameof(serviceInstanceFactory));

            this.SetContractType(contractType);
            this.InstanceFactory = serviceInstanceFactory;
            this.SetLifetime(lifetime);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AppServiceInfo"/> class.
        /// </summary>
        /// <param name="contractType">The contract type of the export.</param>
        /// <param name="serviceInstanceType">Type of the service instance.</param>
        /// <param name="lifetime">Optional. The application service lifetime.</param>
        /// <param name="asOpenGeneric">Optional.
        ///                             <c>true</c> if the contract should be exported as an open generic;
        ///                             otherwise, <c>false</c>.
        /// </param>
        public AppServiceInfo(Type contractType, Type serviceInstanceType, AppServiceLifetime lifetime = AppServiceLifetime.Singleton, bool asOpenGeneric = false)
        {
            Requires.NotNull(contractType, nameof(contractType));
            Requires.NotNull(serviceInstanceType, nameof(serviceInstanceType));

            this.SetContractType(contractType);
            this.InstanceType = serviceInstanceType;
            this.AsOpenGeneric = asOpenGeneric;
            this.SetLifetime(lifetime);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AppServiceInfo"/> class.
        /// </summary>
        /// <param name="contractType">The contract type of the export.</param>
        /// <param name="serviceInstanceType">Type of the service instance.</param>
        public AppServiceInfo(Type contractType, Type serviceInstanceType)
        {
            Requires.NotNull(contractType, nameof(contractType));
            Requires.NotNull(serviceInstanceType, nameof(serviceInstanceType));

            this.SetContractType(contractType);
            this.InstanceType = serviceInstanceType;
            this.SetLifetime(AppServiceLifetime.Scoped);
        }

        /// <summary>
        /// Gets the application service lifetime.
        /// </summary>
        /// <value>
        /// The application service lifetime.
        /// </value>
        public AppServiceLifetime Lifetime { get; private set; }

        /// <summary>
        /// Gets a value indicating whether multiple services for this contract are allowed.
        /// </summary>
        /// <value><commit_msg>Remove duplicate constructor from AppServiceInfo<commit_after>﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AppServiceInfo.cs" company="Kephas Software SRL">
//   Copyright (c) Kephas Software SRL. All rights reserved.
//   Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>
// <summary>
//   Implements the application service information class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Kephas.Services.Reflection
{
    using System;

    using Kephas.Composition;
    using Kephas.Diagnostics.Contracts;
    using Kephas.Dynamic;

    /// <summary>
    /// Information about the application service.
    /// </summary>
    public class AppServiceInfo : Expando, IAppServiceInfo
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AppServiceInfo"/> class.
        /// </summary>
        /// <param name="contractType">The contract type of the export.</param>
        /// <param name="lifetime">Optional. The application service lifetime.</param>
        /// <param name="allowMultiple">Optional.
        ///                             <c>true</c> if multiple services are allowed; otherwise,
        ///                             <c>false</c>.
        /// </param>
        /// <param name="asOpenGeneric">Optional.
        ///                             <c>true</c> if the contract should be exported as an open generic;
        ///                             otherwise, <c>false</c>.
        /// </param>
        public AppServiceInfo(Type contractType, AppServiceLifetime lifetime = AppServiceLifetime.Singleton, bool allowMultiple = false, bool asOpenGeneric = false)
        {
            Requires.NotNull(contractType, nameof(contractType));

            this.SetContractType(contractType);
            this.AllowMultiple = allowMultiple;
            this.AsOpenGeneric = asOpenGeneric;
            this.SetLifetime(lifetime);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AppServiceInfo"/> class.
        /// </summary>
        /// <param name="contractType">The contract type of the export.</param>
        /// <param name="serviceInstance">The service instance.</param>
        public AppServiceInfo(Type contractType, object serviceInstance)
        {
            Requires.NotNull(contractType, nameof(contractType));
            Requires.NotNull(serviceInstance, nameof(serviceInstance));

            this.SetContractType(contractType);
            this.Instance = serviceInstance;
            this.SetLifetime(AppServiceLifetime.Singleton);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AppServiceInfo"/> class.
        /// </summary>
        /// <param name="contractType">The contract type of the export.</param>
        /// <param name="serviceInstanceFactory">The service instance factory.</param>
        /// <param name="lifetime">Optional. The application service lifetime.</param>
        public AppServiceInfo(Type contractType, Func<ICompositionContext, object> serviceInstanceFactory, AppServiceLifetime lifetime = AppServiceLifetime.Transient)
        {
            Requires.NotNull(contractType, nameof(contractType));
            Requires.NotNull(serviceInstanceFactory, nameof(serviceInstanceFactory));

            this.SetContractType(contractType);
            this.InstanceFactory = serviceInstanceFactory;
            this.SetLifetime(lifetime);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AppServiceInfo"/> class.
        /// </summary>
        /// <param name="contractType">The contract type of the export.</param>
        /// <param name="serviceInstanceType">Type of the service instance.</param>
        /// <param name="lifetime">Optional. The application service lifetime.</param>
        /// <param name="asOpenGeneric">Optional.
        ///                             <c>true</c> if the contract should be exported as an open generic;
        ///                             otherwise, <c>false</c>.
        /// </param>
        public AppServiceInfo(Type contractType, Type serviceInstanceType, AppServiceLifetime lifetime = AppServiceLifetime.Singleton, bool asOpenGeneric = false)
        {
            Requires.NotNull(contractType, nameof(contractType));
            Requires.NotNull(serviceInstanceType, nameof(serviceInstanceType));

            this.SetContractType(contractType);
            this.InstanceType = serviceInstanceType;
            this.AsOpenGeneric = asOpenGeneric;
            this.SetLifetime(lifetime);
        }

        /// <summary>
        /// Gets the application service lifetime.
        /// </summary>
        /// <value>
        /// The application service lifetime.
        /// </value>
        public AppServiceLifetime Lifetime { get; private set; }

        /// <summary>
        /// Gets a value indicating whether multiple services for this contract are allowed.
        /// </summary>
        /// <value>
{'fraction_non_alphanumeric': 0.15212890449185346, 'fraction_numerical': 0.0, 'mean_word_length': 1.9007832898172323, 'pattern_counts': {'":': 0, '<': 138, '<?xml version=': 0, '>': 138, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2398621', 'n_tokens_mistral': 2562, 'n_tokens_neox': 2535, 'n_words': 668}