private void SaveTypesCache(List <AssemblyInfo> cachedTypesInfo)
        {
            SubscribedTypesCache root = null;

            if (cachedTypesInfo.Count > 0)
            {
                root = new SubscribedTypesCache {
                    Assemblies = cachedTypesInfo.ToArray()
                };
            }

            try
            {
                if (root == null)
                {
                    File.Delete(CacheFilePath);
                }
                else
                {
                    if (!C1Directory.Exists(CacheDirectoryPath))
                    {
                        C1Directory.CreateDirectory(CacheDirectoryPath);
                    }

                    using (var fileStream = File.Open(CacheFilePath, FileMode.Create))
                    {
                        GetSerializer().Serialize(fileStream, root);
                    }
                }
            }
            catch (UnauthorizedAccessException)
            {
                Log.LogWarning(LogTitle, "Failed to open file '{0}'".FormatWith(CacheFilePath));
            }
        }
Exemple #2
0
        private void SaveTypesCache(List <AssemblyInfo> cachedTypesInfo)
        {
            SubscribedTypesCache root = null;

            if (cachedTypesInfo.Count > 0)
            {
                root = new SubscribedTypesCache {
                    Assemblies = cachedTypesInfo.ToArray()
                };
            }

            try
            {
                if (root == null)
                {
                    File.Delete(CacheFilePath);
                }
                else
                {
                    if (!C1Directory.Exists(CacheDirectoryPath))
                    {
                        C1Directory.CreateDirectory(CacheDirectoryPath);
                    }

                    using (var fileStream = File.Open(CacheFilePath, FileMode.Create))
                    {
                        GetSerializer().Serialize(fileStream, root);
                    }
                }
            }
            catch (Exception)
            {
                Log.LogWarning(LogTitle, $"Failed to open file '{CacheFilePath}' for writing - this may lead to slower start up times, if this issue persist. In that case, check that this file is accessible to the web application for writes.");
            }
        }
        private void SaveTypesCache(List<AssemblyInfo> cachedTypesInfo)
        {
            SubscribedTypesCache root = null;

            if(cachedTypesInfo.Count > 0)
            {
                root = new SubscribedTypesCache {Assemblies = cachedTypesInfo.ToArray()};
            }

            try
            {
                if(root == null)
                {
                    File.Delete(CacheFilePath);
                }
                else
                {
                    if (!C1Directory.Exists(CacheDirectoryPath))
                    {
                        C1Directory.CreateDirectory(CacheDirectoryPath);
                    }

                    using (var fileStream = File.Open(CacheFilePath, FileMode.Create))
                    {
                        GetSerializer().Serialize(fileStream, root);
                    }
                }
            }
            catch (UnauthorizedAccessException)
            {
                Log.LogWarning(LogTitle, "Failed to open file '{0}'".FormatWith(CacheFilePath));
            }
        }