Ejemplo 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());
 }
Ejemplo 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
                    });
                }
            });
        }
Ejemplo n.º 3
0
 public static void UnregisterBehaviour(PlayMonoBehaviour behaviour)
 {
     if (!Behaviours.Contains(behaviour))
     {
         return;
     }
     Behaviours.Remove(behaviour);
     UnregisterBehaviour(behaviour, EventBehaviours);
     UnregisterBehaviour(behaviour, RPCBehaviours);
 }
Ejemplo 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);
 }
Ejemplo 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);
                }
            });
        }
Ejemplo n.º 6
0
 internal static MethodInfo Find(PlayMonoBehaviour host, string methodName, Type[] parameterTypes)
 {
     return(host.GetType().GetMethod(methodName, parameterTypes));
 }
Ejemplo 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());
 }