Exemplo n.º 1
0
        /// <summary>
        /// 引数ありでイベントを実行します。
        /// 全ての登録されたイベントに対して実行を行います。
        /// 一つでもイベントが受け取られるとtrueを返します。
        /// </summary>
        public bool Broadcast <T>(string key, T prm)
        {
            if (Disposed)
            {
                return(false);
            }

            Log.Trace("[ilib-event] Broadcast {0}({1})", key, typeof(T));

            bool ret = false;

            if (InvokeBeforChild)
            {
                ret |= BroadcastImpl(key, prm);
            }
            if (m_Calls != null)
            {
                for (int i = 0; i < m_Calls.Count; i++)
                {
                    EventCall call = m_Calls[i];
                    if (call != null)
                    {
                        ret |= call.Broadcast(key, prm);
                    }
                }
            }
            if (!InvokeBeforChild)
            {
                ret |= BroadcastImpl(key, prm);
            }
            return(ret);
        }
Exemplo n.º 2
0
        public void SetEnabled(object key, bool enabled)
        {
            var _key = EventCall.ToKey(key);

            foreach (var path in m_Paths)
            {
                if (path.Key == _key)
                {
                    path.Enabled = enabled;
                }
            }
        }
Exemplo n.º 3
0
 void Remove(EventCall call)
 {
     Log.Trace("[ilib-event] remove call.");
     lock (m_Locker)
     {
         //要素の長さは変えない
         var index = m_Calls.IndexOf(call);
         if (index >= 0)
         {
             m_Calls[index] = call;
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 子のコールを生成します。
        /// </summary>
        public EventCall SubCall()
        {
            Log.Trace("[ilib-event] create subcall.");
            EventCall call = new EventCall();

            lock (m_Locker)
            {
                call.m_Parent = this;
                if (m_Calls == null)
                {
                    m_Calls = new List <EventCall>(4);
                }
                for (int i = 0; i < m_Calls.Count; i++)
                {
                    if (m_Calls[i] == null)
                    {
                        m_Calls[i] = call;
                        return(call);
                    }
                }
                m_Calls.Add(call);
            }
            return(call);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 引数ありでイベントを実行します。
        /// イベントを受け取ったパスがあるとそこで処理が終わります。
        /// イベントが受け取られたかは返り値で判断できます。
        /// </summary>
        public bool Message <T>(string key, T prm)
        {
            if (Disposed)
            {
                return(false);
            }

            Log.Trace("[ilib-event] Message {0}({1})", key, typeof(T));

            if (InvokeBeforChild)
            {
                if (MessageImpl(key, prm))
                {
                    return(true);
                }
            }
            if (m_Calls != null)
            {
                for (int i = 0; i < m_Calls.Count; i++)
                {
                    EventCall call = m_Calls[i];
                    if (call != null && call.Message(key, prm))
                    {
                        return(true);
                    }
                }
            }
            if (!InvokeBeforChild)
            {
                if (MessageImpl(key, prm))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 6
0
 public HandleAttribute(object obj)
 {
     Key = EventCall.ToKey(obj);
 }
Exemplo n.º 7
0
 internal Path(EventCall call, string key, Func <bool> func) : base(call, key)
 {
     Type   = null;
     m_Func = func;
 }
Exemplo n.º 8
0
 internal PathBase(EventCall call, string key)
 {
     Key      = key;
     m_Parent = call;
 }
Exemplo n.º 9
0
 internal HandlePath(EventCall call, string key, Func <object, bool> func, Type type, EventHandle handle) : base(call, key)
 {
     Type     = type;
     m_Func   = func;
     m_Handle = handle;
 }