/// <summary>
 /// 添加事件及回调
 /// </summary>
 /// <param name="type">事件枚举</param>
 /// <param name="handle">回调</param>
 /// <param name="isUseOnce"></param>
 public static void AddEvent(Enum type, EventHandle handle, bool isUseOnce = false)
 {
     if (isUseOnce)
     {
         if (mUseOnceEventDic.ContainsKey(type))
         {
             if (!mUseOnceEventDic[type].Contains(handle))
                 mUseOnceEventDic[type].Add(handle);
             else
                 Debug.LogWarning("already existing EventType: " + type + " handle: " + handle);
         }
         else
         {
             List<EventHandle> temp = new List<EventHandle>();
             temp.Add(handle);
             mUseOnceEventDic.Add(type, temp);
         }
     }
     else
     {
         if (mEventDic.ContainsKey(type))
         {
             if (!mEventDic[type].Contains(handle))
                 mEventDic[type].Add(handle);
             else
                 Debug.LogWarning("already existing EventType: "+ type+" handle: "+ handle );
         }
         else
         {
             List<EventHandle> temp = new List<EventHandle>();
             temp.Add(handle);
             mEventDic.Add(type, temp);
         }
     }
 }
Beispiel #2
0
 public void AddEventListener(string type, EventHandle handle)
 {
     if (!mCallFuncHandleDic.ContainsKey(type))
     {
         mCallFuncHandleDic[type] = handle;
     }
 }
 /// <summary>
 /// 添加事件及回调
 /// </summary>
 /// <param name="type">事件枚举</param>
 /// <param name="handle">回调</param>
 /// <param name="isUseOnce"></param>
 public static void AddEvent(Enum type, EventHandle handle, bool isUseOnce = false)
 {
     if (isUseOnce)
     {
         if (mUseOnceEventDic.ContainsKey(type))
         {
             if (!mUseOnceEventDic[type].Contains(handle))
             {
                 mUseOnceEventDic[type].Add(handle);
             }
             else
             {
                 Debug.LogWarning("already existing EventType: " + type + " handle: " + handle);
             }
         }
         else
         {
             List <EventHandle> temp = new List <EventHandle>();
             temp.Add(handle);
             mUseOnceEventDic.Add(type, temp);
         }
     }
     else
     {
         if (mEventDic.ContainsKey(type))
         {
             mEventDic[type] += handle;
         }
         else
         {
             mEventDic.Add(type, handle);
         }
     }
 }
Beispiel #4
0
        public void AddEventHandler(string type, NetEventHanlder handler, int priority = 0)
        {
            ArrayList handles = null;

            if (!eventHandles.TryGetValue(type, out handles))
            {
                handles = new ArrayList();
                eventHandles.Add(type, handles);
            }

            EventHandle handle = new EventHandle {
                handler = handler, priority = priority
            };
            int index = 0;

            for (int i = 0; i < handles.Count; i++)
            {
                if (((EventHandle)handles[i]).priority <= handle.priority)
                {
                    index = i;
                    break;
                }
            }

            handles.Insert(index, handle);
        }
Beispiel #5
0
        /// <summary>
        /// 移除某类事件的一个回调
        /// </summary>
        /// <param name="type"></param>
        /// <param name="handle"></param>
        public static void RemoveEvent(Enum type, EventHandle handle)
        {
            if (mUseOnceEventDic.ContainsKey(type))
            {
                if (mUseOnceEventDic[type].Contains(handle))
                {
                    mUseOnceEventDic[type].Remove(handle);
                    if (mUseOnceEventDic[type].Count == 0)
                    {
                        mUseOnceEventDic.Remove(type);
                    }
                }
            }

            if (mEventDic.ContainsKey(type))
            {
                if (mEventDic[type].Contains(handle))
                {
                    mEventDic[type].Remove(handle);
                    if (mEventDic[type].Count == 0)
                    {
                        mEventDic.Remove(type);
                    }
                }
            }
        }
Beispiel #6
0
        public override async Task OnActivateAsync()
        {
            await ReadSnapshotAsync();

            while (true)
            {
                var eventList = await EventStorage.GetListAsync(this.GrainId, this.State.Version, this.State.Version + 1000, this.State.VersionTime);

                foreach (var @event in eventList)
                {
                    this.State.IncrementDoingVersion();//标记将要处理的Version
                    EventHandle.Apply(this.State, @event.Event);
                    if ([email protected])
                    {
                        using (var ms = new PooledMemoryStream())
                        {
                            Serializer.Serialize(ms, @event.Event);
                            await AfterEventSavedHandle(@event.Event, ms.ToArray());
                        }
                    }
                    this.State.UpdateVersion(@event.Event);//更新处理完成的Version
                }
                if (eventList.Count < 1000)
                {
                    break;
                }
            }
            ;
        }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SubscriptionHandle"/> class.
 /// </summary>
 internal SubscriptionHandle()
 {
     EventHandle = new EventHandle()
     {
         PublisherNodeId = EllaConfiguration.Instance.NodeId
     };
 }
Beispiel #8
0
        /// <summary>
        /// 移除某类事件的一个回调
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="handle"></param>
        public void RemoveEvent(string eventName, EventHandle handle)
        {
            if (mUseOnceEventDic.ContainsKey(eventName))
            {
                if (mUseOnceEventDic[eventName].Contains(handle))
                {
                    mUseOnceEventDic[eventName].Remove(handle);
                    if (mUseOnceEventDic[eventName].Count == 0)
                    {
                        mUseOnceEventDic.Remove(eventName);
                    }
                }
            }

            if (mEventDic.ContainsKey(eventName))
            {
                if (mEventDic[eventName].Contains(handle))
                {
                    mEventDic[eventName].Remove(handle);
                    if (mEventDic[eventName].Count == 0)
                    {
                        mEventDic.Remove(eventName);
                    }
                }
            }
        }
    /// <summary>
    /// 移除某类事件的一个回调
    /// </summary>
    /// <param name="type"></param>
    /// <param name="handle"></param>
    public static void RemoveEvent(string eventKey, EventHandle handle)
    {
        if (m_stringEventDic.ContainsKey(eventKey))
        {
            if (m_stringEventDic[eventKey].Contains(handle))
            {
                m_stringEventDic[eventKey].Remove(handle);
                //if (m_stringEventDic[eventKey].Count == 0)
                //{
                //    m_stringEventDic.Remove(eventKey);
                //}
            }
        }

        if (m_stringOnceEventDic.ContainsKey(eventKey))
        {
            if (m_stringOnceEventDic[eventKey].Contains(handle))
            {
                m_stringOnceEventDic[eventKey].Remove(handle);
                //if (m_stringOnceEventDic[eventKey].Count == 0)
                //{
                //    m_stringOnceEventDic.Remove(eventKey);
                //}
            }
        }
    }
        public MacrosView()
        {
            InitializeComponent();

            EventsBuiltin.RegisterListener <Recording>(EventID.REC,
                                                       (r) =>
            {
                this.Dispatcher.Invoke(() => { onRec(r); });
            });

            recLoaded = EventsBuiltin.RegisterEvent <Recording>(EventID.REC_LOADED);

            //test
            //model = new RecordingModel();
            //keyframesControl.DataContext = model;
            //var n1 = new OpenLinkedListNode<Recording.KeyFrame>(new Recording.KeyFrameK(KeyActions.PRESS, System.Windows.Forms.Keys.A, 1200));
            //var n2 = new OpenLinkedListNode<Recording.KeyFrame>(new Recording.KeyFrameK(KeyActions.PRESS, System.Windows.Forms.Keys.B, 1300));
            //n1.Next = n2;
            //var container = new RecordingModel.FocusContainer();
            //var t1 = new InfoTray(n1, null, focusedTray: container);
            //var t2 = new InfoTray(n2, t1.Model, focusedTray: container);
            //model.Keyframes.Add(t1);
            //model.Keyframes.Add(t2);

            //Recording rec = new Recording();
            ////rec.AddKeyFrame(new Recording.KeyFrameK(KeyActions.PRESS, System.Windows.Forms.Keys.A, 1200));
            ////rec.AddKeyFrame(new Recording.KeyFrameK(KeyActions.PRESS, System.Windows.Forms.Keys.B, 1300));
            //rec.AddKeyframe(MouseAction.WM_LBUTTONDOWN, 25, 1, 1200);
            //rec.AddKeyframe(MouseAction.WM_LBUTTONUP, 35, 2, 1300);
            //onRec(rec);
        }
    static int AddEventListener(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 3);
            UIBase      obj       = (UIBase)ToLua.CheckObject(L, 1, typeof(UIBase));
            System.Enum arg0      = (System.Enum)ToLua.CheckObject(L, 2, typeof(System.Enum));
            EventHandle arg1      = null;
            LuaTypes    funcType3 = LuaDLL.lua_type(L, 3);

            if (funcType3 != LuaTypes.LUA_TFUNCTION)
            {
                arg1 = (EventHandle)ToLua.CheckObject(L, 3, typeof(EventHandle));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 3);
                arg1 = DelegateFactory.CreateDelegate(typeof(EventHandle), func) as EventHandle;
            }

            obj.AddEventListener(arg0, arg1);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #12
0
        public IDisposable Register(Type type, Func <object, Task> callback)
        {
            var handler = new EventHandle(this, type, callback);

            listeners.Add(handler);
            return(handler);
        }
Beispiel #13
0
        public static AccountState FromBytes(byte[] bytes)
        {
            var cursor = new CursorBuffer(bytes);

            var authenticationKeyLen = cursor.Read32();
            var authenticationKey    = cursor.ReadXBytes((int)authenticationKeyLen);
            var balance = cursor.Read64();
            var delegatedKeyRotationCapability = cursor.ReadBool();
            var delegatedWithdrawalCapability  = cursor.ReadBool();

            var receivedEventsCount = cursor.Read32();

            cursor.Read32(); // skip struct attribute sequence number
            var receivedEventsKeyLen = cursor.Read32();
            var receivedEventsKey    = cursor.ReadXBytes((int)receivedEventsKeyLen);

            var sentEventsCount = cursor.Read32();

            cursor.Read32(); // skip struct attribute sequence number
            var sentEventsKeyLen = cursor.Read32();
            var sentEventsKey    = cursor.ReadXBytes((int)sentEventsKeyLen);

            var sequenceNumber = cursor.Read64();

            var receivedEvents = new EventHandle(receivedEventsKey, receivedEventsCount);
            var sentEvents     = new EventHandle(sentEventsKey, sentEventsCount);

            return(new AccountState(authenticationKey, balance, receivedEvents, sentEvents, sequenceNumber, delegatedWithdrawalCapability, delegatedKeyRotationCapability));
        }
Beispiel #14
0
        private void btnPortOpen_Click(object sender, EventArgs e)
        {
            try
            {
                if (!COM.IsOpen)    // open
                {
                    COMGetSettings();
                    COM.Open();
                    DataReceived += new EventHandle(COMGetData);
                }

                if (!loop)                  // begin read
                {
                    loop   = true;
                    thread = new Thread(new ThreadStart(PortRead));
                    thread.Start();
                }

                if (COM.IsOpen)
                {
                    lbCOMstatus.Text = "串口已打开";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #15
0
 public virtual void Init()
 {
     EventHandle.AddCommandHook(COMMAND_TYPE.GAME_START, OnStart);
     EventHandle.AddCommandHook(COMMAND_TYPE.SCORE, OnScore);
     EventHandle.AddCommandHook(COMMAND_TYPE.COMMAND_MAX, OnScore);
     EventHandle.AddCommandHook(COMMAND_TYPE.GAME_OVERD, OnDied);
 }
Beispiel #16
0
 public Message(short cmd, short cmd_branch, object protoBuffer,EventHandle handle=null)
 {
     this.cmd = cmd;
     this.cmd_branch = cmd_branch;
     this.protoBuffer = protoBuffer;
     this.eventHandle = handle;
     encodeMessage();
 }
Beispiel #17
0
 /// <inheritdoc />
 public IEventHandle <TEvent> GetHandle <TEvent>()
 {
     if (!_handleCache.ContainsKey(typeof(TEvent)))
     {
         _handleCache[typeof(TEvent)] = new EventHandle <TEvent>(this);
     }
     return((IEventHandle <TEvent>)_handleCache[typeof(TEvent)]);
 }
Beispiel #18
0
 public bool TryGetEvent(string name, out EventHandle handle)
 {
     if (this.eventDefs == null)
     {
         this.eventDefs = GetEventDefs(this.reader, this.typeHandle);
     }
     return(this.eventDefs.TryGetValue(name, out handle));
 }
 //
 // eventHandle    - the "tkEventDef" that identifies the event.
 // definingType   - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created eventHandle.)
 // contextType    - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you
 //                  get your raw information from "definingType", you report "contextType" as your DeclaringType property.
 //
 //  For example:
 //
 //       typeof(Foo<>).GetTypeInfo().DeclaredMembers
 //
 //           The definingType and contextType are both Foo<>
 //
 //       typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers
 //
 //          The definingType is "Foo<,>"
 //          The contextType is "Foo<int,String>"
 //
 //  We don't report any DeclaredMembers for arrays or generic parameters so those don't apply.
 //
 private NativeFormatRuntimeEventInfo(EventHandle eventHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) :
     base(contextTypeInfo, reflectedType)
 {
     _eventHandle      = eventHandle;
     _definingTypeInfo = definingTypeInfo;
     _reader           = definingTypeInfo.Reader;
     _event            = eventHandle.GetEvent(_reader);
 }
 //
 // eventHandle    - the "tkEventDef" that identifies the event.
 // definingType   - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created eventHandle.)
 // contextType    - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you
 //                  get your raw information from "definingType", you report "contextType" as your DeclaringType property.
 //
 //  For example:
 //
 //       typeof(Foo<>).GetTypeInfo().DeclaredMembers
 //
 //           The definingType and contextType are both Foo<>
 //
 //       typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers
 //
 //          The definingType is "Foo<,>"
 //          The contextType is "Foo<int,String>"
 //
 //  We don't report any DeclaredMembers for arrays or generic parameters so those don't apply.
 //
 private RuntimeEventInfo(EventHandle eventHandle, RuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo)
 {
     _eventHandle = eventHandle;
     _definingTypeInfo = definingTypeInfo;
     _contextTypeInfo = contextTypeInfo;
     _reader = definingTypeInfo.Reader;
     _event = eventHandle.GetEvent(_reader);
 }
        public EventProperties(EventHandle eventHandle)
        {
            InitializeComponent();

            _eventHandle = eventHandle;
            _eventHandle.Reference();
            this.UpdateInfo();
        }
        public EventProperties(EventHandle eventHandle)
        {
            InitializeComponent();

            _eventHandle = eventHandle;
            _eventHandle.Reference();
            this.UpdateInfo();
        }
Beispiel #23
0
 //
 // eventHandle    - the "tkEventDef" that identifies the event.
 // definingType   - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created eventHandle.)
 // contextType    - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you
 //                  get your raw information from "definingType", you report "contextType" as your DeclaringType property.
 //
 //  For example:
 //
 //       typeof(Foo<>).GetTypeInfo().DeclaredMembers
 //
 //           The definingType and contextType are both Foo<>
 //
 //       typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers
 //
 //          The definingType is "Foo<,>"
 //          The contextType is "Foo<int,String>"
 //
 //  We don't report any DeclaredMembers for arrays or generic parameters so those don't apply.
 //
 private RuntimeEventInfo(EventHandle eventHandle, RuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo)
 {
     _eventHandle      = eventHandle;
     _definingTypeInfo = definingTypeInfo;
     _contextTypeInfo  = contextTypeInfo;
     _reader           = definingTypeInfo.Reader;
     _event            = eventHandle.GetEvent(_reader);
 }
Beispiel #24
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         string postString = string.Empty;
         string action     = Tool.WEBRequest.GetQueryString("action");
         if (string.IsNullOrEmpty(action))
         {
             if (HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")
             {
                 using (Stream stream = HttpContext.Current.Request.InputStream)
                 {
                     Byte[] postBytes = new Byte[stream.Length];
                     stream.Read(postBytes, 0, (Int32)stream.Length);
                     postString = Encoding.UTF8.GetString(postBytes);
                     string msg = new EventHandle().ReturnMessage(postString);
                     Response.Write(msg);
                 }
             }
             if (HttpContext.Current.Request.HttpMethod.ToUpper() == "GET")
             {
                 new WeiXin().Auth();
             }
         }
         else if (action.ToLower() == "clearcache")
         {
             string user_Ip = Tool.WEBRequest.GetIP();
             if (IsValidIp(user_Ip))
             {
                 //清理客户端WCF缓存
                 //TuanDai.BalancedSystem.Client.BalancedSystemClient client = new TuanDai.BalancedSystem.Client.BalancedSystemClient();
                 //client.ClearCacheByClient();
                 Response.Write("1");
                 Response.End();
             }
             else
             {
                 Response.Write("非法的来访IP");
                 Response.End();
             }
         }
         else if (action.ToLower() == "cleartoken")
         {
             string strValidatePass = Tool.WEBRequest.GetQueryString("ValidatePass");
             if (strValidatePass == "tuandaiisgood")
             {
                 //  TuanDai.WXApiWeb.Common.WeiXinApi.removeCache("WeiXinTicket");
                 //请求完检测DB中Token状态 Allen 2015-08-12
                 ThirdLoginSDK.CheckDBTokenDelegate chkStatus = new ThirdLoginSDK.CheckDBTokenDelegate(ThirdLoginSDK.CheckDBTokenStatus);
                 chkStatus.BeginInvoke(GlobalUtils.AppId, null, null);
             }
         }
     }
     catch (Exception ex)
     {
         SysLogHelper.WriteErrorLog("微信请求", "错误详细信息:" + ex.Message + "|" + ex.StackTrace);
     }
 }
Beispiel #25
0
 public bool RemoveHandler(EventHandle handle)
 {
     if (this.events.Contains(handle))
     {
         this.events.Remove(handle);
         return(true);
     }
     return(false);
 }
Beispiel #26
0
 private AccountState(byte[] authenticationKey, ulong balance, EventHandle receivedEvents, EventHandle sentEvents, ulong sequenceNumber, bool delegatedWithdrawalCapability)
 {
     this.AuthenticationKey             = authenticationKey;
     this.Balance                       = balance;
     this.ReceivedEvents                = receivedEvents;
     this.SentEvents                    = sentEvents;
     this.SequenceNumber                = sequenceNumber;
     this.DelegatedWithdrawalCapability = delegatedWithdrawalCapability;
 }
Beispiel #27
0
        } // Read

        public static uint Read(this NativeReader reader, uint offset, out EventHandle handle)
        {
            uint value;

            offset = reader.DecodeUnsigned(offset, out value);
            handle = new EventHandle((int)value);
            handle._Validate();
            return(offset);
        } // Read
Beispiel #28
0
    IEnumerator RestartGame()
    {
        yield return(new WaitForSecondsRealtime(tickTime));

        ResetGame();
        EventHandle.Command(COMMAND_TYPE.GAME_RESET);
        isGameStart = true;
        EventHandle.Command(COMMAND_TYPE.GAME_START);
    }
Beispiel #29
0
        /// <summary>
        /// キューに非同期メッセージを入れます
        /// </summary>
        /// <param name="d">呼び出すSendOrPostCallbackデリゲート</param>
        /// <param name="state">デリゲートに渡されるオブジェクト</param>
        public override void Post(SendOrPostCallback d, object state)
        {
            var msg = new Message(this, d, state);

            lock (((ICollection)queue).SyncRoot) {
                queue.Enqueue(msg);
                EventHandle.Set();
            }
        }
Beispiel #30
0
    //等一段时间再开始 让 reinforcement 把最后一次失败更新到 q_table
    IEnumerator RestartGame()
    {
        yield return(new WaitForSecondsRealtime(tickTime));

        ResetGame();
        EventHandle.Command(COMMAND_TYPE.GAME_RESET);
        GameManager.S.isGameStart = true;
        EventHandle.Command(COMMAND_TYPE.GAME_START);
        Scorers.S.SetLiveTime(true);
    }
Beispiel #31
0
    public void GameOver()
    {
        isGameOver = true;
        EventHandle.Command(COMMAND_TYPE.GAME_OVERD);

        if (isTrainning)
        {
            StartCoroutine(RestartGame());
        }
    }
Beispiel #32
0
    public void AddEventListener(Enum EventEnum, EventHandle handle)
    {
        EventHandRegisterInfo info = new EventHandRegisterInfo();
        info.m_EventKey = EventEnum;
        info.m_hande = handle;

        GlobalEvent.AddEvent(EventEnum, handle);

        m_EventListeners.Add(info);
    }
Beispiel #33
0
        public bool AddHandler(EventHandle handle)
        {
            if (this.events.Exists((EventHandle item) => item == handle))
            {
                return(false);
            }

            this.events.Add(handle);
            return(true);
        }
Beispiel #34
0
    public void AddEventListener(Enum EventEnum, EventHandle handle)
    {
        EventHandRegisterInfo info = new EventHandRegisterInfo();
        info.m_EventKey = EventEnum;
        info.m_hande = handle;

        GlobalEvent.AddEvent(EventEnum, handle);

        m_EventListeners.Add(info);
    }
Beispiel #35
0
        public bool DetachEvent(EventCode eventCode, EventHandle eventHandle)
        {
            List <EventHandle> list = _EventMap[(int)eventCode];

            if (list != null)
            {
                return(list.Remove(eventHandle));
            }
            return(false);
        }
Beispiel #36
0
 internal override bool TryGetEventHandle(Cci.IEventDefinition def, out EventHandle handle)
 {
     var other = this.mapToMetadata.MapDefinition(def) as PEEventSymbol;
     if ((object)other != null)
     {
         handle = other.Handle;
         return true;
     }
     else
     {
         handle = default(EventHandle);
         return false;
     }
 }
Beispiel #37
0
 public void AddEventListener(string key, EventHandle handle)
 {
     if (_dict.ContainsKey(key))
     {
         Delegate[] _delegates = _dict[key].GetInvocationList();
         for (int i = 0; i < _delegates.Length; i++)
         {
             if (_delegates[i] == handle)
             {
                 return;
             }
         }
         _dict[key] += handle;
     }
     else
     {
         _dict.Add(key, handle);
     }
 }
Beispiel #38
0
        public void RemoveEventListener(string key, EventHandle handle)
        {
            if (_dict.ContainsKey(key))
            {
                Delegate[] _delegates = _dict[key].GetInvocationList();
                for (int i = 0; i < _delegates.Length; i++)
                {
                    if (_delegates[i] == handle)
                    {
                        _dict[key] -= handle;
                        return;
                    }
                }

                if (_dict[key] == null)
                {
                    _dict.Remove(key);
                }
            }
        }
 public sealed override IEnumerable<CustomAttributeData> GetPsuedoCustomAttributes(MetadataReader reader, EventHandle eventHandle, TypeDefinitionHandle declaringTypeHandle)
 {
     return Empty<CustomAttributeData>.Enumerable;
 }
Beispiel #40
0
        public static bool IsTypeOf(INETWISEDriverSink sink, DatabaseHandle hDatabase, EventHandle hEvent)
        {
            WISE_RESULT wResult = WISEError.WISE_OK;
            AttributeHandle hAttr = WISEConstants.WISE_INVALID_HANDLE;
            string strEntityType = string.Empty;

            if ((sink == null) || (hEvent == WISEConstants.WISE_INVALID_HANDLE))
            {
                return false;
            }

            // Initialize handle cache
            Initialize(sink as INETWISEStringCache);

            wResult = sink.GetEventAttributeHandle(hDatabase, hEvent, WISEConstants.WISE_TEMPLATE_EVENT_TYPE, ref hAttr,
                                                   DataType.String);
            bool bResult = WISEError.CheckCallFailed(wResult);

            wResult = sink.GetEventAttributeValue(hDatabase, hEvent, hAttr, ref strEntityType);
            bResult = WISEError.CheckCallSucceeded(wResult);

            return bResult && IsTypeOf(strEntityType);
        }
Beispiel #41
0
 public CBRNLCDControl(INETWISEDriverSink sink, DatabaseHandle databaseHandle, EventHandle eventHandle)
 {
     this.WISESink = sink;
     this.Database = databaseHandle;
     this.Handle = eventHandle;
 }
Beispiel #42
0
        protected override WISE_RESULT OnSendEvent(DateTime timeStamp, DatabaseHandle hDatabase, EventHandle hEvent,
            ClassHandle hClass, TransactionHandle hTransaction)
        {
            WISE_RESULT result = WISEError.WISE_OK;

            // Call base class implementation
            result = base.OnSendEvent(timeStamp, hDatabase, hEvent, hClass, hTransaction);
            WISEError.CheckCallFailedEx(result);

            try
            {
                //
                // TODO: Send event on driver communication interface.
                //
                // This method typically needs to perform the following steps;
                //   1. Identify the type of event.
                //   2. Based on the event type, extract event attributes.
                //   3. Fill event attribute values into the protocol container associated with the event.
                //   4. Send the event on the underlying protocol.
                //

                #region Sample code: Check event type
                //ClassHandle hTestEventClass = ClassHandle.Invalid;

                //// Get handle corresponding to class "TEST_EVENT" (this can be done once and then cached)
                //result = this.WISETypeInfo.GetWISEClassHandle(hDatabase, "TEST_EVENT", ref hTestEventClass);
                //WISEError.CheckCallFailedEx(result);

                //if (hClass == hTestEventClass)
                //{
                //    #region Sample code: Access TEST_EVENT attributes
                //    string stringAttributeValue = "";
                //    AttributeHandle hAttr = AttributeHandle.Invalid;

                //    result = this.Sink.GetEventAttributeHandle(hDatabase, hEvent, "TEST_STRING", ref hAttr);
                //    WISEError.CheckCallFailedEx(result);

                //    result = this.Sink.GetEventAttributeValue(hDatabase, hEvent, hAttr, ref stringAttributeValue);
                //    WISEError.CheckCallFailedEx(result);
                //    #endregion
                //}
                #endregion
            }
            catch (WISEException ex)
            {
                result = ex.Error.ErrorCode;
            }
            return result;
        }
Beispiel #43
0
        internal PEEventSymbol(
            PEModuleSymbol moduleSymbol,
            PENamedTypeSymbol containingType,
            EventHandle handle,
            PEMethodSymbol addMethod,
            PEMethodSymbol removeMethod)
        {
            Debug.Assert((object)moduleSymbol != null);
            Debug.Assert((object)containingType != null);
            Debug.Assert(!handle.IsNil);
            Debug.Assert((object)addMethod != null);
            Debug.Assert((object)removeMethod != null);

            this.addMethod = addMethod;
            this.removeMethod = removeMethod;
            this.handle = handle;
            this.containingType = containingType;

            EventAttributes mdFlags = 0;
            Handle eventType = default(Handle);

            try
            {
                var module = moduleSymbol.Module;
                module.GetEventDefPropsOrThrow(handle, out this.name, out mdFlags, out eventType);
            }
            catch (BadImageFormatException mrEx)
            {
                if ((object)this.name == null)
                {
                    this.name = string.Empty;
                }

                lazyUseSiteDiagnostic = new CSDiagnosticInfo(ErrorCode.ERR_BindToBogus, this);

                if (eventType.IsNil)
                {
                    this.eventType = new UnsupportedMetadataTypeSymbol(mrEx);
                }
            }

            if ((object)this.eventType == null)
            {
                var metadataDecoder = new MetadataDecoder(moduleSymbol, containingType);
                this.eventType = metadataDecoder.GetTypeOfToken(eventType);
            }

            // IsWindowsRuntimeEvent checks the signatures, so we just have to check the accessors.
            bool callMethodsDirectly = IsWindowsRuntimeEvent
                ? !DoModifiersMatch(this.addMethod, this.removeMethod)
                : !DoSignaturesMatch(moduleSymbol, this.eventType, this.addMethod, this.removeMethod);

            if (callMethodsDirectly)
            {
                flags |= Flags.CallMethodsDirectly;
            }
            else
            {
                this.addMethod.SetAssociatedEvent(this, MethodKind.EventAdd);
                this.removeMethod.SetAssociatedEvent(this, MethodKind.EventRemove);
            }

            if ((mdFlags & EventAttributes.SpecialName) != 0)
            {
                flags |= Flags.IsSpecialName;
            }

            if ((mdFlags & EventAttributes.RTSpecialName) != 0)
            {
                flags |= Flags.IsRuntimeSpecialName;
            }
        }
 public bool TryGetEvent(string name, out EventHandle handle)
 {
     if (this.eventDefs == null)
     {
         this.eventDefs = GetEventDefs(this.reader, this.typeHandle);
     }
     return this.eventDefs.TryGetValue(name, out handle);
 }
Beispiel #45
0
        public static bool IsTypeOf(INETWISEDriverSink2 WISE, DatabaseHandle hDatabase, EventHandle hEvent)
        {
            uint result = WISEError.WISE_ERROR;
            AttributeHandle hAttr = WISEConstants.WISE_INVALID_HANDLE;
            string strEntityType = string.Empty;

            if ((WISE == null) || (hEvent == WISEConstants.WISE_INVALID_HANDLE))
            {
                return false;
            }

            result = WISE.GetEventAttributeHandle(hDatabase, hEvent, WISEConstants.WISE_TEMPLATE_EVENT_TYPE, ref hAttr);
            if (WISEError.CheckCallFailed(result))
            {
                return false;
            }

            result = WISE.GetEventAttributeValue(hDatabase, hEvent, hAttr, ref strEntityType);
            return WISEError.CheckCallSucceeded(result) && IsTypeOf(strEntityType);
        }
Beispiel #46
0
 public CBRNLCDControl(INETWISEDriverSink2 WISE, DatabaseHandle databaseHandle, EventHandle eventHandle)
 {
     this.WISE = WISE;
     this.Database = databaseHandle;
     this.Handle = eventHandle;
 }
Beispiel #47
0
 internal abstract bool TryGetEventHandle(IEventDefinition def, out EventHandle handle);
Beispiel #48
0
 public void SetNoHandle(EventHandle no)
 {
     eventNo = no;
 }
Beispiel #49
0
 public void SetYesHandle(EventHandle yes)
 {
     eventYes = yes;
 }
    /// <summary>
    /// 移除某类事件的一个回调
    /// </summary>
    /// <param name="type"></param>
    /// <param name="handle"></param>
    public static void RemoveEvent(string eventKey, EventHandle handle)
    {
        if (m_stringEventDic.ContainsKey(eventKey))
        {
            if (m_stringEventDic[eventKey].Contains(handle))
            {
                m_stringEventDic[eventKey].Remove(handle);
                //if (m_stringEventDic[eventKey].Count == 0)
                //{
                //    m_stringEventDic.Remove(eventKey);
                //}
            }
        }

        if (m_stringOnceEventDic.ContainsKey(eventKey))
        {
            if (m_stringOnceEventDic[eventKey].Contains(handle))
            {
                m_stringOnceEventDic[eventKey].Remove(handle);
                //if (m_stringOnceEventDic[eventKey].Count == 0)
                //{
                //    m_stringOnceEventDic.Remove(eventKey);
                //}
            }
        }
    }
Beispiel #51
0
 public abstract IEnumerable<CustomAttributeData> GetPsuedoCustomAttributes(MetadataReader reader, EventHandle eventHandle, TypeDefinitionHandle declaringTypeHandle);
    /// <summary>
    /// 移除某类事件的一个回调
    /// </summary>
    /// <param name="type"></param>
    /// <param name="handle"></param>
    public static void RemoveEvent(Enum type, EventHandle handle)
    {
        if (mUseOnceEventDic.ContainsKey(type))
            {
                if (mUseOnceEventDic[type].Contains(handle))
                {
                    mUseOnceEventDic[type].Remove(handle);
                    if (mUseOnceEventDic[type].Count == 0)
                    {
                        mUseOnceEventDic.Remove(type);
                    }
                }
            }

            if (mEventDic.ContainsKey(type))
            {
                if (mEventDic[type].Contains(handle))
                {
                    mEventDic[type].Remove(handle);
                    if (mEventDic[type].Count == 0)
                    {
                        mEventDic.Remove(type);
                    }
                }
            }
    }
 /// <summary>
 /// 添加事件及回调
 /// </summary>
 /// <param name="type">事件枚举</param>
 /// <param name="handle">回调</param>
 /// <param name="isUseOnce"></param>
 public static void AddEvent(string eventKey, EventHandle handle, bool isUseOnce = false)
 {
     if (isUseOnce)
     {
         if (m_stringOnceEventDic.ContainsKey(eventKey))
         {
             if (!m_stringOnceEventDic[eventKey].Contains(handle))
                 m_stringOnceEventDic[eventKey].Add(handle);
             else
                 Debug.LogWarning("already existing EventType: " + eventKey + " handle: " + handle);
         }
         else
         {
             List<EventHandle> temp = new List<EventHandle>();
             temp.Add(handle);
             m_stringOnceEventDic.Add(eventKey, temp);
         }
     }
     else
     {
         if (m_stringEventDic.ContainsKey(eventKey))
         {
             if (!m_stringEventDic[eventKey].Contains(handle))
                 m_stringEventDic[eventKey].Add(handle);
             else
                 Debug.LogWarning("already existing EventType: " + eventKey + " handle: " + handle);
         }
         else
         {
             List<EventHandle> temp = new List<EventHandle>();
             temp.Add(handle);
             m_stringEventDic.Add(eventKey, temp);
         }
     }
 }