Most voted "reflection" questions
Reflection is the process by which a program can observe and modify its own structure and behavior at runtime. Commonly used to view metadata, associate methods and properties, and discover types.
Learn more…124 questions
Sort by count of
-
3
votes1
answer758
viewsPass Type parameter for generic Runtime method
I have a method I use to deserialize data: public static class CustomJson<T> where T: class, new() { public static T Deserialize(string data) { try { return string.IsNullOrEmpty(data) ?…
-
3
votes2
answers2092
viewsFill all fields of an Object iteratively
I have a Class public class Objeto { public int _numero { get; set; } public DateTime _data { get; set; } public string _palavra { get; set; } public decimal _decimal { get; set; } } Is it possible…
-
3
votes2
answers876
viewsIs it possible for me to create a runtime class in Python?
I wanted to create a runtime class to do some database updates, for example, but without being dependent on DBMS but using python and I wanted to know if it is possible to create these classes at…
-
3
votes1
answer379
viewsWhat is the difference between metaprogramming and reflection?
There are two terms that look a lot like when we are talking about introspection techniques: metaprogramming and reflection. Wikipedia treats reflection as a key strategy of metaprogramming…
-
3
votes4
answers815
viewsReflection of an Object that is owned by another
In my code I use a class called GenericField<T> which is used in all attributes of another class called Aplicacao. Until everything well, however, in another part of the code I need to get via…
-
3
votes1
answer170
viewsDifferences between __name__ and __qualname__
In Python functions/methods and classes have two attributes that in their most "basic" use seem to do exactly the same thing, are they: __name__ and __qualname__, see: def fn(): pass class…
-
3
votes1
answer424
viewsRun Java class by passing parameters to Scanner
Bestamos creating a programming championship in Java and we would like the students to make an algorithm that reads from a scanner and calculates a certain mathematical logic and returns in the…
-
3
votes1
answer169
viewsAdd classes to software at runtime
Question There is some feature that some language makes available to be able to add at runtime a class to the running software, that is, the software to recognize and thus be able to instantiate…
-
3
votes1
answer257
viewsInstantiating objects dynamically
When I create a new object within the repeat loop, it has the name in $sizeName, and try to access the method getUrl() get: Fatal error: Call to a Member Function geturl() on a non-object in ... on…
-
3
votes1
answer3537
viewsDynamic mapping error: Missing type map Configuration or Unsupported Mapping
I have a data dictionary something like this: public class Colunas { public string ColunaOrigem {get; set;} public string ColunaDestino {get; set;} public DbType Tipo {get; set;} } public class…
-
3
votes1
answer148
viewsConvert Dynamic to query string
Is there any more "elegant" way to convert a dynamic for a query string? I’m currently doing with several Replace() but it’s not quite what I wanted. string data = new { email = email, password =…
-
3
votes2
answers1387
viewsName of fields of a generic object - Reflection
Good morning, everyone. I have a problem that I believe can be solved with Reflection, but I do not know how to use and I hope you can help me in my difficulty. I have an object that will be passed…
-
3
votes1
answer55
viewsCreate a method that receives a generic class?
I’ve been racking my brain with the Reflection API. I am writing a class (reader) that reads a CSV file and creates an Arraylist of objects based on CSV. I made a test class to write the code, only…
-
2
votes1
answer1821
viewsTake all classes of a given Package that is in the classpath
I’m needing to take all the classes of a certain package, I’ve seen some codes that do this, but it only takes the classes that are part of the project itself, basically doesn’t use Reflection and…
-
2
votes1
answer247
viewsHow to use Reflection
How and why to use Reflection? Is it very useful in everyday life? Its use offers some gain for the system itself?
-
2
votes3
answers86
viewsSetting a Field for a Proxy
Hello, I’m having a problem: I need to change the value of a Field to a proxy. My proxy works perfectly, but I can’t modify a Field. Whenever I try returns me an Illegalargumentexception saying I…
-
2
votes1
answer79
viewsJava, difference between Integer.TYPE and int.class
What is the difference between using Integer.TYPE and int.class? I did some tests and both can be passed as a parameter to a Class<?>.
-
2
votes1
answer2235
viewsException org.hibernate.Propertyaccessexception: could not set a field value by Reflection Setter
I’m trying to map the following model in JPA with Hibernate: Company table: CREATE TABLE empresa ( id_empresa INT(11) NOT NULL AUTO_INCREMENT , PRIMARY KEY (id_empresa) ) ENGINE = InnoDB DEFAULT…
-
2
votes1
answer101
viewsHow to open a form with just the name of the type
I have a DataGridView in my form, remembering that it gets the name of the Mysql database forms. I’ve tried a few ways to click the form name on DataGridView and open the same, but did not succeed.…
-
2
votes1
answer924
viewsHow to create a runtime class?
How to create a runtime class, or Runtime, dynamically, from a Dictionary<TKey, TValue>, for example, with C#? Dictionary<string, string> dicionario = new Dictionary<string,…
-
2
votes1
answer51
viewsHow to catch serial fields with Javafx reflecition API?
I have a form with several Checkboxs, which I named C1, C2, C3, C4, C5...until C66. So: @FXML private CheckBox c1; @FXML private CheckBox c2; . . . @FXML private CheckBox c66; Now I want to do an…
-
2
votes1
answer2062
viewsList all properties of a C#object?
I need to write all the primitive properties of a C# object regardless of how many "levels" I enter these objects. I have the following object in Javascript: var objeto = { propriedade:{ valor:42 },…
-
2
votes1
answer146
viewsReflection with list property
How to change the value of the class property in the list? My variable classPropValueList always comes void. I’m trying to make a Reflection of every class it inherits from Coisable, to change its…
-
2
votes1
answer195
viewsIs it possible to store files in an executable?
I need to store a file, no matter its extension (it’s mainly an Executable) within another executable. It’s just, I’m compiling with Codedom an executable that inside it there is a file "special"…
-
2
votes1
answer40
viewsRemove virtual properties from Typedescriptor.Getproperties()
I did a question how to use Sqlbulkcopy, the @Virgilionovic user showed me a code that uses Reflection to save any kind of list, but I do the TypeDescriptor.GetProperties() he brings the properties…
-
2
votes1
answer544
viewsCheck null or empty fields in an entity without consecutive use of "if-Else"
In a system integration there are data updates on both sides, where you get the record of Side A and the record of side B. If there are null fields in A and these exist in B then A is supplemented…
-
2
votes1
answer233
viewsInvoking a method by reflection
I took a look at that question You can pass methods as a parameter? and tried to invoke a method from one class, in another, passing as parameters the screen/class and the method name. The purpose…
-
2
votes1
answer193
viewsInstantiate a Map object only when necessary based on a regex
I have a Factory what instance the PARSER responsible for extracting information from a particular invoice format. To determine the invoice format I use regex. I loop every regex added to Map and…
-
2
votes1
answer779
viewsJAVA - Creating an instance of an object in a class?
So, I have a class called "Geraform" that I need to return a HTML-style string with some information contained in an annotation. I got the code to work when I pass a certain class to it, but I would…
-
2
votes2
answers79
viewsDetecting if a Setter of a property has been called
Hello I wonder if there is a way to find out if the value of a property has changed. Example public partial class MinhaClasseExemplo { public int Id { get; set; } public String Nome { get; set; }…
-
2
votes1
answer26
viewsAccess method of type String with Reflection
I have the following class of Enum: public enum Teste { TESTE( 101, "Teste" ), MUNDO( 601, "Mundo" ); private final String descricao; private final int codigo; Teste( int codigo, String descricao )…
-
1
votes1
answer112
viewsIsGenericType, GetGenericTypeDefinition e Nullable.GetUnderlyingType
In a code snippet I was suggested the use of these three members in order to verify if the properties of an object are Nullable. p.PropertyType.IsGenericType &&…
-
1
votes1
answer344
viewsHierarchical Object Filter
I have an Asp.net MVC 4.5 C# Razor screen typed by a main class: public class ClassePaiDTO { public virtual ICollection<Filho1DTO> Filho1s { get; set; } public virtual…
-
1
votes1
answer765
viewsHow to access the value of a private attribute in a Java class without a public method?
How can I access the value of a private attribute in a class, a class in another package, without using an access method, such as a getter? class Person{ private String name = "Someone"; } Why would…
-
1
votes0
answers25
viewsReflections with Kotlin
I need to compare a Kparameter with a Kclass, know if the type of the parameter is equivalent to my Kclass. So far I have not found a saint to do this, someone has my solution?
-
1
votes1
answer46
viewsJava Reflection nested objects
Hello, good afternoon everyone. I’m studying java Reflection and my question is whether it would be possible and how to pick up nested objects dynamically as in the example below: public class Rg{…
-
1
votes1
answer95
viewsIllegalaccessexception when reading values with Reflection
I cannot read the attributes values of the class with Reflection: ContentValues values = new ContentValues(); Field[] fields = this.getClass().getDeclaredFields(); for (Field field: fields ) {…
-
1
votes0
answers83
viewsReflection with Property Developer in typescript does not work
I am trying to create a developer (Nonexportable) to inform which fields of a class should not be exported. Follow code: nonexportable-decorators.ts const NON_EXPORTABLE_KEY =…
-
1
votes3
answers219
viewsCheck function existence in C#
How can I verify if a function exists in C#? I think I have to use some kind of reflection, but I don’t know much about it. Is there any way to get the function’s list of arguments, if it exists?…
-
1
votes1
answer992
viewsCheck if there is value in the enumeration by the attribute and return its value
It is possible to produce simpler code for this function without changing the enum? /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]…
-
1
votes1
answer191
viewsRun method of one nested class as property in another in C#
I have the following class: public class Feliz : IFeliz { //public algumas propeiedades e tals... { get; set; } public bool EstaFeliz() { //Faz alguma coisa... } } And she’s a property in another…
-
1
votes1
answer121
viewsPassing a type created in Runtime for a statistical method
EDIT My problem is this. I need to generate a lambda expression that is of a type that I will only know at the time of execution, IE, the type to be used will be passed in the parameter classType of…
-
1
votes1
answer27
viewsProblem with Reading Attribute in c#
I have the following problem, I have my ENUM class: public enum DataBaseType { DATA_BASE_NAME, SERVER_IP_NAME, PORT, USER_NAME, PASSWORD }; I have my Attributo, in which you have this ENUM: public…
-
1
votes1
answer99
viewsHow to create an extension method for the type of a class in VB.NET
I’m creating a MVC structure that will work similar to the Entity Framework within a VB.NET project where I created an attribute called TableAttribute which will define the table and the schemas to…
-
1
votes2
answers923
viewsAccess object attribute passed as generic parameter
In my application I have a chained list class that takes a generic parameter, which is the type of value the list will store. In this case, I am passing as parameter the class Usuario, I need to…
-
1
votes1
answer456
viewsCreating a new Object, and populating its properties, using Java Reflection
Hello, I need to invoke a method via reflection, Method.invoke(Objeto, arg); Object -> Object created from Class.newInstance() Arg -> is the value I want to pass. And I know it’s a String. But…
-
1
votes0
answers43
viewsUse EWS API with C#Reflection
I am trying to use the EWS API in SSIS Script Task, but the server does not have the corresponding dll: Microsoft.Exchange.WebServices.dll So using Reflection is the only solution I found, the dll…
-
0
votes1
answer48
viewsHow to get a Type from a string
For example, I want a string containing the information "System.Windows.Forms.Button" return a button object New Button(), would that be possible? Note: Is tagged C# as it is easy to translate from…
-
0
votes1
answer166
viewsProblem adding an element to a collection at runtime
In this my method I must fill a Collection, regardless of its type public void loadBeanCollectionItems(B bean, Collection collection, JSONArray collectionJson) { for(int index = 0; index <…
-
0
votes2
answers483
viewsMatch content of two objects
Use the method below to update a given table: public int alteraBem(tb_bens itemBem) { try { using (GestaoAtivoEntities db = new GestaoAtivoEntities()) { var bem = db.tb_bens.Where(v =>…