Reflection is the process by which a program can observe and modify its own structure and behavior at runtime.
0
votes
0answers
36 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
70 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
61 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:
<?php
/**
* User entity. I want to save it into database.
* ...
0
votes
3answers
107 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
27 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
50 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 ...
0
votes
0answers
37 views
Suggest improvements to Perl remote server for serving Perl code via reflection
I built a custom XML-RPC server in Perl that "supposedly" serves any given Perl code module/class whose structure conforms to some compatible specifications, and the server serves it dynamically at ...
8
votes
2answers
312 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:
Evaluate the maximum possible type to fit ...
1
vote
1answer
323 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 ...
1
vote
1answer
40 views
Action based controller using reflections
I'm modeling a controller reflection based. I would like to know if you agree my implementation and what could to be enhanced.
I'm starting with reflection and I would like to know if I'm using good ...
1
vote
1answer
128 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
179 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 ...
2
votes
1answer
747 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 ...
3
votes
3answers
449 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:
# recursively computate ...
2
votes
2answers
590 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 Value and Description.
Is there a cleaner way of implementing this?
...
1
vote
0answers
195 views
Basis of custom c++ serialization lib
This is gonna be a long read, I'm warning you:)
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 ...
7
votes
2answers
387 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 varying configurations throughout our app.
One requirement we have is ...
2
votes
1answer
2k 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
681 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:
class Baz {
String foo = "foo2"
int bar = 2
public Map asMap() {
def ...
4
votes
2answers
238 views
C# overload method simplification
I have the following routine that I would like to simplify:
public void SetUniform(RenderContext ctx, string uName, object value)
{
if (ctx == null)
throw new ...
4
votes
1answer
207 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:
private static ...
1
vote
2answers
281 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 object, Invoice invoice.
string str = "Your invoice [%InvoiceNo%] will be ...
4
votes
4answers
352 views
How can i make this piece of code better ?
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace ParserProject{
class ParseToJsonString{
private readonly StringBuilder _sb;
...
2
votes
1answer
392 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
2answers
170 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
1k 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 ...
2
votes
1answer
310 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 ...
3
votes
2answers
571 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:
object validator; // An object known to implement IValidation<T>
...