mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
csharp: added format caching
This commit is contained in:
@ -50,6 +50,8 @@ namespace OnlineEditorsExample
|
||||
|
||||
public class FormatManager
|
||||
{
|
||||
private static List<Format> cachedFormats;
|
||||
|
||||
public static List<string> FillableExtensions()
|
||||
{
|
||||
return Fillable()
|
||||
@ -159,11 +161,15 @@ namespace OnlineEditorsExample
|
||||
|
||||
public static List<Format> All()
|
||||
{
|
||||
var path = GetPath();
|
||||
var lines = File.ReadLines(path, Encoding.UTF8);
|
||||
var contents = string.Join(Environment.NewLine, lines);
|
||||
var formats = JsonConvert.DeserializeObject<Format[]>(contents);
|
||||
return formats.ToList();
|
||||
if (cachedFormats == null) {
|
||||
var path = GetPath();
|
||||
var lines = File.ReadLines(path, Encoding.UTF8);
|
||||
var contents = string.Join(Environment.NewLine, lines);
|
||||
var formats = JsonConvert.DeserializeObject<Format[]>(contents);
|
||||
cachedFormats = formats.ToList();
|
||||
}
|
||||
|
||||
return cachedFormats;
|
||||
}
|
||||
|
||||
private static string GetPath()
|
||||
|
||||
Reference in New Issue
Block a user