示例#1
0
        public void Setup(PolyCacheConfig config)
        {
            // Create all the buffer holders. They are all initially idle.
            for (int i = 0; i < MAX_CONCURRENT_DOWNLOADS; i++)
            {
                idleBuffers.Add(new BufferHolder());
            }

            // Caching is only supported on Windows/Mac for now.
            bool cacheSupported = Application.platform == RuntimePlatform.WindowsEditor ||
                                  Application.platform == RuntimePlatform.WindowsPlayer ||
                                  Application.platform == RuntimePlatform.OSXEditor ||
                                  Application.platform == RuntimePlatform.OSXPlayer;

            PtDebug.LogFormat("Platform: {0}, cache supported: {1}", Application.platform, cacheSupported);

            if (cacheSupported && config.cacheEnabled)
            {
                //string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                //string defaultCachePath = Path.Combine(Path.Combine(Path.Combine(
                //  appDataPath, Application.companyName), Application.productName), "WebRequestCache");
                string defaultCachePath = Path.Combine(Application.persistentDataPath, "WebRequestCache");

                string cachePath = config.cachePathOverride;
                if (string.IsNullOrEmpty(cachePath))
                {
                    cachePath = defaultCachePath;
                }
                // Note: Directory.CreateDirectory creates all directories in the path.
                Directory.CreateDirectory(cachePath);

                cache = gameObject.AddComponent <PersistentBlobCache>();
                cache.Setup(cachePath, config.maxCacheEntries, config.maxCacheSizeMb * 1024 * 1024);
            }
        }
        public LocalDictionary(string databasePath)
        {
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                Converters = new List <JsonConverter>()
                {
                    new BasicsConverter(),
                    new DateTimeConverter(),
                    new EntityCollectionConverter(),
                    new EntityConverter(),
                    new EntityReferenceConverter(),
                    new GuidConverter(),
                    new MoneyConverter(),
                    new OptionSetConverter()
                }
            };

            cache = new PersistentBlobCache(databasePath);
        }