Пример #1
0
        protected override IDictionary <string, string> GetFSizes(ISizeChart sizeChart, string originalSize)
        {
            var originalSizeFormated = originalSize.Replace(" ", "");

            if (originalSizeFormated.HasPrefix())
            {
                return(null);
            }

            var originalSizeFormatedUs  = originalSizeFormated.AddUsPrefix();
            var originalSizeFormatedUk  = originalSizeFormated.AddUkPrefix();
            var originalSizeFormatedEur = originalSizeFormated.AddEurPrefix();

            var cacheKey = $"{nameof(SizeChartConverter2)}_{originalSizeFormated}_{sizeChart.Name}";

            var formatedSizes = new List <string>();

            var result = Cache.GetOrCreate(cacheKey, cacheEntry =>
            {
                int i = 0;
                IDictionary <string, string> dict = null;
                if (sizeChart.ContainsSize(originalSizeFormatedEur, ref dict))
                {
                    i++;
                }
                if (sizeChart.ContainsSize(originalSizeFormatedUk, ref dict))
                {
                    i++;
                }
                if (i == 2)
                {
                    //нет смысла дальше искать в таблице есть размер, как с префиксом eur так и с uk, непонятно какой брать
                    return(null);
                }

                if (sizeChart.ContainsSize(originalSizeFormatedUs, ref dict))
                {
                    i++;
                }

                if (i == 2)
                {
                    //в таблице есть размер, c разными префиксами , непонятно какой брать
                    return(null);
                }

                return(dict);
            });

            return(result);
        }
Пример #2
0
        protected virtual IDictionary <string, string> GetFSizes(ISizeChart sizeChart, string originalSize)
        {
            var originalSizeFormated = originalSize.Replace(" ", "");
            var cacheKey             = $"{nameof(SizeChartConverter)}_{originalSizeFormated}_{sizeChart.Name}";
            var result = Cache.GetOrCreate(cacheKey, cacheEntry =>
            {
                IDictionary <string, string> szDictionary = null;
                if (sizeChart.ContainsSize(originalSizeFormated, ref szDictionary))
                {
                    return(szDictionary);
                }
                return(null);
            });

            return(result);
        }