예제 #1
0
        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);
            }
        }
예제 #2
0
 public void When(EntityDemoEvent e)
 {
     Name = e.Name;
 }