コード例 #1
0
ファイル: ContentMgr.cs プロジェクト: uvbs/Asda2-Server
 public static void Load(LightDBMapper mapper, bool failException)
 {
     try
     {
         if (ContentMgr.EnableCaching && mapper.SupportsCaching && mapper.LoadCache())
         {
             return;
         }
         mapper.Fetch();
         if (!ContentMgr.EnableCaching || !mapper.SupportsCaching)
         {
             return;
         }
         ContentMgr.log.Info("Saving cache for: " +
                             ((IEnumerable <DataHolderDefinition>)mapper.Mapping.DataHolderDefinitions)
                             .ToString <DataHolderDefinition>(", "));
         mapper.SaveCache();
     }
     catch (Exception ex)
     {
         if (failException)
         {
             throw new ContentException(ex, "Unable to load entries using \"{0}\"", new object[1]
             {
                 (object)mapper
             });
         }
     }
 }
コード例 #2
0
ファイル: ContentMgr.cs プロジェクト: 0xFh/Asda2-Project
 public static void Load(LightDBMapper mapper, bool failException)
 {
     try
     {
         if (EnableCaching && mapper.SupportsCaching && mapper.LoadCache())
         {
             return;
         }
         mapper.Fetch();
         if (!EnableCaching || !mapper.SupportsCaching)
         {
             return;
         }
         log.Info("Saving cache for: " +
                  mapper.Mapping.DataHolderDefinitions
                  .ToString(", "));
         mapper.SaveCache();
     }
     catch (Exception ex)
     {
         if (failException)
         {
             throw new ContentException(ex, "Unable to load entries using \"{0}\"", (object)mapper);
         }
     }
 }
コード例 #3
0
ファイル: ContentMgr.cs プロジェクト: NecroSharper/WCell
        public static void Load(LightDBMapper mapper, bool failException)
        {
            try
            {
                if (EnableCaching && mapper.SupportsCaching)
                {
                    if (mapper.LoadCache())
                    {
                        // loaded cache successfully
                        return;
                    }
                }

                //Utility.Measure("Loading content from DB - " + mapper + "", 1, () => {
                mapper.Fetch();
                //});

                if (EnableCaching && mapper.SupportsCaching)
                {
                    log.Info("Saving cache for: " + mapper.Mapping.DataHolderDefinitions.ToString(", "));
                    mapper.SaveCache();
                }
            }
            catch (Exception e)
            {
                if (failException)
                {
                    throw new ContentException(e, "Unable to load entries using \"{0}\"", mapper);
                }
                // LogUtil.ErrorException(e, "Unable to load entries using \"{0}\"", mapper);
            }
        }
コード例 #4
0
ファイル: ContentMgr.cs プロジェクト: uvbs/Asda2-Server
        public static void SaveCache(this LightDBMapper mapper)
        {
            string cacheFilename = mapper.GetCacheFilename();

            try
            {
                mapper.SaveCache(cacheFilename);
            }
            catch (Exception ex)
            {
                File.Delete(cacheFilename);
                LogUtil.ErrorException(ex, "Failed to save cache to file: " + cacheFilename, new object[0]);
            }
        }
コード例 #5
0
ファイル: ContentMgr.cs プロジェクト: NecroSharper/WCell
        public static void SaveCache(this LightDBMapper mapper)
        {
            // save cache after loading
            var file = GetCacheFilename(mapper);

            try
            {
                mapper.SaveCache(file);
            }
            catch (Exception e)
            {
                File.Delete(file);
                LogUtil.ErrorException(e, "Failed to save cache to file: " + file);
            }
        }