public override bool Equals(object obj)
        {
            MessagePrototype other = (MessagePrototype)obj;

            if (name != other.name)
            {
                return(false);
            }

            if (!returnType.Equals(other.returnType))
            {
                return(false);
            }
            else
            {
                if (parameterTypes.Length != other.parameterTypes.Length)
                {
                    return(false);
                }
                else
                {
                    for (int i = 0; i < parameterTypes.Length; i++)
                    {
                        if (!parameterTypes[i].Equals(other.parameterTypes[i]))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
        public static MessagePrototype Create( string _name,MethodInfo minfo )
        {
            MessagePrototype newPrototype = new MessagePrototype();

            DocumentationAttribute docAttr = Attribute.GetCustomAttribute(minfo,typeof(DocumentationAttribute) ) as DocumentationAttribute;

            if (docAttr != null)
            {
                newPrototype.documentation = docAttr.Documentation;
                newPrototype.description = docAttr.Description;
            }

            // Build up prototype.
            newPrototype.parameterTypes = new Type[minfo.GetParameters().Length];
            for (int i = 0; i < newPrototype.parameterTypes.Length; i++)
            {
                newPrototype.parameterTypes[i] = minfo.GetParameters()[i].ParameterType;
            }

            newPrototype.returnType = minfo.ReturnType;
            newPrototype.name = _name;

            return newPrototype;
        }
Exemplo n.º 3
0
        private void Initialize(IActor actor)
        {
            // First get all public methods.
            MethodInfo[] allMethods = actor.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic);

            foreach (MethodInfo m in allMethods)
            {
                // Check if its a method handler.
                MessageHandlerAttribute messageAttribute = Attribute.GetCustomAttribute(m, typeof(MessageHandlerAttribute)) as MessageHandlerAttribute;

                if (messageAttribute != null)
                {
                    string messageName = messageAttribute.Name;

                    if (messageName == string.Empty)
                    {
                        messageName = m.Name;
                    }

                    // Store it.
                    if (!methods.ContainsKey(messageName))
                    {
                        MessagePrototype newPrototype = MessagePrototype.Create(messageName, m);

                        methods.Add(messageName, m);
                        prototypes.Add(messageName, newPrototype);
                    }
                }
            }

            returnArray = new MessagePrototype[prototypes.Count];
            prototypes.Values.CopyTo(returnArray, 0);

            // Handle the dispatch
            realCall = new MessageDebugger.DebugMessageDelegate(this.CallMethod);
        }
        public static MessagePrototype Create(string _name, MethodInfo minfo)
        {
            MessagePrototype newPrototype = new MessagePrototype();

            DocumentationAttribute docAttr = Attribute.GetCustomAttribute(minfo, typeof(DocumentationAttribute)) as DocumentationAttribute;

            if (docAttr != null)
            {
                newPrototype.documentation = docAttr.Documentation;
                newPrototype.description   = docAttr.Description;
            }

            // Build up prototype.
            newPrototype.parameterTypes = new Type[minfo.GetParameters().Length];
            for (int i = 0; i < newPrototype.parameterTypes.Length; i++)
            {
                newPrototype.parameterTypes[i] = minfo.GetParameters()[i].ParameterType;
            }

            newPrototype.returnType = minfo.ReturnType;
            newPrototype.name       = _name;

            return(newPrototype);
        }