Ejemplo n.º 1
0
        public ConstructorInfo GetConstructor(IEnumerable<Type> argTypes)
        {
            var comparer = new TypeComparer();

            return _type.GetConstructors(BINDING_FLAGS)
                         .Where(c => comparer.Equals(c.GetParameters()
                                                      .Select(p => p.ParameterType), argTypes))
                         .Union(_type.GetConstructors(BINDING_FLAGS)
                                      .Where(c => comparer.Assignable(c.GetParameters()
                                                                       .Select(p => p.ParameterType), argTypes)))
                         .FirstOrDefault();
        }
Ejemplo n.º 2
0
        public PropertyInfo GetIndexer(IEnumerable<Type> argTypes)
        {
            var matches = _type.GetProperties(BINDING_FLAGS)
                              .Where(p => p.Name.Equals("Item"));

            var comparer = new TypeComparer();

            return matches.Where(m => comparer.Equals(m.GetIndexParameters()
                                                       .Select(p => p.ParameterType), argTypes))
                          .Union(matches.Where(m => comparer.Assignable(m.GetIndexParameters()
                                                                         .Select(p => p.ParameterType), argTypes)))
                          .FirstOrDefault();
        }
Ejemplo n.º 3
0
        public MethodInfo GetMethod(string methodName, IEnumerable<Type> argTypes)
        {
            var matches = _type.GetMethods(BINDING_FLAGS)
                                .Where(m => m.Name.Equals(methodName))
                                .ToArray();

            var comparer = new TypeComparer();

            return matches.Count() == 1
                   && !argTypes.Any()
                   ? matches.First()
                   : matches.Where(m => comparer.Equals(m.GetParameters()
                                                         .Select(p => p.ParameterType), argTypes))
                            .Union(matches.Where(m => comparer.Assignable(m.GetParameters()
                                                                           .Select(p => p.ParameterType), argTypes)))
                            .FirstOrDefault();
        }