I am trying to find a way to get the source code for (user defined) PHP functions in a string.
For normal code this is easy, using reflection I can find the file and linenumbers where the function is defined, then I can open the file and read the function source code.
This will not work if a function is defined in eval'd code. I do not...
Currently I have the function CreateLog() for creating a a log4net Log with name after the constructing instance's class.
Typically used as in:
class MessageReceiver
{
protected ILog Log = Util.CreateLog();
...
}
If we remove lots of error handling the implementation boils down to:
[EDIT: Please read the longer version of C...
Hi,
I'm trying to get a class memeber variable list at run time. I know this probably using typeof and reflections. but can't find an example. Please someone shed light for me.
Here is pseudo code example:
Class Test01
{
public string str01;
public string str02;
public int myint01;
}
I want something like this (pseudo code):
Te...
ok, ive a class and i pass an object as property.
the object that i pass is a List<X>
in my class im trying to access the Object index by reflection BUT I CAN'T!!!
Example:
this class works i just wrote down the part i want to show you and i need help.
class MyClass
{
private object _recordSet;
public object RecordSet
{...
Hi there is there a possibility to get an object from a specific namespace? Perhaps with the System.Reflections? I want to get all objects from type ITestType in the namespace Test.TestTypes as Objects so that I have a list of instances of TestType1, TestType2, TestType3 and so on. Can Someone help me? I don't know where to search for th...
Hi,
I have an expression tree I have created by parsing an Xml using the expression class in C#. See this question.
I only have Add, Subtract, Divide, Multiply, Parameters, And and Or in my Expression Tree.
Is there a way to convert this ExpressionTree into a callable method?
...or do I have to emit the IL manually?
Kind regards,
...
I have an application the will load usercontrols dynamically depending on the user. You will see in the example below that I am casting each user control via switch/case statements. Is there a better way to do this? Reflection? (I must be able to add an event handler Bind in each control.)
override protected void OnInit(EventArgs e)
{...
What is the origin of the term reflection? It seems more like introspection. Why isn't it called that?
Introspection: A looking inward; specifically, the act or process of self-examination.
Reflection:
the act of reflecting or the state of being reflected.
an image; representation; counterpart
a fixing of the thoughts on something;...
I'm building a custom property grid that displays the properties of items in a collection. What I want to do is show only the properties in the grid that are common amongst each item. I am assuming the best way to do this would be to find the the common base class of each type in the collection and display it's properties. Is there any e...
i have a winforms applicatoin that has a lot of implementations of IOrderDataLoader. Other teams are starting to build their own new implementations of IOrderDataLoader. So we switched our app to look in a directories of Dlls and load all classes that implement IOrderDataLoader using reflection. This way other groups can deploy their ...
Is it possible to reflectively instantiate a generic type in Java? Using the technique described here I get an error because class tokens cannot be generic. Take the example below. I want to instantiate some subclass of Creator that implements Creator. The actual class name is passed in as a command line argument. The idea is to be able ...
Assuming the following hypothetical inheritance hierarchy:
public interface IA
{
int ID { get; set; }
}
public interface IB : IA
{
string Name { get; set; }
}
Using reflection and making the following call:
typeof(IB).GetProperties(BindingFlags.Public | BindingFlags.Instance)
will only yield the properties of interface IB, wh...
This is a somewhat bizarre question. My objectives are to understand the language design decision and to identify the possibilities of reflection in C++.
Why C++ language committee did not go towards implementing reflection in the language? Is reflection too difficult in a language that does not run on a virtual machine (like java)?
If...
I'm trying to use reflection to get a property from a class. Here is some sample code of what I'm seeing:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Reflection.PropertyInfo[] tmp2
= typeof(TestClass).GetProperties();
System....
I am looking to get a list of the column names returned from a Model. Anyone know how this would be done, any help would be greatly appreciated.
Example Code:
var project = db.Projects.Single(p => p.ProjectID.Equals(Id));
This code would return the Projects object, how would I get a list of all the column names in this Model.
Thanks...
I'm currently working with a specialized, interpreted, programming language implemented in Java. As a very small part of the language, I'd like to add the ability to make calls into Java. Before I dive into all of the nitty-gritty of reflection, I was wondering if anyone knew of a general library for doing the "backend" part of invoking...
I was wondering if anyone knows of a quick way or if anyone has written a reflection tool to tell which objects in a solution are not marked as serializable. I'm switching a site over to a StateServer and i need to have all objects marked as serializable. I don't want to miss any.
Also, second part do enums have to be serializable?
T...
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
Typeof(Customer).GetProperty("ZipCode")?
...
Hi,
I need to show an object in PropertyGrid with the following requirements: the object and its sub object must be read-only, able to activate PropertyGrid's CollectionEditors.
I found a sample that's closely match to what I need but there's an unexpected behaviour I couldn't figure out. I have more than one PropertyGrids each for dif...
Hi,
I have a similar question to this one except I need to loop all the sub objects and change the property to read-only
Please check my code below. This one loop only the main object. When I tried to loop its sub objects, I got an overflow.
Thanks.
Public Class ReadOnlyTypeDescriptor
Inherits CustomTypeDescriptor
Priva...