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

learn more… | top users | synonyms

5
votes
1answer
49 views

Python proper abstract class and subclassing with attributes and methods

The goal of the code below is to have an abstract base class that defines simple methods and attributes for the subclasses. This is part of an application that provides the code base for others to ...
4
votes
0answers
62 views

Dynamically creating login screen on Android devices

This has been an experience. I'm well above "hello world" java is not a language I use often when programming and I don't program too much. I find myself a lot on Google.... basically just about for ...
1
vote
1answer
43 views

Executing a function's flow

My __main__.py file has a function's flow, based on methods of each class instance, which each one has its own methods and attributes, like this: ...
3
votes
3answers
101 views

Saving complex business objects with reflection and recursion

In our application we have complex objects with many nesting levels, each with various properties that are important to the business. We currently serialize and persist these objects along with their ...
0
votes
0answers
28 views

Generate random instance of given Class

I was running some rightsizing tests and had to blast random objects of my various class types. Here is the code I came up with. ...
-3
votes
0answers
40 views

Accessing types which are defined in another (referenced) assembly

I would like to load an assembly and have access to types which are defined in another assembly (which is referenced by the first assembly). Is a good idea to load referenced assemblies by using the ...
4
votes
3answers
170 views

Accessing Properties by Name

Over the weekend I decided to start work on my own version of FastMember. I began with my take on an implementation of TypeAccessor so that I could work with the ...
3
votes
1answer
28 views

Declarative DependencyProperety registration

Most properties have simple requirements so it should be possible to register their Dependency Property fields declaratively. I made a small experiment and it seems to work just fine. The first ...
4
votes
2answers
96 views

Dynamically convert property to different data type

The code finds marked attributes and parses them according to the attribute type. Is it possible to simplify this logic? Is there generic way to do it? Please suggest some way to optimise this code. ...
0
votes
0answers
29 views

Single integration test written using reflection to test routing

We have two .NET solutions: WebAPI solution that contains all business logic and repositories, MVC project that represents a presentation layer of the application. In WebAPI solution we also have a ...
3
votes
0answers
23 views

Print Python docstrings when module is executed interactively

I have written a module, which should only be used by means of import, then call the functions as required. I do not want this module to do anything when ran interactively, other than printing out ...
5
votes
4answers
856 views

Generic Null/Empty check for each property of a class

I have created a method to check for null/empty values of class properties and if any null property is found I'm stopping the checking process and returning the result as true. I'm used a solution ...
4
votes
1answer
79 views

Code that uses reflection to validate arguments

I wrote an answer to this question on the Software Engineering SE site and was hoping to get it critiqued. (I'm told that it's acceptable to do so). Essentially, this code uses reflection to check to ...
3
votes
0answers
102 views

Get n-th data member of a struct

To get n-th member of a struct without non-empty bases and w/o non-public members C++ now have a pretty way: ...
3
votes
2answers
94 views

Determine the class hierarchy of a class

My only concern with the following class is the line hierarchy.trimToSize() in determineHierarchy, because it is not necessary ...
4
votes
2answers
101 views

Java CLI Program Commands

As I was creating a CLI program, I realized having a ton of switch/if-then statements was a messy way to process user input. So, I set up a way to dynamically create commands as I added modules (...
4
votes
1answer
51 views

Serializing Objects to Delimited Files Part II

This is a follow up to my previous question: Serializing objects to delimited files I've added some feature enhancements, and based on suggestions from rolfl in chat, I've fixed up a couple ...
2
votes
2answers
49 views

Python deep get

I'm implementing deep_get functionality to look inside arbitrarily nested Python 2.7 objects. Primarily for further logging. This turned out to have surprising ...
4
votes
1answer
58 views

Enumerations via reflection in AS3

I'm very much used to enumerations a la Java, where each value in an enum is a distinct object. You can call functions on these objects, and they're generally ...
1
vote
1answer
81 views

Decoupled chain of responsibility in Python

I've started to learn Python today. I'm trying to write decoupled middleware or chain of responsibility pattern. In my app I have some two classes: abstract class or interface named Processable ...
2
votes
1answer
90 views

Unit test code for a private median-of-three function, using reflection [closed]

A Junit test class is used to test the class LibraryCounter. Reflection was used to test the private methods. This made the code much more complicated. ...
5
votes
1answer
124 views

Illumination as a way of instantiating new objects

Basically, what I mean by illumination is having a method create an object where the caller supplies all the dependencies. This allows us to hide our new keyword ...
1
vote
1answer
306 views

Custom Exception.ToString() formatter

I find the default Exception.ToString() formattig very difficult to read especially if there are inner exceptions involved. I guess everyone knows how it looks: <...
3
votes
2answers
133 views

Accessing and caching attributes

I have the following manager class that handles access and caching attributes from classes. I am a bit worried about the caching mechanism. Is there a better way of handling it? ...
3
votes
1answer
93 views

Serialize and deserialize n dimensional int array

I've made two symmetric methods which serialize an int array of any number of dimensions into an OutputStream, and read such an array from an InputStream. I was wondering if there is ways this code ...
5
votes
1answer
408 views

Serializing objects to delimited files

For a new project I'm going to need to be able to serialize random types to TSV or CSV files, so I write a class which can be used to serialize any object to a TSV, CSV or any other _SV file you can ...
0
votes
1answer
88 views

Business logic parallelization engine

In my Java 8 application there are 3 different classes but each of them contains one similar method, which is dedicated to parallelization of the business logic ...
3
votes
1answer
261 views

Extended WebBrowser control

I needed the ability to do a few extra things with a WebBrowser control on a .NET Windows Forms Form, and I found it needed some updates. So, I made a few. I added ...
5
votes
3answers
225 views

Determine if Class B uses Class A ( Java Reflection)

Below is a function that determines if Class B uses Class A. Currently, it tests for: Fields Superclass Constructors Methods ...
6
votes
2answers
594 views

Generic extension method that will attempt to parse a string and return it's value or default(T)

So I got sick of several things about the way TryParse works. I implemented a generic ParseOrDefault function using reflection. It appears to work as expected, but I'm not fool enough to say my code ...
0
votes
1answer
250 views

Data model decomposition into key value pairs using reflection and attributes

I'm trying to change how our system generates PDF files. Currently I have a class for each PDF that goes through the model for the PDF and fills in the properties. I want to change that to a self ...
4
votes
1answer
31 views

Invoking API calls with parameters specified using JSON

I have an instance of a Java class that I need to call some functions on, using the API exposed by another party. For each call, I need to both check for thrown exceptions, and check the value of the ...
10
votes
1answer
157 views

Corrupting Java arithmetic through reflection

Inspired by a PPCG answer, I wrote this code, which shuffles the autoboxing caches of Number subclasses. This leads to, among other things, outputting ...
7
votes
1answer
179 views

Milking a COM type library: “fun” with COM reflection

Once upon a time, there was a duck that wanted to know where and how user code was calling into the VBA standard library and Excel object model. To match the rest of its API, the poor little duck had ...
4
votes
2answers
48 views

Storing disassembled data in a structured way

I want to store the information returned by the dis function of the dis module in a structured way, using a dict, associating the mnemonics of each code of a line to the correspondent line number. ...
3
votes
1answer
45 views

Property validation

I require that the Feature set of my Licence to have a non-empty intersection with a set of features that the module I am ...
2
votes
0answers
96 views

Pagination links for various lists using Spring-HATEOAS

I'm using Spring HATEOAS to create some links on my REST API. However, the entities i'm returning are very close, so the code to generate the links are the same: ...
10
votes
3answers
402 views

Tracking Entity Changes (not EF)

So, I kept refactoring my Sage300 API wrapper - I wanted the client code to feel just like using Entity Framework - this is the closest I got to it: ...
1
vote
0answers
110 views

Saving the state of a ViewModel

I've the following scenario, I've got some viewmodel that need to persist their state on disk. I've defined a custom attribute as: ...
2
votes
3answers
402 views

Reflection optimization

In a web application I'm working on I have a class that Map objects to other (different) objects. It is implemented with something like: ...
8
votes
1answer
134 views

Linq-to-Sage Implementation

Following-up on my last question where I wrapped the Sage API with a familiar IRepository interface, I decided to push the abstraction a step further, and... ...
5
votes
2answers
110 views

Method/parameter tracer

I am writing a class which can log the activity of an application during run time. The plan is that the SupportMI string will be sent to a DB, from where I can use ...
6
votes
1answer
55 views

Wrapping the Sage300 View API with… a Repository

Related: Something like a LINQ provider I needed to work with the Sage300 View API. I had never worked with it, but my first impression has been that the API is ...
3
votes
1answer
62 views

Request handler based solely on reflections ver. 2

This question is connected to the previous one: Request handler based solely on reflections I have edited the code, taking tim's answer in regard, editing the Kernel class cohesion. ...
4
votes
1answer
67 views

Request handler based solely on reflections

The code itself is divided into 3 logical parts: Core modules (I call them Kernel modules, my love for Linux) - those are basic modules a web-developer would need, e.g. database wrapper class (PDO), <...
12
votes
2answers
1k views

Extension method to list enum values

I have the following enum extension method: ...
7
votes
1answer
123 views

NullGuard for throwing more informative exceptions

This small utility class is my solution for a more convenient way for checking against null. I also wanted to have more informative NullReferenceExceptions but I ...
5
votes
1answer
122 views

How to refactor this mapping class not to violate SOLID

So I have the below (which is working correctly and all my unit tests are passing) but it's ugly and is violating SOLID, I will have to change the class every time I want to be able to map a different ...
11
votes
3answers
814 views

Give me thy name, I'll invoke thee

This generic function invokes a property of a given object by name: ...
11
votes
4answers
887 views

Using reflection in a test to check if a private variable is really null after a function, is this okay?

I am using reflection to check if a private variable is set to null after the logout function. This is needed because the getUser function will always attempt to set and return an user if no user is ...