예제 #1
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

            ImageCache = new SQLitePureImageCache();
            //ImageCacheSecond = new HttpPureImageCache("http://127.0.0.1:7777");
        }
예제 #2
0
        public Cache()
        {
            #region singleton check

            if (Instance != null)
            {
                throw new 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

            {
                string newCache = CacheLocator.Location;

                string oldCache = Environment.GetFolderPath(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;
                }
            }
        }
예제 #3
0
파일: Cache.cs 프로젝트: culiniac/quavs
        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 (string.IsNullOrEmpty(CacheLocation))
            {
#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
                {
                    string oldCache = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + "GMap.NET" + Path.DirectorySeparatorChar;
#if PocketPC
                    CacheLocation = oldCache;
#else
                    string newCache = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "GMap.NET" + Path.DirectorySeparatorChar;

                    // move database to non-roaming user directory
                    try
                    {
                        //changed to avoid exceptions
                        if (Directory.Exists(oldCache) & !Directory.Exists(newCache))
                        {
                            Directory.Move(oldCache, newCache);
                        }
                        CacheLocation = newCache;
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine("SQLitePureImageCache, moving data: " + ex.ToString());
                        CacheLocation = oldCache;
                    }
#endif
                }
            }
        }
예제 #4
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
#endif

            if (string.IsNullOrEmpty(CacheLocation))
            {
                {
                    string oldCache = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "MapTile" + Path.DirectorySeparatorChar;
                    string newCache = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "MapTile" + 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;
                    //}
                }
            }
        }
예제 #5
0
        private Cache()
        {
#if SQLite
            ImageCache = new SQLitePureImageCache();
#else
            // you can use $ms stuff if you like too ;}
            ImageCache = new MsSQLCePureImageCache();
#endif

            {
                string newCache = CacheLocator.Location;

                string oldCache = Environment.GetFolderPath(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;
                }
            }
        }