Esempio n. 1
0
 internal static IEnumerable <MethodInfo> Find <T>(PlayMonoBehaviour host)
     where T : Attribute
 {
     return(host.GetType().GetMethods()
            .Where(m => m.GetCustomAttributes(typeof(T), false).Length > 0)
            .ToArray());
 }
Esempio n. 2
0
        internal static void RegisterBehaviour <T>(PlayMonoBehaviour behaviour, IDictionary <string, IList <PlayMonoBehaviour> > methodBehaviours)
            where T : Attribute
        {
            var methods = Play.Find <T>(behaviour);

            methods.Every(m =>
            {
                if (methodBehaviours.ContainsKey(m.Name))
                {
                    var behaviours = methodBehaviours[m.Name];
                    if (behaviours == null)
                    {
                        behaviours = new List <PlayMonoBehaviour>();
                    }
                    behaviours.Add(behaviour);
                }
                else
                {
                    methodBehaviours.Add(m.Name, new List <PlayMonoBehaviour>()
                    {
                        behaviour
                    });
                }
            });
        }
Esempio n. 3
0
 public static void UnregisterBehaviour(PlayMonoBehaviour behaviour)
 {
     if (!Behaviours.Contains(behaviour))
     {
         return;
     }
     Behaviours.Remove(behaviour);
     UnregisterBehaviour(behaviour, EventBehaviours);
     UnregisterBehaviour(behaviour, RPCBehaviours);
 }
Esempio n. 4
0
 /// <summary>
 /// register message noticitication.
 /// </summary>
 /// <param name="behaviour">PlayMonoBehaviour instance</param>
 public static void RegisterBehaviour(PlayMonoBehaviour behaviour)
 {
     if (Behaviours.Contains(behaviour))
     {
         return;
     }
     Behaviours.Add(behaviour);
     RegisterBehaviour <PlayEventAttribute>(behaviour, EventBehaviours);
     RegisterBehaviour <PlayRPCAttribute>(behaviour, RPCBehaviours);
 }
Esempio n. 5
0
        internal static void UnregisterBehaviour(PlayMonoBehaviour behaviour, IDictionary <string, IList <PlayMonoBehaviour> > methodBehaviours)
        {
            var methodBehaviourListCollection = methodBehaviours.Values;

            methodBehaviourListCollection.Every(behaviours =>
            {
                if (behaviours.Contains(behaviour))
                {
                    behaviours.Remove(behaviour);
                }
            });
        }
Esempio n. 6
0
 internal static MethodInfo Find(PlayMonoBehaviour host, string methodName, Type[] parameterTypes)
 {
     return(host.GetType().GetMethod(methodName, parameterTypes));
 }
Esempio n. 7
0
 internal static MethodInfo Find <T>(PlayMonoBehaviour host, string methodName) where T : Attribute
 {
     return(host.GetType().GetMethods()
            .Where(m => m.GetCustomAttributes(typeof(T), false).Length > 0 && m.Name == methodName).FirstOrDefault());
 }