示例#1
0
        public void InvokeMethod(object instance, uint fieldId, params object[] parameters)
        {
            if (!HasField <ToffeeMethod>(fieldId))
            {
                throw new ToffeeException("Tried to invoke method '{0}' on class '{1}' but it doesn't exist.", Name, fieldId);
            }
            ToffeeMethod method = GetField <ToffeeMethod>(fieldId);

            method.Invoke(instance, parameters);
        }
示例#2
0
        public void AddMethod(MethodInfo methodInfo, ToffeeModifiers modifiers = ToffeeModifiers.None)
        {
            ToffeeMethod method = new ToffeeMethod(this, methodInfo, modifiers);

            if (HasField(method.Identifier))
            {
                throw new ToffeeException("Class '{0}' already has field with name: '{1}'.", Name, method.Identifier);
            }
            if (HasField(method.FieldId))
            {
                throw new ToffeeException("Class '{0}' already has field with id: '{1}'.", Name, method.FieldId);
            }

            AddField(method);
            _Methods.Add(method);
            MethodIdentifierLookup.Add(method.Identifier, method);
            MethodLookup.Add(method.FieldId, method);
        }