Questions tagged [reflection]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
11k views

Casting an Enumeration with Descriptions into a Dictionary

The Enumeration in question is based on int, so the following Extension returns a Dictionary<int, string> of the Enum's ...
6
votes
1answer
448 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 ...
8
votes
2answers
2k 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 ...
3
votes
1answer
9k 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 ...
16
votes
4answers
21k 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
672 views

C# overload method simplification

I have the following routine that I would like to simplify: ...
7
votes
2answers
273 views

Dispatcher for a JSON API without routes

I am using this code for a fast JSON API without routes. Does this code contain any useless parts? Is the class loader efficient enough? Are there any better options? Is ...
4
votes
1answer
468 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
6k 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 ...
2
votes
0answers
861 views

ORM with magic getters/setters

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 from ...
3
votes
1answer
354 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 ...
2
votes
1answer
6k 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 ...
6
votes
1answer
11k views

Is there a better way to convert to a specific type with reflection?

Rather than doing what is essentially a large switch statement for every possible type, is there a better more generic way of converting to a specific type with reflection? I've looked up ...
4
votes
2answers
9k views

Casting to less generic types

The source code, or rather the concept I'd like to get reviewed is what now allows me to do the following during reflection: ...
11
votes
2answers
23k views

Mapping ExpandoObject to another object type

I am working on a helper method that maps properties from an ExpandoObject to a user supplied object and was wondering if the code could be cleaned up or made any ...