예제 #1
0
 private static void MapBack(string nativeId, PsaParameterType type)
 {
     Mnemocode mapBack = MnemocodeToPsaTypeConversionCache.MapBack(type);
     {
         if (mapBack == null)
         {
             if (!UnknownNativeIds.Contains(nativeId))
             {
                 Log.Warn(String.Format("Could not find a mnemocode for native id {0} which is {1}", nativeId, type));
                 UnknownNativeIds.Add(nativeId);
             }
         }
         else
         {
             NativeIdToMnemocodeConversionCache.Set(nativeId, mapBack);
         }
     }
 }
예제 #2
0
        public static PsaParameterType GetType(string nativeId)
        {
            HashSet <Mnemocode> set  = NativeIdToMnemocodeConversionCache.Get(nativeId);
            Mnemocode           code = null;

            if (set != null)
            {
                code = set.FirstOrDefault();
            }
            if (code == null)
            {
                IList <Mnemocode> mnemocodesFromDatabase = null;
                if (!DatabaseMnemocodeResolver.DatabaseReady && !NativeIdsCheckedInDb.Contains(nativeId))
                {
                    PsaParameterType result = DataTypeMapper.GetType(nativeId);
                    return(result);
                }
                NativeIdsCheckedInDb.Add(nativeId);
                if (mnemocodesFromDatabase.Any())
                {
                    code = mnemocodesFromDatabase.First();
                    if (!String.IsNullOrWhiteSpace(code.Code))
                    {
                        NativeIdToMnemocodeConversionCache.Set(nativeId, code);
                    }
                    else
                    {
                        throw new ArgumentException("Wrong mnemocode from database.");
                    }
                }
                PsaParameterType oldMappedType = DataTypeMapper.GetType(nativeId);
                if (oldMappedType == PsaParameterType.Unsupported)
                {
                    ReportUnknownNativeId(nativeId);
                    return(oldMappedType);
                }
                foreach (Mnemocode dbmc in mnemocodesFromDatabase)
                {
                    MnemocodeToPsaTypeConversionCache.Add(dbmc, oldMappedType);
                }
                if (code == null && oldMappedType != PsaParameterType.Unsupported)
                {
                    Mnemocode mapBack = MnemocodeToPsaTypeConversionCache.MapBack(oldMappedType);
                    {
                        if (mapBack == null)
                        {
                            if (!UnknownNativeIds.Contains(nativeId))
                            {
                                Log.Warn(String.Format("Could not find a mnemocode for native id {0} which is {1}", nativeId, oldMappedType));
                                UnknownNativeIds.Add(nativeId);
                            }
                        }
                        else
                        {
                            NativeIdToMnemocodeConversionCache.Set(nativeId, mapBack);
                        }
                    }
                    return(oldMappedType);
                }
            }
            PsaParameterType type = MnemocodeToPsaTypeConversionCache.Get(code);

            if (type == PsaParameterType.Unsupported)
            {
                type = DataTypeMapper.GetType(nativeId);
                if (type != PsaParameterType.Unsupported)
                {
                    MnemocodeToPsaTypeConversionCache.Add(code, type);
                }
            }
            if (type == PsaParameterType.Unsupported)
            {
                ReportUnknownNativeId(nativeId);
            }
            return(type);
        }