public void SqlServerEventStore_Save_And_Find_Should_Retrieve_EnumEvent_Without_Throwing_When_NullableConfirm_Is_Not_Null()
        {
            var enumEvent = new EnumEvent(EnumEvent.TestEnum.Yes, nullableConfirm: EnumEvent.TestEnum.No);

            var eventId = enumEvent.Id;

            var eventStore = new SqlServerEventStore(Config.ConnectionString, this.EventDispatcher);

            eventStore.Save(enumEvent);

            System.Threading.Thread.Sleep(1000);

            var events = eventStore.Find <EnumEvent>(e => e.Id == eventId).ToArray();

            Assert.NotNull(events);
            Assert.Single(events);

            var @event = events[0];

            Assert.Equal(enumEvent.Id, @event.Id);
            Assert.Equal(enumEvent.TimelineId, @event.TimelineId);
            Assert.Equal(enumEvent.TimeStamp.ToLongDateString(), @event.TimeStamp.ToLongDateString());
            Assert.Equal(enumEvent.RequiredConfirm, @event.RequiredConfirm);
            Assert.Equal(enumEvent.NullableConfirm, @event.NullableConfirm);
            Assert.NotNull(@event.NullableConfirm);
        }
 public void EnumEventHandler(DSPNode evNode, EnumEvent ev)
 {
     Debug.Log("EnumEventHandler");
     Assert.That(evNode, Is.EqualTo(Node));
     Assert.That(ev, Is.EqualTo(EnumEvent.EnumEvent1));
     ++EnumEventCallCount;
     Debug.Log("EnumEventHandler call count: " + EnumEventCallCount);
 }
Example #3
0
    public static void SafeInvoke(this EnumEvent e, Enum value)
    {
        if (e == null || value == null)
        {
            return;
        }

        e.Invoke(value);
    }
Example #4
0
    public static void Subscribe(this EnumEvent e, UnityAction <Enum> action)
    {
        if (e == null || action == null)
        {
            return;
        }

        e.AddListener(action);
    }
Example #5
0
 static public void AddListener(EnumEvent eventType, Callback handler)
 {
     // Obtain a lock on the event table to keep this thread-safe.
     lock (eventTable)
     {
         // Create an entry for this event type if it doesn't already exist.
         if (!eventTable.ContainsKey(eventType))
         {
             eventTable.Add(eventType, null);
         }
         // Add the handler to the event.
         eventTable[eventType] = (Callback)eventTable[eventType] + handler;
     }
 }
Example #6
0
 static public void AddListener(EnumEvent eventType, Callback handler)
 {
     // Obtain a lock on the event table to keep this thread-safe.
     lock (eventTable)
     {
         // Create an entry for this event type if it doesn't already exist.
         if (!eventTable.ContainsKey(eventType))
         {
             eventTable.Add(eventType, null);
         }
         // Add the handler to the event.
         eventTable[eventType] = (Callback)eventTable[eventType] + handler;
     }
 }
Example #7
0
    public static void AddEventFunction(EnumEvent _enum_eventType, EventHandler handler)
    {
        //Create a lock on the event list to keep this thread-safe
        lock(dic_eventList)
        {
            if(!dic_eventList.ContainsKey(_enum_eventType))
            {
                dic_eventList.Add(_enum_eventType, null);
            }

            //Update the value of the existing key in order to add a function to the existing list of event
            dic_eventList[_enum_eventType] = (EventHandler)dic_eventList[_enum_eventType] + handler;
        }
    }
Example #8
0
    public static void RemoveEventFunction(EnumEvent _enum_eventType, EventHandler handler)
    {
        lock(dic_eventList)
        {
            if(dic_eventList.ContainsKey(_enum_eventType))
            {
                dic_eventList[_enum_eventType] = (EventHandler)dic_eventList[_enum_eventType] - handler;

                if(dic_eventList[_enum_eventType] == null)
                {
                    dic_eventList.Remove (_enum_eventType);
                }
            }
        }
    }
Example #9
0
    static public void Raise(EnumEvent eventType)
    {
        Delegate d;
        // Raise the delegate only if the event type is in the dictionary.
        if (eventTable.TryGetValue(eventType, out d))
        {
            // Take a local copy to prevent a race condition if another thread
            // were to unsubscribe from this event.
            Callback callback = (Callback)d;

            // Raise the delegate if it's not null.
            if (callback != null)
            {
                callback();
            }
        }
    }
Example #10
0
    public static void callEventFunction(EnumEvent eventType)
    {
        Delegate del;
        // Raise the delegate only if the event type is in the dictionary.
        if(dic_eventList.TryGetValue(eventType, out del))
        {
            // Take a local copy to prevent a race condition if another thread
            // were to unsubscribe from this event.
            EventHandler handler = (EventHandler)del;

            // Raise the delegate if it's not null.
            if(handler != null)
            {
                handler();
            }
        }
    }
Example #11
0
    static public void Raise(EnumEvent eventType)
    {
        Delegate d;

        // Raise the delegate only if the event type is in the dictionary.
        if (eventTable.TryGetValue(eventType, out d))
        {
            // Take a local copy to prevent a race condition if another thread
            // were to unsubscribe from this event.
            Callback callback = (Callback)d;

            // Raise the delegate if it's not null.
            if (callback != null)
            {
                callback();
            }
        }
    }
Example #12
0
    static public void RemoveListener(EnumEvent eventType, Callback handler)
    {
        // Obtain a lock on the event table to keep this thread-safe.
        lock (eventTable)
        {
            // Only take action if this event type exists.
            if (eventTable.ContainsKey(eventType))
            {
                // Remove the event handler from this event.
                eventTable[eventType] = (Callback)eventTable[eventType] - handler;

                // If there's nothing left then remove the event type from the event table.
                if (eventTable[eventType] == null)
                {
                    eventTable.Remove(eventType);
                }
            }
        }
    }
Example #13
0
    static public void RemoveListener(EnumEvent eventType, Callback handler)
    {
        // Obtain a lock on the event table to keep this thread-safe.
        lock (eventTable)
        {
            // Only take action if this event type exists.
            if (eventTable.ContainsKey(eventType))
            {
                // Remove the event handler from this event.
                eventTable[eventType] = (Callback)eventTable[eventType] - handler;

                // If there's nothing left then remove the event type from the event table.
                if (eventTable[eventType] == null)
                {
                    eventTable.Remove(eventType);
                }
            }
        }
    }
Example #14
0
        private void ddlEvent_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlEvent.SelectedValue.GetType().Name == "DataRowView")
            {
                ddlEvent.SelectedValue = dtEvent.Rows[0]["Value"].ToString();
                return;
            }

            if (ddlEvent.SelectedValue.ToString() != String.Empty)
            {
                EnumEvent enumEvent = (EnumEvent)(Convert.ToInt32(ddlEvent.SelectedValue));

                //根据选择的动作类型,初始化不同的参数设置面板
                this.Event = EventFactory.GetEventDev(enumEvent);
            }
            else
            {
                this.Event = null;
            }

            if (this.Event != null)
            {
                this.iEventParameterSet = (IEventParameterSet)this.Event;

                this.treeViewParameter.Nodes.Clear();
                this.treeViewParameter.Nodes.Add(iEventParameterSet.GetParameterSetNode(this.FormEntity));
                this.treeViewParameter.ExpandAll();
                this.treeViewParameter.SelectedNode = iEventParameterSet.DefaultSelectedNode;
            }
            else
            {
                this.iEventParameterSet = null;
                this.treeViewParameter.Nodes.Clear();
                this.panelParameter.Controls.Clear();
            }
        }