Exemplo n.º 1
0
        public int FindMethod(object instance, string name)
        {
            int id;
            var hasMethod = _methodNames.TryGetIdOfName(name, out id);

            if (!hasMethod)
            {
                Func <IValue[], object> invoker = (IValue[] callParams) =>
                {
                    return(instance.GetType().InvokeMember(name,
                                                           BindingFlags.InvokeMethod | BindingFlags.IgnoreCase
                                                           | BindingFlags.Public | BindingFlags.OptionalParamBinding
                                                           | BindingFlags.Instance,
                                                           new ValueBinder(),
                                                           instance,
                                                           callParams.Cast <object>().ToArray()));
                };

                id = _methodNames.RegisterName(name);
                System.Diagnostics.Debug.Assert(_methodsCache.Count == id);

                _methodsCache.Add(invoker);
            }

            return(id);
        }
Exemplo n.º 2
0
        public int FindProperty(string name)
        {
            GetAllProperties();
            var hasProperty = _propertyNames.TryGetIdOfName(name, out var id);

            if (!hasProperty)
            {
                throw RuntimeException.PropNotFoundException(name);
            }

            return(id);
        }
Exemplo n.º 3
0
        public int FindMethod(string name)
        {
            int id;
            var hasMethod = _methodNames.TryGetIdOfName(name, out id);

            if (!hasMethod)
            {
                var methodInfo = _reflectedType.GetMethod(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
                if (methodInfo == null)
                {
                    throw RuntimeException.MethodNotFoundException(name);
                }

                id = _methodNames.RegisterName(name);
                System.Diagnostics.Debug.Assert(_methodsCache.Count == id);

                _methodsCache.Add(methodInfo);
            }

            return(id);
        }
Exemplo n.º 4
0
        public int FindProperty(string name)
        {
            int id;
            var hasProperty = _propertyNames.TryGetIdOfName(name, out id);

            if (!hasProperty)
            {
                var propInfo = _reflectedType.GetProperty(name, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public);
                if (propInfo == null)
                {
                    throw RuntimeException.PropNotFoundException(name);
                }

                id = _propertyNames.RegisterName(name);
                System.Diagnostics.Debug.Assert(_propertyCache.Count == id);

                _propertyCache.Add(propInfo);
            }

            return(id);
        }