コード例 #1
0
ファイル: Cache.cs プロジェクト: Hogan2/MyMap00
        public Cache()
        {
            #region singleton check
            if (Instance != null)
            {
                throw (new System.Exception("You have tried to create a new singleton class where you should have instanced it. Replace your \"new class()\" with \"class.Instance\""));
            }
            #endregion


            ImageCache = new SQLitePureImageCache();



            {
#if PocketPC
                CacheLocation = CacheLocator.Location;
#else
                string newCache = CacheLocator.Location;

                string oldCache = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + "GMap.NET" + Path.DirectorySeparatorChar;

                // move database to non-roaming user directory
                if (Directory.Exists(oldCache))
                {
                    try
                    {
                        if (Directory.Exists(newCache))
                        {
                            Directory.Delete(oldCache, true);
                        }
                        else
                        {
                            Directory.Move(oldCache, newCache);
                        }
                        CacheLocation = newCache;
                    }
                    catch (Exception ex)
                    {
                        CacheLocation = oldCache;
                        Trace.WriteLine("SQLitePureImageCache, moving data: " + ex.ToString());
                    }
                }
                else
                {
                    CacheLocation = newCache;
                }
#endif
            }
        }
コード例 #2
0
        public Cache()
        {
            #region singleton check
            if (Instance != null)
            {
                throw (new System.Exception("You have tried to create a new singleton class where you should have instanced it. Replace your \"new class()\" with \"class.Instance\""));
            }
            #endregion

#if SQLite
            ImageCache = new SQLitePureImageCache();
#else
            // you can use $ms stuff if you like too ;}
            ImageCache = new MsSQLCePureImageCache();
#endif

#if PocketPC
            // use sd card if exist for cache
            string sd = Native.GetRemovableStorageDirectory();
            if (!string.IsNullOrEmpty(sd))
            {
                CacheLocation = sd + Path.DirectorySeparatorChar + "GMap.NET" + Path.DirectorySeparatorChar;
            }
            else
#endif
            {
#if PocketPC
                CacheLocation = CacheLocator.Location;
#else
                string newCache = CacheLocator.Location;

                string oldCache = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + "GMap.NET" + Path.DirectorySeparatorChar;

                // move database to non-roaming user directory
                if (Directory.Exists(oldCache))
                {
                    try
                    {
                        if (Directory.Exists(newCache))
                        {
                            Directory.Delete(oldCache, true);
                        }
                        else
                        {
                            Directory.Move(oldCache, newCache);
                        }
                        CacheLocation = newCache;
                    }
                    catch (Exception ex)
                    {
                        CacheLocation = oldCache;
                        Trace.WriteLine("SQLitePureImageCache, moving data: " + ex.ToString());
                    }
                }
                else
                {
                    CacheLocation = newCache;
                }
#endif
            }
        }