Reflection is the process by which a program can observe and modify its own structure and behavior at runtime.

learn more… | top users | synonyms

0
votes
0answers
15 views

Validating all of model's properties are accounted for in form using reflection

We have run into instances where someone would add columns to a table in the database, update the Entity Framework models for our solution, but forgot to update the forms to compensate for the added ...
3
votes
2answers
205 views

Set Game State from String

Before I used reflection to invoke a state based on the string. It looked like this. ...
1
vote
4answers
56 views

Python Decorator - inspecting function argument values

Some of my functions use a "fail_silently" flag. It is used in the following way: ...
5
votes
2answers
108 views

Recursively merge dictionaries with generic types in C#

I am looking to implement a method that is capable of merging 2 dictionaries using generics. I've seen several great answers on SO already, but none handle the case of nested dictionaries. As in, what ...
1
vote
0answers
135 views

Retrieving Primary Key from Entity Framework entity

Entity Framework (version 6) generates classes based on your tables that look like this (where each property represents a field in the table): ...
6
votes
1answer
133 views

JSON serializer using generics rather than System.Object

I recently created a custom static class in C# to encode, hopefully, any object it is given (or collection of objects), because I was, at the time, unaware of a native C# library that did the same ...
4
votes
1answer
58 views

Porting a web-based POS system to Android

I'm currently porting a web-based POS system to Android. The Android version uses NavigationDrawer to navigate between menus. What I need a code review on is my ...
2
votes
3answers
114 views

Property Mapping with Reflection efficiency

I have an object that I am populating via mapping and lookup with Reflection: ...
2
votes
2answers
50 views

config.properties, Static Classes and Reflection

I wanted an opinion about an idea I had regarding the use of config.properties, static classes and the use of reflection. I have to load some preferences at application startup, for that I will be ...
6
votes
2answers
155 views

Building in the built-in declarations

In order for Rubberduck to be able to "recognize" the built-in VBA functions, procedures and objects, I added yet another constructor parameter to my Declaration ...
10
votes
2answers
283 views

Optimize a generic foreach method that converts Datatable to my object using Reflection

I need to optimize this code block below, this method converts a Datatable object to the Object that I am passing by parameter, in another words, this serializes the object, however I have to run this ...
4
votes
2answers
103 views

Type Name or Alias via Reflection for TT Code Generation

I was working on some TT code generation to get rid of mundane C# codings in VS2013 Express Edition, and after researching online, created the following helper methods to facilitate Type declarations. ...
2
votes
1answer
69 views

Implementing transaction method with invoking business methods in a one transaction

Because the ambient transaction isn't supported with informix, I pass the transaction and the connection through my methods. I ...
1
vote
0answers
58 views

Using interface for generated functions or just create plain functions

I was wondering which code might be better. I'm abstracting away the rote code as follows: ...
5
votes
2answers
384 views

Java MVC model for large scale GUI using annotations

I'm trying to make a good MVC model using annotations, which I will use it in a large scale GUI project. I want to respect the maximum of rules and guidelines, and be able to decorrelate every parts ...
6
votes
3answers
187 views

Avoid static initializer for lists of image and video formats?

I wrote the following code to read constants from annotations: ...
8
votes
2answers
235 views

Generic queries and handlers without reflection

I'm trying to implement generic queries and handlers so that I can make requests with simple syntax, like this: ...
3
votes
2answers
80 views

Validator part 2

This is a follow up to: Validating individual properties and whole items I have a custom class I've written which allows me to validate individual properties of items, without firing validation ...
2
votes
0answers
40 views

'Tag' packages and make them discoverable

We have another team who is going to expose class packages for use to scan and pickup details from. If they should add some new packages or rename old ones I don't want to have to recode a thing. I am ...
2
votes
2answers
79 views

Function caller (to multiple receivers) interface

This class is designed to call a similar function of multiple objects of multiple classes using a single interface (it is not for calling functions that return a value). A potential usage will be ...
5
votes
2answers
6k views

Check if any of class properties is not null/empty/was assigned

I have a class that I use to display on a web page fieldset. However, all of the properties of this class are optionally filled in by the user, which means all of them could be null/default. In this ...
4
votes
2answers
87 views

Reflection and Project Euler

I have made a Project Euler runner in order to facilitate the running of the various problems. I have never used reflection before, and I believe that I have found a good use for reflection within ...
5
votes
1answer
103 views

Autowiring publishers/listeners with reflection in Unity Framework

I'm currently building an application with the Microsoft Unity Framework. I also use a simple system of message publishers/listeners inspired from MVVM light and caliburn: The listener interface ...
5
votes
2answers
259 views

Loading data into a number of different typed List<T>s: Can I do without reflection?

I'm not sure whether my distaste for reflection is justified or not, but it feels ucky that I'm using reflection here. I'm trying to make a very simple class which has a number of ...
5
votes
2answers
210 views

Evaluating algebra expression using an auxiliary VB class compiled on the fly and consumed in a C# project

I want to create algebra evaluator but I don't want to write my own parser because it takes much time to learn. I don't like algebra expression in C# because it does not look natural compared to VB ...
4
votes
1answer
3k views

Transform DataReader to List<T> using reflections

I have implemented the code to convert datareader to list of objects. My intention was to not to use column name string literals while reading the datareader. ...
6
votes
2answers
1k views

Using Reflection to Initialize Instance Variables

I'm facing the issue of how to reconstruct data across a network in Java. As part of my Component based game engine (read about it here, I have to encode components as XML on the server, send it to ...
2
votes
1answer
198 views

Speed problems with SetValue, ToType and Reflection

I have a 'speed problem' with a program I'm currently developing. I already have encountered the methods which costs some time. ...
4
votes
1answer
500 views

Speed problems with SetValue, ToType and Reflection

I have a 'speed problem' with a program im currently developing. I already have encountered the methods which costs some time. ...
6
votes
2answers
137 views

My EventBus system followup

This question is a followup from my previous question My EventBus system, and incorporates most points from @rolfl's answer. It includes, but is not limited to: Usage of ...
7
votes
1answer
118 views

My EventBus system

I decided to roll out my own EventBus system which is intended to be thread-safe. Hence a review should focus extra on thread safety apart from all regular concerns. The ...
6
votes
5answers
309 views

Initializing JTree

I have a class called Piece, and many many subclasses of Piece. I want to add an instance of every single subclass of ...
5
votes
3answers
1k views

Get nested type name without namespace

Suppose I have a nested class structure like this: ...
4
votes
0answers
154 views

Leverage C++ Type Inference and basic Reflection library

I've finished my fist iteration on a type inference and basic reflection library for C++, which is part of a small game engine I'm writing on my spare time. It features type instantiation by name/id ...
10
votes
2answers
1k views

Override equals() and hashCode() using reflection

I wrote a utility method to override equals() using reflection. This works fine, but I wonder if this code will pass all the tests. ...
4
votes
2answers
175 views

comparing objects; optimize code short of using reflection

I'm comparing two distinct instances and if they are not the same I save to the dB, so I've given snippet of code below of the way I am comparing these instances, I realize I could use reflection and ...
5
votes
1answer
82 views

Setting up keyboard bindings using JSON and reflection

My game uses configuration files in JSON format. One of them is used for setting up control bindings, and it looks like this: ...
6
votes
1answer
5k views

A generic way to use LINQ to Entity with types and operations unknown until run time

A question was asked here about reflection and LINQ to entity. I'm trying to modify the code that was presented to fit my needs. Here's what I am trying to accomplish: I'm writing back-end support ...
6
votes
2answers
425 views

Using reflection to connect to an arbitrary backend

A little background first - I'm working on a server application that requires the ability to use multiple data access class libraries based on the resources available on the server it is installed on ...
6
votes
1answer
3k views

Variadic macro enum class “reflection” in C++11

I recently had the need of "reflecting" multiple enum class constructs in order to get their elements' names as std::string ...
4
votes
2answers
129 views

Can my string to instance construction be improved?

I have a Dictionary<string, object> (named tableDict) that has been parsed from JSON. The ...
2
votes
1answer
404 views

Java reflection: Inject data generically and safely

I have become interested in reflection and I wrote a class to wrap an Object so that I can access its private instance fields. The code works great. I do not need to wory about the exceptions in the ...
3
votes
1answer
55 views

Collect all fields having given Modifier(s)

I want to collect all fields which have given Modifier(s) of a class. I have written following pieces of codes: ...
6
votes
2answers
2k views

Function that builds dictionary based on lambda params

I've written a method in c# that allows me to do create a dictionary from a passed in object and N lambda expressions that reference that objects properties and methods. It's working the way I want it ...
3
votes
1answer
82 views

How can I improve my Java MethodPointer?

This was just an experiment to see if I could replicate something like C++ function pointers in Java. Basically, the idea was to have an object which represented a method call, and when you call ...
2
votes
1answer
307 views

Is this the right way to retrieve all the fields from any Object?

I have a method that returns a List<Object> from any given Object containing its values. It doesn't get the values of any ...
8
votes
1answer
328 views

Improve this reflection bashing code

I have implemented an IDataContractSurrogate to enable serialization of ImmutableList<T> (from the Microsoft Immutable ...
2
votes
2answers
672 views

Extension methods for class Type

While working on one of my projects I actively used Reflection. While working with class Type I expected methods: TryGetMember, ...
2
votes
1answer
653 views

Java reflection and static classes

I try to intercept some OpenGL calls for testing my rendering classes. Reflection is used for replacing the OpenGL backend. I feel this class is badly written and I need advices for refactoring it. ...
3
votes
1answer
113 views

How to avoid echoing JavaScript from PHP?

I want to use some constant in both server side and client side. Currently, I use PHP reflection in order to synchronize PHP constants and Javascript constants. But for the maintainable reason, it's ...