Ejemplo n.º 1
0
        public static bool AddBehaviour(int key, BehaviourBase behaviour)
        {
            if (behaviour == null)
            {
                return(false);
            }

            int priority = behaviour.Priority;

            if (_loadedBehaviours.ContainsKey(key))
            {
                if (_loadedBehaviours[key].Priority < priority)
                {
                    _loadedBehaviours[key] = behaviour;
                }
            }
            else
            {
                _loadedBehaviours.Add(key, behaviour);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        private static void AddBehaviour <T>(BehaviourBase behaviour, T targetObject) where T : MemberInfo
        {
            if (behaviour == null)
            {
                return;
            }

            AddBehaviour(behaviour);

            if (OnBehaviourLoadedWithContext != null && behaviour != null)
            {
                OnBehaviourLoadedWithContext(behaviour, targetObject);
            }
        }
Ejemplo n.º 3
0
        private static void AddBehaviour(BehaviourBase behaviour)
        {
            if (behaviour == null)
            {
                return;
            }

            bool added = AddBehaviour(behaviour.GetHashCode(), behaviour);

            if (OnBehaviourLoaded != null && behaviour != null)
            {
                OnBehaviourLoaded(behaviour);
            }

            if (added && behaviour != null && OnBehaviourAdded != null)
            {
                OnBehaviourAdded(behaviour);
            }
        }
 private static void OnBehaviourLoaded(BehaviourBase behaviour)
 {
     if (behaviour is TypeBlockerAttribute typeBlocker)
     {
         foreach (Type type in typeBlocker.TypeFunction())
         {
             if (!_blockedTypes.Contains(type))
             {
                 _blockedTypes.Add(type);
             }
         }
     }
     else if (behaviour is MemberBlockerAttribute memberBlocker)
     {
         foreach (string member in memberBlocker.MemberFunction())
         {
             if (!_blockedMembers.Contains(member))
             {
                 _blockedMembers.Add(member);
             }
         }
     }
 }