Esempio n. 1
0
        public static List<GeneradorDeNumero> GenerarComplementos(List<int> excluidos)
        {
            var posibles = digitos.Except(excluidos);

            var variaciones = new Variations<int>(posibles, 4);
            return variaciones.Select(variacion => new GeneradorDeNumero(variacion[0], variacion[1], variacion[2], variacion[3], excluidos.Union(variacion).ToList())).ToList();
        }
Esempio n. 2
0
        private static List <long> ApplyMaskToAddress(string mask, int address)
        {
            var binaryValue     = Convert.ToString(address, 2);
            var fullBinaryValue = Enumerable.Repeat('0', mask.Length - binaryValue.Length)
                                  .Concat(binaryValue);

            var maskedValue = mask.Zip(fullBinaryValue, (c1, c2) => c1 == '0' ? c2 : c1)
                              .ToArray();

            var maskedValueString = new string(maskedValue);

            var variations = new Variations <char>(
                new char[] { '0', '1' },
                maskedValue.Count(c => c == 'X'),
                GenerateOption.WithRepetition
                );

            return(variations.Select(variation =>
            {
                var copy = string.Copy(maskedValueString).Split('X');

                int length = Math.Min(copy.Count(), variation.Count());

                var parts = copy.Take(length)
                            .Zip(variation.Take(length), (a, b) => new string[] { a, b.ToString() })
                            .SelectMany(x => x)
                            .Concat(copy.Skip(length))
                            .ToArray();

                var binaryString = string.Concat(parts);
                return Convert.ToInt64(binaryString, 2);
            })
                   .ToList());
        }
        public virtual object Clone()
        {
            var result = MemberwiseClone() as ProductPromoEntry;

            result.Variations = Variations?.Select(x => x.Clone()).OfType <ProductPromoEntry>().ToList();
            result.Attributes = new Dictionary <string, string>(Attributes);
            return(result);
        }
Esempio n. 4
0
        public static List <GeneradorDeNumero> GenerarComplementos(List <int> excluidos)
        {
            var posibles = digitos.Except(excluidos);

            var variaciones = new Variations <int>(posibles, 4);

            return(variaciones.Select(variacion => new GeneradorDeNumero(variacion[0], variacion[1], variacion[2], variacion[3], excluidos.Union(variacion).ToList())).ToList());
        }
Esempio n. 5
0
        public IList <GeneradorDeNumero> ObtenerPosibles(IEnumerable <GeneradorDeNumero> noPermitidos)
        {
            var posiblesValores = digitos.Except(DigitosExcluidos).ToList();
            var todoBien        = posiblesValores.Count >= CantidadDeNulls;
            IList <GeneradorDeNumero> posibles = new List <GeneradorDeNumero>();

            if (todoBien)
            {
                var variaciones = new Variations <int>(posiblesValores, CantidadDeNulls);
                var todos       = variaciones.Select(GenerarNumero).ToList();
                posibles = todos.Except(noPermitidos).ToList();
            }

            return(posibles);
        }
Esempio n. 6
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as CatalogProduct;

            result.SeoInfos               = SeoInfos?.Select(x => x.Clone()).OfType <SeoInfo>().ToList();
            result.Images                 = Images?.Select(x => x.Clone()).OfType <Image>().ToList();
            result.Assets                 = Assets?.Select(x => x.Clone()).OfType <Asset>().ToList();
            result.Properties             = Properties?.Select(x => x.Clone()).OfType <Property>().ToList();
            result.Associations           = Associations?.Select(x => x.Clone()).OfType <ProductAssociation>().ToList();
            result.ReferencedAssociations = ReferencedAssociations?.Select(x => x.Clone()).OfType <ProductAssociation>().ToList();
            result.Reviews                = Reviews?.Select(x => x.Clone()).OfType <EditorialReview>().ToList();
            result.Links      = Links?.Select(x => x.Clone()).OfType <CategoryLink>().ToList();
            result.Variations = Variations?.Select(x => x.Clone()).OfType <Variation>().ToList();

            return(result);
        }
Esempio n. 7
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as CatalogProduct;

            // result.Catalog = (Catalog)Catalog?.Clone(); // Intentionally temporary disabled due to memory overhead
            // result.Category = (Category)Category?.Clone(); // Intentionally temporary disabled due to memory overhead
            result.SeoInfos               = SeoInfos?.Select(x => x.Clone()).OfType <SeoInfo>().ToList();
            result.Images                 = Images?.Select(x => x.Clone()).OfType <Image>().ToList();
            result.Assets                 = Assets?.Select(x => x.Clone()).OfType <Asset>().ToList();
            result.Properties             = Properties?.Select(x => x.Clone()).OfType <Property>().ToList();
            result.Associations           = Associations?.Select(x => x.Clone()).OfType <ProductAssociation>().ToList();
            result.ReferencedAssociations = ReferencedAssociations?.Select(x => x.Clone()).OfType <ProductAssociation>().ToList();
            result.Reviews                = Reviews?.Select(x => x.Clone()).OfType <EditorialReview>().ToList();
            result.Links      = Links?.Select(x => x.Clone()).OfType <CategoryLink>().ToList();
            result.Variations = Variations?.Select(x => x.Clone()).OfType <Variation>().ToList();
            // result.Outlines = Outlines?.Select(x => x.Clone()).OfType<Outline>().ToList(); // Intentionally temporary disabled due to memory overhead

            return(result);
        }
Esempio n. 8
0
        public virtual object Clone()
        {
            var result = base.MemberwiseClone() as CatalogProduct;

            if (SeoInfos != null)
            {
                result.SeoInfos = SeoInfos.Select(x => x.Clone()).OfType <SeoInfo>().ToList();
            }
            if (Images != null)
            {
                result.Images = Images.Select(x => x.Clone()).OfType <Image>().ToList();
            }
            if (Assets != null)
            {
                result.Assets = Assets.Select(x => x.Clone()).OfType <Asset>().ToList();
            }
            if (Properties != null)
            {
                result.Properties = Properties.Select(x => x.Clone()).OfType <Property>().ToList();
            }
            if (Associations != null)
            {
                result.Associations = Associations.Select(x => x.Clone()).OfType <ProductAssociation>().ToList();
            }
            if (ReferencedAssociations != null)
            {
                result.ReferencedAssociations = ReferencedAssociations.Select(x => x.Clone()).OfType <ProductAssociation>().ToList();
            }
            if (Reviews != null)
            {
                result.Reviews = Reviews.Select(x => x.Clone()).OfType <EditorialReview>().ToList();
            }
            if (Links != null)
            {
                result.Links = Links.Select(x => x.Clone()).OfType <CategoryLink>().ToList();
            }
            if (Variations != null)
            {
                result.Variations = Variations.Select(x => x.Clone()).OfType <Variation>().ToList();
            }
            return(result);
        }
Esempio n. 9
0
        public virtual object GetCopy()
        {
            var result = Clone() as CatalogProduct;

            result.Id = null;

            result.Images     = Images?.Select(x => x.GetCopy()).OfType <Image>().ToList();
            result.Assets     = Assets?.Select(x => x.GetCopy()).OfType <Asset>().ToList();
            result.Properties = Properties?.Select(x => x.GetCopy()).OfType <Property>().ToList();
            result.Variations = Variations?.Select(x => x.GetCopy()).OfType <Variation>().ToList();
            result.Reviews    = Reviews?.Select(x => x.GetCopy()).OfType <EditorialReview>().ToList();
            // Clear ID for all related entities except properties
            var allSeoSupportEntities = result.GetFlatObjectsListWithInterface <ISeoSupport>();

            foreach (var seoSuportEntity in allSeoSupportEntities)
            {
                seoSuportEntity.SeoInfos?.Clear();
            }
            return(result);
        }
Esempio n. 10
0
        public IList<GeneradorDeNumero> ObtenerPosibles(IEnumerable<GeneradorDeNumero> noPermitidos)
        {
            var posiblesValores = digitos.Except(DigitosExcluidos).ToList();
            var todoBien = posiblesValores.Count >= CantidadDeNulls;
            IList<GeneradorDeNumero> posibles = new List<GeneradorDeNumero>();
            if (todoBien)
            {
                var variaciones = new Variations<int>(posiblesValores, CantidadDeNulls);
                var todos = variaciones.Select(GenerarNumero).ToList();
                posibles = todos.Except(noPermitidos).ToList();
            }

            return posibles;
        }