Reflection is the process by which a program can observe and modify its own structure and behavior at runtime.
3
votes
2answers
54 views
IEnumerable extension method that ingests SqlCommand and returns query results
The following ingests a preexisting SqlCommand and returns the values.
A couple caveats right now.
1 ) Type properties must be named identical to the SQL column
...
2
votes
1answer
34 views
Getting translated string using reflection and Resource Manager
I wrote the following code to get the translated string from Resource Manager. The method GetTranslatedString is called more than 50 times in my project.
...
2
votes
2answers
36 views
Method for finding all classes
This was inspired by a Stack Overflow question about getting all the classes of an application and I took it a little too seriously (or perhaps not seriously enough).
It's rather silly to do it this ...
10
votes
3answers
652 views
Listing human-readable enums
I'm trying to do some util class to operate on enums - convert Enums to its special strings representation via interface method.
String stored in enum constructors.
...
1
vote
1answer
51 views
Create Form Controls based on the properties of a class
Is there a better way to create Form Controls for properties of a class? Right now, I iterate through all properties of a class and have a method to create the Form Control for that property based on ...
7
votes
2answers
67 views
Strict types decorator (works only with Python 3.5)
I wrote a decorator which makes Python 3.5 raise exceptions if the arguments that are passed to a type-hinted function are of the wrong type.
...
2
votes
0answers
31 views
Method that return related entities using OData
There is method GetFull that should use OData return related entities.
When I call GetFull(12, "entity1,entity2") then I will ...
4
votes
2answers
105 views
Setting the value of properties via reflection
I am working on an application in which I have to parse an XML file. Nodes of the XML file corresponds to an object. I have to populate the properties of the objects at run time. The code below ...
5
votes
1answer
57 views
Generating controls based on PropertyInfo
This is a class that takes a PropertyInfo and makes a Control for it. You can access the value of the control through a property on the class called Value. ...
6
votes
1answer
54 views
Getting all public constants from the main and nested classes
I wrote this recursive function to get all constants from a class and its subclasses. Can it be simplified?
...
5
votes
1answer
72 views
Project Euler: Autorun problems
I've found that it's a huge pain to have to write the boilerplate code for each Project Euler problem I write (timing code, main method, what about running every problem instead of just one?). So I ...
6
votes
1answer
87 views
Dynamic data object generation
Last weekend I had an idea: Why not remove dozens of classes by removing all the basic get/set/equals/hashCode implementation of my data object interfaces? I tend to code against interfaces, so I ...
0
votes
0answers
23 views
Generic Razor view Model property validation for Form
I 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
233 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
98 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
128 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
495 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
331 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
79 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
131 views
Property Mapping with Reflection efficiency
I have an object that I am populating via mapping and lookup with Reflection:
...
2
votes
2answers
74 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
194 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
409 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
129 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
99 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
62 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
552 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 ...
5
votes
3answers
201 views
Avoid static initializer for lists of image and video formats?
I wrote the following code to read constants from annotations:
...
8
votes
2answers
313 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
99 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
42 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
88 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 ...
6
votes
2answers
9k 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
90 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
124 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
323 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
264 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 ...
5
votes
2answers
4k 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
222 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
600 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
143 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
126 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
350 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
4
votes
0answers
160 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
197 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
86 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
6k 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 ...