From a808568bfb33cb2eff019b94da0e12ea36613b9d Mon Sep 17 00:00:00 2001 From: tanghai Date: Wed, 29 Oct 2014 16:34:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=AE=A1=E7=90=86=E5=99=A8?= =?UTF-8?q?=E4=B9=9F=E5=81=9A=E6=88=90World=E7=9A=84=E4=B8=80=E4=B8=AAComp?= =?UTF-8?q?onent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model/Component/EventComponent.cs} | 18 ++++++++++-------- CSharp/Game/Model/Model.csproj | 1 + CSharp/Platform/Common/Common.csproj | 1 - 3 files changed, 11 insertions(+), 9 deletions(-) rename CSharp/{Platform/Common/Event/EventTrigger.cs => Game/Model/Component/EventComponent.cs} (70%) diff --git a/CSharp/Platform/Common/Event/EventTrigger.cs b/CSharp/Game/Model/Component/EventComponent.cs similarity index 70% rename from CSharp/Platform/Common/Event/EventTrigger.cs rename to CSharp/Game/Model/Component/EventComponent.cs index f57a554c..fd52d9d7 100644 --- a/CSharp/Platform/Common/Event/EventTrigger.cs +++ b/CSharp/Game/Model/Component/EventComponent.cs @@ -1,21 +1,23 @@ using System; using System.Collections.Generic; +using System.Reflection; +using Common.Base; +using Common.Event; -namespace Common.Event +namespace Model { - public class EventTrigger where T : AEventAttribute + public class EventComponent: Component where T : AEventAttribute { - private readonly Dictionary> events; + private Dictionary> events; - public EventTrigger() + public void Load(Assembly assembly) { this.events = new Dictionary>(); - Type type = typeof (T); - var types = type.Assembly.GetTypes(); + var types = assembly.GetTypes(); foreach (var t in types) { - object[] attrs = t.GetCustomAttributes(type, false); + object[] attrs = t.GetCustomAttributes(typeof (T), false); if (attrs.Length == 0) { continue; @@ -28,7 +30,7 @@ namespace Common.Event obj.GetType().FullName)); } - AEventAttribute iEventAttribute = (T) attrs[0]; + AEventAttribute iEventAttribute = (AEventAttribute) attrs[0]; if (!this.events.ContainsKey(iEventAttribute.Type)) { diff --git a/CSharp/Game/Model/Model.csproj b/CSharp/Game/Model/Model.csproj index a548eaf2..9e0154b2 100644 --- a/CSharp/Game/Model/Model.csproj +++ b/CSharp/Game/Model/Model.csproj @@ -54,6 +54,7 @@ + diff --git a/CSharp/Platform/Common/Common.csproj b/CSharp/Platform/Common/Common.csproj index 46d066fc..52d73436 100644 --- a/CSharp/Platform/Common/Common.csproj +++ b/CSharp/Platform/Common/Common.csproj @@ -62,7 +62,6 @@ - -- GitLab