예제 #1
0
 public virtual void OnEnable()
 {
     MethodInfo[] methods = GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
     foreach (MethodInfo m in methods)
     {
         System.Attribute[] attributes = (System.Attribute[])m.GetCustomAttributes(true);
         foreach (System.Attribute attribute in attributes)
         {
             if (attribute is OnEvent)
             {
                 OnEvent onEventMethod = (OnEvent)attribute;
                 if (m.GetParameters().Length == 2)
                 {
                     PMEvent del = (PMEvent)Delegate.CreateDelegate(typeof(PMEvent), this, m);
                     events.Add(new PairEventString(onEventMethod.Name, del));
                 }
                 else
                 {
                     PMEventLite del = (PMEventLite)Delegate.CreateDelegate(typeof(PMEventLite), this, m);
                     eventsLite.Add(new PairEventLiteString(onEventMethod.Name, del));
                 }
             }
         }
     }
     RegisterAll();
 }
예제 #2
0
 public void Unregister(string id, PMEvent eventMethod)
 {
     if (id != "")
     {
         events [id] -= eventMethod;
     }
     else
     {
         allEvents -= eventMethod;
     }
 }
예제 #3
0
    public void Initialize()
    {
        StateController.AddPieka(this);


        System.Attribute[] att = (System.Attribute[])GetType().GetCustomAttributes(true);


        foreach (System.Attribute attribute in att)
        {
            if (attribute is AllowedState)
            {
                AllowedState allowedState = (AllowedState)attribute;
                isInActiveState = false;
                allowedStates.Add(allowedState.Name);
            }
        }

        MethodInfo[] methods = GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

        foreach (MethodInfo m in methods)
        {
            System.Attribute[] attributes = (System.Attribute[])m.GetCustomAttributes(true);


            foreach (System.Attribute attribute in attributes)
            {
                if (attribute is OnEvent)
                {
                    OnEvent onEventMethod = (OnEvent)attribute;



                    if (m.GetParameters().Length == 2)
                    {
                        PMEvent del = (PMEvent)Delegate.CreateDelegate(typeof(PMEvent), this, m);
                        events.Add(new PairEventString(onEventMethod.Name, del));
                    }
                    else
                    {
                        PMEventLite del = (PMEventLite)Delegate.CreateDelegate(typeof(PMEventLite), this, m);
                        eventsLite.Add(new PairEventLiteString(onEventMethod.Name, del));
                    }



                    //	SEventSystem.Register ( onEventMethod.Name, (PMEvent)PMEvent.CreateDelegate( typeof(PMEvent), m ) );
                }
            }
        }
        RegisterAll();
        OnStateChange(StateController.GetActiveState());
    }
예제 #4
0
 public void Register(string id, PMEvent eventMethod)
 {
     if (id != "")
     {
         if (!events.ContainsKey(id))
         {
             events [id] = eventMethod;
         }
         else
         {
             events [id] += eventMethod;
         }
     }
     else
     {
         allEvents += eventMethod;
     }
 }
예제 #5
0
 public static void Unregister(string id, PMEvent eventMethod)
 {
     eventSystem.Unregister(id, eventMethod);
 }
예제 #6
0
 private void dateTimePicker_ValueChanged(object sender, EventArgs e)
 {
     datetime = dateTimePicker.Value;
     DisplayPD(datetime);
     PMEvent?.Invoke(this, e);
 }
예제 #7
0
 public PairEventString(string name, PMEvent @event)
 {
     this.Name  = name;
     this.Event = @event;
 }