<commit_before>﻿namespace Merchello.Core.Gateways.Taxation
{
    using System;
    using System.Linq;

    using Merchello.Core.Models;
    using Merchello.Core.Services;

    using Umbraco.Core;
    using Umbraco.Core.Logging;

    /// <summary>
    /// Represents the TaxationContext
    /// </summary>
    internal class TaxationContext : GatewayProviderTypedContextBase<TaxationGatewayProviderBase>, ITaxationContext
    {
        /// <summary>
        /// The store setting service.
        /// </summary>
        private readonly IStoreSettingService _storeSettingService;

        /// <summary>
        /// The _tax by product method.
        /// </summary>
        private ITaxationByProductMethod _taxByProductMethod;

        /// <summary>
        /// The _tax method not set.
        /// </summary>
        private bool _taxMethodNotQueried = true;

        /// <summary>
        /// The <see cref="TaxationApplication"/>.
        /// </summary>
        private TaxationApplication _taxationApplication;

        /// <summary>
        /// Initializes a new instance of the <see cref="TaxationContext"/> class.
        /// </summary>
        /// <param name="gatewayProviderService">
        /// The gateway provider service.
        /// </param>
        /// <param name="storeSettingService">
        /// The <see cref="IStoreSettingService"/>
        /// </param>
        /// <param name="resolver">
        /// The resolver.
        /// </param>
        public TaxationContext(IGatewayProviderService gatewayProviderService, IStoreSettingService storeSettingService, IGatewayProviderResolver resolver)
            : base(gatewayProviderService, resolver)
        {
            Mandate.ParameterNotNull(storeSettingService, "storeSettingService");
            _storeSettingService = storeSettingService;
            TaxApplicationInitialized = false;
        }

        /// <summary>
        /// Gets a value indicating whether product pricing enabled.
        /// </summary>
        public bool ProductPricingEnabled
        {
            get
            {
                return TaxationApplication == TaxationApplication.Product && ProductPricingTaxMethod != null;
            }         
        }

        /// <summary>
        /// Gets or sets the taxation application.
        /// </summary>
        public TaxationApplication TaxationApplication
        {
            get
            {
                if (!TaxApplicationInitialized)
                {
                    this.SetTaxApplicationSetting();
                }
                return _taxationApplication;
            }

            internal set
            {
                _taxationApplication = value;
            }
        }

        /// <summary>
        /// Gets the product pricing tax method.
        /// </summary>
        internal ITaxationByProductMethod ProductPricingTaxMethod
        {
            get
            {
                if (_taxByProductMethod == null && this._taxMethodNotQueried)
                {
                    _taxByProductMethod = this.GetTaxationByProductMethod();
                }
<commit_msg>Publicizes the ITaxationByProductMethod property on the taxation context.<commit_after>﻿namespace Merchello.Core.Gateways.Taxation
{
    using System;
    using System.Linq;

    using Merchello.Core.Models;
    using Merchello.Core.Services;

    using Umbraco.Core;
    using Umbraco.Core.Logging;

    /// <summary>
    /// Represents the TaxationContext
    /// </summary>
    internal class TaxationContext : GatewayProviderTypedContextBase<TaxationGatewayProviderBase>, ITaxationContext
    {
        /// <summary>
        /// The store setting service.
        /// </summary>
        private readonly IStoreSettingService _storeSettingService;

        /// <summary>
        /// The _tax by product method.
        /// </summary>
        private ITaxationByProductMethod _taxByProductMethod;

        /// <summary>
        /// The _tax method not set.
        /// </summary>
        private bool _taxMethodNotQueried = true;

        /// <summary>
        /// The <see cref="TaxationApplication"/>.
        /// </summary>
        private TaxationApplication _taxationApplication;

        /// <summary>
        /// Initializes a new instance of the <see cref="TaxationContext"/> class.
        /// </summary>
        /// <param name="gatewayProviderService">
        /// The gateway provider service.
        /// </param>
        /// <param name="storeSettingService">
        /// The <see cref="IStoreSettingService"/>
        /// </param>
        /// <param name="resolver">
        /// The resolver.
        /// </param>
        public TaxationContext(IGatewayProviderService gatewayProviderService, IStoreSettingService storeSettingService, IGatewayProviderResolver resolver)
            : base(gatewayProviderService, resolver)
        {
            Mandate.ParameterNotNull(storeSettingService, "storeSettingService");
            _storeSettingService = storeSettingService;
            TaxApplicationInitialized = false;
        }

        /// <summary>
        /// Gets a value indicating whether product pricing enabled.
        /// </summary>
        public bool ProductPricingEnabled
        {
            get
            {
                return TaxationApplication == TaxationApplication.Product && ProductPricingTaxMethod != null;
            }         
        }

        /// <summary>
        /// Gets or sets the taxation application.
        /// </summary>
        public TaxationApplication TaxationApplication
        {
            get
            {
                if (!TaxApplicationInitialized)
                {
                    this.SetTaxApplicationSetting();
                }
                return _taxationApplication;
            }

            internal set
            {
                _taxationApplication = value;
            }
        }

        /// <summary>
        /// Gets the product pricing tax method.
        /// </summary>
        public ITaxationByProductMethod ProductPricingTaxMethod
        {
            get
            {
                if (_taxByProductMethod == null && this._taxMethodNotQueried)
                {
                    _taxByProductMethod = this.GetTaxationByProductMethod();
                }

{'fraction_non_alphanumeric': 0.09685114503816794, 'fraction_numerical': 0.0, 'mean_word_length': 1.6236962870254485, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 59, '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': '4260571', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1471, 'n_words': 337}