Пример #1
0
        private static SyncRefsDict getItemsCache <T>()
        {
            SyncRefsDict syncRefsDict;

            if (!cache.TryGetValue(typeof(T), out syncRefsDict))
            {
                syncRefsDict = new SyncRefsDict();
                cache.Add(typeof(T), syncRefsDict);
            }

            return(syncRefsDict);
        }
Пример #2
0
        internal static long GetModelId <T>(object syncRef) where T : CatalogObject
        {
            string strSyncRef = ((syncRef ?? string.Empty) as string).TrimEnd();

            if (string.IsNullOrEmpty(strSyncRef))
            {
                return(0);
            }

            long id;

            SyncRefsDict itemsCache = getItemsCache <T>();

            if (!itemsCache.TryGetValue(strSyncRef, out id))
            {
                id = Convert.ToInt64(BarcodeWorker.GetIdByRef(typeof(T), strSyncRef));
                itemsCache.Add(strSyncRef, id);
            }

            return(id);
        }