Esempio n. 1
0
        public static FactsPartsDictionary GetFactsOfParts(Taxonomy taxonomy)
        {
            var instance = new FactsPartsDictionary();

            instance.DeSerializeItems = (lines) => {
                var values = new IntervalList();
                foreach (var line in lines)
                {
                    values.AddInterval(Interval.GetInstanceFromString(line));
                }
                values.TrimExcess();

                return(values);
            };
            instance.SerializeItem = (itemcontainer) =>
            {
                var sb = new StringBuilder();
                foreach (var item in itemcontainer.Intervals)
                {
                    sb.AppendLine(item.Content());
                }
                return(sb);
            };
            instance.Folder            = () => taxonomy.TaxonomyFactsFolder;
            instance.FileSearchPattern = "FactsOfParts_*.dat";
            instance.GetKey            = (file) =>
            {
                return(Utilities.Converters.FastParse(Utilities.Strings.TextBetween(file, "FactsOfParts_", ".dat")));
            };

            return(instance);
        }
Esempio n. 2
0
        public void MoveTo(FactsPartsDictionary target)
        {
            foreach (var item in this)
            {
                //if (item.Key == 11529)
                //{

                //}
                if (!target.ContainsKey(item.Key))
                {
                    target.Add(item.Key, new IntervalList());
                }
                var targetitem = target[item.Key];
                //IntervalList t = targetitem.Copy();
                //t.AddRange(this[item.Key]);
                //if (!t.IsConsistent())
                //{

                //}

                //var ct = targetitem.Count;
                //var cs = this[item.Key].Count;
                //if (item.Key == 4179)
                //{
                //}
                targetitem.AddRange(this[item.Key]);
                //if (item.Key == 4179)
                //{

                //    if (targetitem.Count != cs + ct)
                //    {

                //    }
                //}
                //target[item.Key] = target[item.Key].Distinct().ToList();

                targetitem.TrimExcess();
                this[item.Key].Clear();
            }
        }