Skip to main content

Questions tagged [reflection]

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

3votes
0answers
129views

Allocate managed objects in C# on the native heap

This is a pretty basic class to allocate objects from the native heap. The whole process goes as follows: allocate bytes from NativeMemory.Alloc, set the method table pointer from an existing object, ...
InfiniPLEX's user avatar
8votes
3answers
172views

Modern utility to get type name strings

This is a modernization of a very old utility I’ve had in my personal code toolbox for a while. There are two variable template constants: indi::type_name<T>:...
indi's user avatar
  • 14.9k
0votes
0answers
42views

Flat serialization of single-value Java records used as strong types with Gson v2.11.0

Introduction I am currently developing a REST client in Java v21 and got the foundation basically working. In my project the Immutables and Gson library are currently used. Both libraries integrate ...
Florian Wolters's user avatar
3votes
1answer
112views

Recursively iterate over every object in an object graph looking for specific types

I have an object graph which contains two types of objects that I care about: Link objects that contain an ID and a reference to the object with that ID. ...
ScottishTapWater's user avatar
2votes
1answer
200views

Add field and value into an object by reflection

original code: import, hide some irrelevant company package ...
leaf_yakitori's user avatar
0votes
1answer
3kviews

Copy object without reference using reflection

Recently I was in need of a method to copy an object and pass it to a method which alters the data. Since a class is passed by reference this would alter the class in the caller which I don't want. So,...
Roe's user avatar
  • 121
1vote
1answer
147views

Readlines abstraction for Golang

I've just started learning Golang and was solving some problems which required me to read lines of text from a file. I decided to abstract away the reading part so that I can use Go's ...
smac89's user avatar
  • 1,529
1vote
1answer
76views

Mapping various input values to a data accumulation class

This function takes inputs from multiple different controls on a form, and maps them to values in a data accumulation class. This code was written specifically to keep logic, data, and display ...
EvilPCDiva's user avatar
3votes
0answers
211views

Simple Java IoC container for dependency injection

I have come up with a quick and simple IoC container to enable minimal dependency injection support in one of my Java projects. The container supports services with: A transient lifetime, meaning, a ...
Amal K's user avatar
1vote
3answers
2kviews

Best way to get an arbitrary property for a C# class?

I have close to a hundred classes where I need to get arbitrary properties from them at runtime. The calling class knows which properties it wants at run time, but not at compile time. Looking for ...
DKATyler's user avatar
14votes
1answer
2kviews

Low Level VBA Hacking - making Private functions Public

NEW: Download demo files Not sure what to title this - essentially, inspired by RubberDuck's unit test engine, I've created a way to call private methods of standard modules in VBA. It also lets you ...
Greedo's user avatar
  • 2,625
9votes
1answer
782views

Change arbitrary arguments of function based on their names with a decorator

I ran across an issue that proved to be more complicated than I thought: Changing an arbitrary argument of a function purely based upon its name in Python - possibly via a decorator. I tried to ...
s-m-e's user avatar
3votes
1answer
1kviews

Setting all class members to null to destroy strong references

At work we are using Xamarin.iOS for our apps. We frequently have to fight it's disadvantages, namely it's memory leak issues where strong cyclic references keep objects alive and prevent them from ...
Frederik Hoeft's user avatar
3votes
2answers
114views

Search code that performs in-memory search

This is the code I came across in our repository. This performs search in-memory and is invoked on service layer code. In our front end operators like EQUAL_TO and ...
user251118's user avatar
0votes
1answer
90views

How to save/get different type of data with less duplicated code

description: I'm using thrift to save and get data by filter. The data have many types, and the types may increase in the future. So I use ...
leaf_yakitori's user avatar

153050per page
close