Ejemplo 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);
        }
Ejemplo n.º 2
0
        private void GetAllProperties()
        {
            if (_propertyCache != null)
            {
                return;
            }

            _propertyCache = new List <PropertyInfo>();

            var allProps = _reflectedType.GetProperties(BindingFlags.Instance | BindingFlags.Public);

            foreach (var propInfo in allProps)
            {
                _propertyNames.RegisterName(propInfo.Name);
                _propertyCache.Add(propInfo);
            }
        }
Ejemplo 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);
        }
Ejemplo 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);
        }