Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Load()

bool Terraria.IO.Preferences.Load ( )
inline

Definition at line 64 of file Preferences.cs.

65 {
66 //IL_005d: Unknown result type (might be due to invalid IL or missing references)
67 //IL_0064: Expected O, but got Unknown
68 lock (_lock)
69 {
70 if (!File.Exists(_path))
71 {
72 return false;
73 }
74 try
75 {
76 if (!UseBson)
77 {
78 string text = File.ReadAllText(_path);
80 }
81 else
82 {
85 try
86 {
87 JsonSerializer val2 = JsonSerializer.Create(_serializerSettings);
88 _data = val2.Deserialize<Dictionary<string, object>>((JsonReader)(object)val);
89 }
90 finally
91 {
92 ((IDisposable)val)?.Dispose();
93 }
94 }
95 if (_data == null)
96 {
98 }
99 if (this.OnLoad != null)
100 {
101 this.OnLoad(this);
102 }
103 return true;
104 }
105 catch (Exception)
106 {
107 return false;
108 }
109 }
110 }
static bool Exists([NotNullWhen(true)] string? path)
Definition File.cs:97
static FileStream OpenRead(string path)
Definition File.cs:236
static string ReadAllText(string path)
Definition File.cs:246
Dictionary< string, object > _data
readonly object _lock
Action< Preferences > OnLoad
readonly string _path
readonly JsonSerializerSettings _serializerSettings
readonly bool UseBson

References Terraria.IO.Preferences._data, Terraria.IO.Preferences._lock, Terraria.IO.Preferences._path, Terraria.IO.Preferences._serializerSettings, System.IO.File.Exists(), Terraria.IO.Preferences.OnLoad, System.IO.File.OpenRead(), System.IO.File.ReadAllText(), System.text, and Terraria.IO.Preferences.UseBson.

Referenced by Terraria.Main.LoadSettings().