public void Load(IEntityID ID) { string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/事件"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path += "/" + DateTime.Now.ToString("yyyy-MM-dd") + "事件" + ID.GetEntityID().ToString() + ".txt"; if (!File.Exists(path)) { using (StreamWriter writer = File.CreateText(path)) { }; } using (StreamReader reader = File.OpenText(path)) { JsonSerializer serializer = JsonSerializer.Create(); JObject @object = (JObject)serializer.Deserialize(reader, typeof(JObject)); if (@object == null) { Version = 1; } else { Version = @object.Value <long>("Version"); JArray jArray = @object.Value <JArray>("Event"); foreach (var obj in jArray) { Event e = new EntityDemoEvent(obj.Value <string>("Name"), obj.Value <string>("EventName")); Events.Add(e); } } } while (AddQueue.TryDequeue(out Event @event)) { Events.Add(@event); } }
protected EntityModule(IEntityID ID) { this.ID = ID; }