예제 #1
0
        /// <summary>
        /// parses the relevant data from each mapper pairs object
        /// </summary>
        public static List <DataStructures.VEP.MapperPair> ParseList(List <AbstractData> abstractDataList, ImportDataStore dataStore)
        {
            var mapperPairs = DumperUtilities.GetPopulatedList <DataStructures.VEP.MapperPair>(abstractDataList.Count);

            // loop over all of the key/value pairs in the mapper pairs object
            for (int mapperPairIndex = 0; mapperPairIndex < abstractDataList.Count; mapperPairIndex++)
            {
                var ad = abstractDataList[mapperPairIndex];

                // skip references
                if (DumperUtilities.IsReference(ad))
                {
                    continue;
                }

                if (ad.DataType != DataType)
                {
                    throw new GeneralException(
                              $"Expected a mapper pair data type, but found the following data type: [{ad.DataType}]");
                }

                var mapperPairNode = ad as ObjectValue;
                if (mapperPairNode == null)
                {
                    throw new GeneralException(
                              $"Could not transform the AbstractData object into an ObjectValue: [{ad.GetType()}]");
                }

                var newMapperPair = Parse(mapperPairNode, dataStore.CurrentReferenceIndex);
                // DS.VEP.MapperPair oldMapperPair;
                // if (dataStore.MapperPairs.TryGetValue(newMapperPair, out oldMapperPair))
                //{
                //    mapperPairs[mapperPairIndex] = oldMapperPair;
                //}
                // else
                //{
                mapperPairs[mapperPairIndex] = newMapperPair;
                //    dataStore.MapperPairs[newMapperPair] = newMapperPair;
                //}
            }

            return(mapperPairs);
        }