reflection

CreateDelegate with unknown types

亡梦爱人 提交于 2020-02-10 08:58:10
问题 I am trying to create Delegate for reading/writing properties of unknown type of class at runtime. I have a generic class Main<T> and a method which looks like this: Delegate.CreateDelegate(typeof(Func<T, object>), get) where get is a MethodInfo of the property that should be read. The problem is that when the property returns int (I guess this happens for value types) the above code throws ArgumentException because the method cannot be bound. In case of string it works well. To solve the

Invoke a method using reflection with the “params” keyword without arguments

旧城冷巷雨未停 提交于 2020-02-04 09:05:35
问题 Just like this question I'm having issues invoking a method that has the "params" keyword. I keep getting TargetParameterCountException exceptions. "Parameter count mismatch". The goal is to call this method with no parameters: IList<T> List(params Expression<Func<T, object>>[] includeProperties); Here is what I have so far: //Get generic type var entityType = typeof(Applicant).Assembly.GetType(string.Format("Permet.BackEnd.ETL.Domain.Models.{0}", tableName)); //create service that will

Invoke a method using reflection with the “params” keyword without arguments

被刻印的时光 ゝ 提交于 2020-02-04 09:04:54
问题 Just like this question I'm having issues invoking a method that has the "params" keyword. I keep getting TargetParameterCountException exceptions. "Parameter count mismatch". The goal is to call this method with no parameters: IList<T> List(params Expression<Func<T, object>>[] includeProperties); Here is what I have so far: //Get generic type var entityType = typeof(Applicant).Assembly.GetType(string.Format("Permet.BackEnd.ETL.Domain.Models.{0}", tableName)); //create service that will

Invoke a method using reflection with the “params” keyword without arguments

走远了吗. 提交于 2020-02-04 09:04:19
问题 Just like this question I'm having issues invoking a method that has the "params" keyword. I keep getting TargetParameterCountException exceptions. "Parameter count mismatch". The goal is to call this method with no parameters: IList<T> List(params Expression<Func<T, object>>[] includeProperties); Here is what I have so far: //Get generic type var entityType = typeof(Applicant).Assembly.GetType(string.Format("Permet.BackEnd.ETL.Domain.Models.{0}", tableName)); //create service that will

Which are the right Matrix Values to use in a metal shader passed by a SCNProgram to get a correct chrome like reflection

核能气质少年 提交于 2020-02-04 01:46:09
问题 I am working on an App, that should render a chrome-style reflective sphere-like object inside a skybox (using a six faced cube map). I am doing this in Swift using Scenekit with different approaches. Everything is fine and perfectly reflected (see Figure 1 below) as long as I let Scenekit doing all the work - in other words, using a standard SCNMaterial with metalness 1.0, roughness 0.0 and color UIColor.white (using .physicallyBased as lighting model) attached to the firstMaterial of the

Creating an instance from a class name

倾然丶 夕夏残阳落幕 提交于 2020-02-04 01:33:43
问题 I'm trying to create an instance of a class at run time. The classes I'm trying to create all inherit from a base class, ConfigMgrObj, and are named ConfigMgr_xxxxxx e.g. ConfigMgr_Collection . They all take a special object that I'm calling oController and a string as arguments. This is the line I'm using to do it, where ClassToGet is a string that contains the name of the class e.g. ConfigMgr_Collection . object oNewObject = System.Activator.CreateInstance(null, "StackOverflowNamespace." +

How can get an instance from .class file in java

痴心易碎 提交于 2020-02-03 12:23:13
问题 Frankly, I do not know even it is possible or not. But what I am trying to do is just like below. I made a class file from ClassFile.java via javac command in terminal. Then I want to get an instance from .java file or .class file. Next, I made another project in eclipse, As you guess this project path and upper file path are completely different. For instance, ClassFile.java/class file can be located in '~/Downloads' folder, the other hand, new eclipse project can be in '~/workspace/'. So I

Is this a bug in .Net reflection?

[亡魂溺海] 提交于 2020-02-03 07:57:53
问题 ANSWER is: No, this is not a bug. The difference is in the ReflectedType. So the real question here is: Is there a way of comparing two PropertyInfo objects, for the same property, but reflected from different types, so that it returns true ? Original question This code produces two PropertyInfo objects for the very same property , by using two different ways . It comes that, these property infos compare differently somehow. I have lost some time trying to figure out this out. What am I doing

Is this a bug in .Net reflection?

倖福魔咒の 提交于 2020-02-03 07:57:16
问题 ANSWER is: No, this is not a bug. The difference is in the ReflectedType. So the real question here is: Is there a way of comparing two PropertyInfo objects, for the same property, but reflected from different types, so that it returns true ? Original question This code produces two PropertyInfo objects for the very same property , by using two different ways . It comes that, these property infos compare differently somehow. I have lost some time trying to figure out this out. What am I doing

Is this a bug in .Net reflection?

不问归期 提交于 2020-02-03 07:57:07
问题 ANSWER is: No, this is not a bug. The difference is in the ReflectedType. So the real question here is: Is there a way of comparing two PropertyInfo objects, for the same property, but reflected from different types, so that it returns true ? Original question This code produces two PropertyInfo objects for the very same property , by using two different ways . It comes that, these property infos compare differently somehow. I have lost some time trying to figure out this out. What am I doing