Esempio n. 1
0
 static public Geography FromCache(int geographyId)
 {
     lock (loadCacheLock)
     {
         return(Geography.FromBasic(GeographyCache.GetGeography(geographyId)));
     }
 }
Esempio n. 2
0
        static public BasicGeography[] GetGeographyLine(int leafGeographyId)
        {
            List <BasicGeography> result = new List <BasicGeography>();


            BasicGeography currentNode = GeographyCache.GetGeography(leafGeographyId);

            // This iterates until the zero-parentid root node is found

            while (currentNode.GeographyId != 0)
            {
                result.Add(currentNode);

                if (currentNode.ParentGeographyId != 0)
                {
                    currentNode = GeographyCache.GetGeography(currentNode.ParentGeographyId);
                }
                else
                {
                    currentNode = new BasicGeography(0, 0, string.Empty);
                }
            }

            result.Reverse();

            return(result.ToArray());
        }
Esempio n. 3
0
        public static int CountGeographyChildren(int parentGeographyId)
        {
            lock (loadCacheLock)
            {
                // Prime the cache
                BasicGeography partent = GeographyCache.GetGeography(parentGeographyId);

                return(GetHashedGeographies()[parentGeographyId].Count - 1);
            }
        }
Esempio n. 4
0
        static public BasicGeography[] GetGeographies(int[] ids)
        {
            List <BasicGeography> result = new List <BasicGeography>();

            lock (loadCacheLock)
            {
                foreach (int i in ids)
                {
                    result.Add(GeographyCache.GetGeography(i));
                }
                return(result.ToArray());
            }
        }
Esempio n. 5
0
        static public BasicGeography[] GetGeographyChildren(int parentGeographyId)
        {
            List <BasicGeography> result = new List <BasicGeography>();

            lock (loadCacheLock)
            {
                // Prime the cache
                BasicGeography partent = GeographyCache.GetGeography(parentGeographyId);

                //TODO: Possible to miss a child geography here if it was added since last cache reload.

                Dictionary <int, List <BasicGeography> > hashedGeographies = GetHashedGeographies();
                foreach (BasicGeography b in hashedGeographies[parentGeographyId])
                {
                    if (b.Identity != parentGeographyId)
                    {
                        result.Add(b);
                    }
                }
                return(result.ToArray());
            }
        }