Exemplo n.º 1
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="arg">
        /// The pipeline argument.
        /// </param>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <returns>
        /// The <see cref="PipelineArgument"/>.
        /// </returns>
        public async override Task <LocalizedTerm> Run(LocalizedTerm arg, CommercePipelineExecutionContext context)
        {
            if (arg != null)
            {
                return(arg); // Return the argument we retrieved from the cache
            }

            LocalizedProductFeaturesConfigurationArgument argument = context.CommerceContext.GetObjects <LocalizedProductFeaturesConfigurationArgument>().FirstOrDefault <LocalizedProductFeaturesConfigurationArgument>();

            if (string.IsNullOrEmpty(argument?.LocalizationKey))
            {
                return(arg);
            }

            var policy = context.GetPolicy <ProductFeaturesControlPanelPolicy>();

            string currentLanguage = context.CommerceContext.CurrentLanguage();

            ILocalizableTermsPipeline localizableTermsPipeline = this.Commander.Pipeline <ILocalizableTermsPipeline>();
            LocalizableTermArgument   localizableTermArgument  = new LocalizableTermArgument(string.Empty, policy.ProductFeaturesNamesPath);

            localizableTermArgument.Language = currentLanguage;

            return((await localizableTermsPipeline.Run(localizableTermArgument, context)).FirstOrDefault <LocalizedTerm>(t => t.Key.Equals(argument.LocalizationKey, StringComparison.OrdinalIgnoreCase)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="arg">
        /// The pipeline argument.
        /// </param>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <returns>
        /// The <see cref="PipelineArgument"/>.
        /// </returns>
        public async override Task <IEnumerable <LocalizedTerm> > Run(IEnumerable <LocalizedTerm> arg, CommercePipelineExecutionContext context)
        {
            if (arg != null)
            {
                return(arg); // Return the argument we retrieved from the cache
            }

            var policy = context.GetPolicy <ProductFeaturesControlPanelPolicy>();

            string currentLanguage = context.CommerceContext.CurrentLanguage();

            ILocalizableTermsPipeline localizableTermsPipeline = this.Commander.Pipeline <ILocalizableTermsPipeline>();
            LocalizableTermArgument   localizableTermArgument  = new LocalizableTermArgument(string.Empty, policy.AvailableProductFeaturesPath);

            localizableTermArgument.Language = currentLanguage;

            return(await localizableTermsPipeline.Run(localizableTermArgument, context));
        }