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

learn more… | top users | synonyms

4
votes
2answers
92 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 ...
4
votes
2answers
60 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
101 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
519 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 ...
1
vote
0answers
80 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. ...
3
votes
0answers
119 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
99 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
87 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
159 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
313 views

Get nested type name without namespace

Suppose I have a nested class structure like this: ...
3
votes
0answers
79 views

Leverage C++ Type Inference and basic Reflection library

I've just 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 ...
10
votes
2answers
482 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
108 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
56 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
2k 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
387 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
1k 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
122 views

Can my string to instance construction be improved?

I have a Dictionary<string, object> (named tableDict) that has been parsed from JSON. The ...
1
vote
1answer
191 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
50 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: ...
3
votes
2answers
752 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
60 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
158 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
239 views

Improve this reflection bashing code

I have implemented an IDataContractSurrogate to enable serialization of ImmutableList<T> (from the Microsoft Immutable ...
2
votes
2answers
425 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, ...
3
votes
1answer
345 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
96 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 ...
2
votes
1answer
216 views

PHP ORM like system

I'm using PDO, but I want to create my own class for more convenient work with the database. My main idea in example with comments: ...
0
votes
3answers
370 views

New to LINQ, not sure this is best practice

So i have a super class that has a 3 child classes. Those 3 child classes have multiple classes of their own. I was having troubles saving this into XML, so I decided to parse it out and do a little ...
2
votes
1answer
208 views

Multiple target method invocation wrapper

I'm currently working on a system using WCF to communicate between a Windows Service and one or multiple clients. Service is required to answer clients calls, as well as notify them of certain events, ...
2
votes
1answer
57 views

ORM Entity with many similar relationships

To provide some background context, I'm implementing a web-based solution (Java, Spring, Hibernate) that allows the creation/authoring of task-centric workflow documents. Basically a workflow ...
8
votes
2answers
392 views

Evaluate the best common type to fit both of types

Here is an algorithm to evaluate best matching System.Type for two types in hierarhy. This is one of answers for this StackOverflow question by Ken Kin: ...
5
votes
1answer
2k views

Inject dependency into PostSharp aspect

I have designed couple of aspects using PostSharp for different projects, but there is a design flaw in many of them: dependency management. This is a question about injection of dependencies into ...
7
votes
2answers
125 views

Action based controller using reflections

I'm modeling a reflection-based controller. I would like to know if you agree with my implementation and about what could be enhanced. I'm starting with reflection and I would like to know if I'm ...
1
vote
1answer
256 views

PHP class and interface interrogation using reflection

I have been working on a class to use Reflection to interrogate other PHP classes and interfaces, what I want to know from anyone with more experience of this is, is there anything else I can add, or ...
1
vote
1answer
492 views

PHP Lazy loading with __get - yay or nay?

I have my own PHP MVC framework that I'm iteratively developing (i.e. adding a feature when I have the time). I'm trying to keep it to the best practices I can, while still adding the most in terms of ...
4
votes
1answer
3k views

Usage of Expression<Func<T>>

I am developing data-interfacing that converts between two different data models. However, I must be sure that all required fields exist. Therefore I have written this utility class that I can easily ...
4
votes
3answers
1k views

Ruby fibonacci(n) recursive computation optimized with reflection. Is this good Ruby?

I'm coming from Java and this is my first attempt with Ruby reflection. The idea is to take the common-known (and awfully bad performing) fibonacci(n) recursive method: ...
2
votes
2answers
3k views

How can an Enumeration with Descriptions be cast into a Dictionary?

The Enumeration in question is based on int, so the following Extension returns a Dictionary<int, string> of the Enum's ...
5
votes
0answers
320 views

Basis of custom C++ serialization lib

I know it's been done a million times already, but I couldn't find a serialization library to suit my needs. This is the very basis of what I came up with. I know the code is ugly and unstructured, so ...
7
votes
2answers
783 views

Attribute Driven Behaviour in C# Methods

We want to create a TransactionScope Factory class that we can use as a central point for instantiating TransactionScopes with ...
2
votes
1answer
4k views

Query String Serializer

I have a ASP.NET Web Forms project, and I want to build calls to .aspx pages in a strongly-typed fashion. I ended up rolling my own serializer that takes simple structs and saves them to/loads them ...
4
votes
2answers
2k views

Returning Groovy class fields as a map

I want to get a map of all the fields in a class (aka value object) in a generic way. The following works fine for me: ...
4
votes
2answers
410 views

C# overload method simplification

I have the following routine that I would like to simplify: ...
4
votes
1answer
296 views

Find log4net logfiles at runtime without adding dependency to project

I was searching for a way to get all active log4net logfiles (if any) at runtime without adding a reference to the project. This is the solution I came up with: ...
1
vote
2answers
1k views

Replace all occurrences with the properties of an object

The basic idea is to replace all special expressions, e.g., [%InvoiceNo%], [%DueDate%], in a string with the properties of an ...
3
votes
4answers
378 views
2
votes
1answer
630 views

Magic getters/setters in PHP … Any comments/suggestions?

So, I'm playing around with PHP, trying to write a small ORM. Having worked with Magento quite a bit lately, I've fallen in love with the automagic getters/setters that Magento, I think, inherited ...
3
votes
1answer
225 views

Method to lookup persistent entities by an example object

i'm currently writing a generic data access object for the persistent entities I have to handle in my JavaEE application. What this codeReview is about is a findByExample method that is used to find ...
1
vote
1answer
2k views

Creating Extension Method to map entity with subentities object to Poco object

I am trying to create an extension method that builds a POCO object (copies all the fields) for an Entity Object. When Entity object is simple (no navigation, no sub collections), it works fine. I ...