Пример #1
0
        public virtual void AddPreGarment(Garment garment)
        {
            int pos = OutfitValidationService.GetClosetOutfitPosition(garment);

            PropertyInfo pi = new PreCombination().GetType().GetProperty(string.Format("Garment{0}", pos + 1));

            pi.SetValue(this, garment.PreGarment, null);
        }
Пример #2
0
        public virtual void AddComponent(Garment garment, Garment hack)
        {
            int pos = OutfitValidationService.GetClosetOutfitPosition(garment);

            PropertyInfo pi = this.GetType().GetProperty(string.Format("Garment{0}", pos + 1));

            pi.SetValue(this, garment, null);

            for (int i = 0; i <= 12; i++)
            {
                pi = this.GetType().GetProperty(string.Format("Garment{0}", i + 1));
                if (pi.GetValue(this, null) == null)
                {
                    pi.SetValue(this, hack, null);
                }
            }
        }
Пример #3
0
        public void SaveToFile(IEnumerable <PreOutfit> currentOutfits)
        {
            int i = 0;

            var sb = new StringBuilder(lineSize * 200000, maxLineSize * maxRecords);

            foreach (PreOutfit po in currentOutfits)
            {
                Combination pc = po.Combination;

                var lb = new StringBuilder(lineSize, maxLineSize);

                // Add Closet & Flavor
                lb.Append(Closet.Id);
                lb.Append(",");
                lb.Append(pc.FashionFlavor.Id);

                int used = 2;

                // Let's setup in the correct order to avoid duplicates.
                var arrItems = new Garment[13];
                foreach (Garment g in po.ToList())
                {
                    // Always use first silouhette to position
                    int pos = OutfitValidationService.GetClosetOutfitPosition(g);
                    arrItems[pos] = g;
                }

                foreach (Garment g in arrItems)
                {
                    if (g != null)
                    {
                        lb.Append(",");
                        lb.Append(g.Id);
                        lb.Append(",");
                        lb.Append(g.PreGarment.Id);
                        used++;
                    }
                    else
                    {
                        lb.Append(",");
                        lb.Append(@"0");
                        lb.Append(",");
                        lb.Append(@"0");
                    }
                }

                lb.Append(",");
                lb.Append(po.Seasons.ToString());
                lb.Append(",");
                lb.Append(po.EventTypes.ToString());
                lb.Append(",");
                lb.Append(pc.EditorRating);

                sb.AppendLine(lb.ToString());

                i++;
                if (i == 200000)
                {
                    File.AppendAllText(Path.Combine(SharePath, fileName), sb.ToString());
                    sb = null;

                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    sb = new StringBuilder(lineSize * maxRecords, maxLineSize * maxRecords);
                    i  = 0;
                }
            }

            if (i > 0)
            {
                File.AppendAllText(Path.Combine(SharePath, fileName), sb.ToString());
                sb = null;

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }