Ejemplo n.º 1
0
 public TESVSnip.Data.RecordsRecord ProcessBase(Record r)
 {
     TESVSnip.Data.RecordsRecord rr;
     if (!rdict.TryGetValue(r.Name, out rr))
     {
         rr      = new TESVSnip.Data.RecordsRecord();
         rr.name = r.Name;
         rr.desc = r.Name;
         rdict.Add(r.Name, rr);
     }
     return(rr);
 }
Ejemplo n.º 2
0
        public bool Process(Record p)
        {
            TESVSnip.Data.RecordsRecord rr = ProcessBase(p);

            // int srIdx = 0;
            var groups = from psr in p.SubRecords
                         group psr by psr.Name into g
                         select new { Name = g.Key, Records = g.ToArray() };

            int lastIndex = 0;
            Dictionary <string, TESVSnip.Data.Subrecord> dict = new Dictionary <string, TESVSnip.Data.Subrecord>();

            foreach (var kvp in groups)
            {
                if (IsCanceled)
                {
                    return(false);
                }

                TESVSnip.Data.Subrecord sr = rr.Subrecords.FirstOrDefault(x => x.name == kvp.Name);
                if (sr == null)
                {
                    sr          = new TESVSnip.Data.Subrecord();
                    sr.name     = sr.desc = kvp.Name;
                    sr.optional = 1;
                    if (lastIndex + 1 <= rr.Items.Count)
                    {
                        rr.Items.Insert(++lastIndex, sr);
                    }
                    else
                    {
                        rr.Items.Add(sr);
                    }
                }
                else
                {
                    lastIndex = rr.Items.IndexOf(sr, lastIndex);
                    if (lastIndex < 0)  // out of order
                    {
                        lastIndex = rr.Items.IndexOf(sr);
                    }
                }
                int n = kvp.Records.Length;
                if (n > 0)
                {
                    if (sr.repeat == 0 && n > 1)
                    {
                        sr.optional = sr.repeat = 1;
                    }
                    int idx1 = p.SubRecords.IndexOf(kvp.Records[0]);
                    int idx2 = idx1;
                    for (int i = 1; i < n; ++i, idx1 = idx2)
                    {
                        idx2 = p.SubRecords.IndexOf(kvp.Records[i]);
                        int diff = (idx2 - idx1);
                        if (diff > sr.repeat)
                        {
                            if (diff < 10)
                            {
                                sr.optional = sr.repeat = diff;
                            }
                            else
                            {
                                sr.optional = sr.repeat;
                            }
                        }
                    }
                }
                foreach (var subrec in kvp.Records)
                {
                    if (IsCanceled)
                    {
                        break;
                    }
                    Process(sr, subrec);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
 public TESVSnip.Data.RecordsRecord ProcessBase(Record r)
 {
     TESVSnip.Data.RecordsRecord rr;
     if (!rdict.TryGetValue(r.Name, out rr))
     {
         rr = new TESVSnip.Data.RecordsRecord();
         rr.name = r.Name;
         rr.desc = r.Name;
         rdict.Add(r.Name, rr);
     }
     return rr;
 }