Is there an equivalent of get_defined_functions() which only shows the functions of a given object?
Example usage and output:
class A {
function foo() { }
function bar() { }
}
class B extends A {
function foobar() { }
}
$b = new B();
print_r(get_object_functions($b));
// Array (
// 0 => "foo",
// 1 => "bar",
// 2 => "fo...
Howdie!
So I'm deserializing a class called Method using .NET Serialization. Method contains a list of objects implementing IAction. I originally used the [XmlInclude] attribute to specify all classes which implement IAction.
But now, I'd like to change my program to load all dlls in a directory and strip out the classes which impleme...
I am writing a curriculum project for students new to Java. It has a folder structure as so.
myjar.jar
solutions/my/really/long/package/MySolution.class
I got it so the jar can load all classes in the solutions/my/really/long/package/ directory.
by adding 'solutions/' to the classpath.
My question is if it is possible to set it up so...
Can I load an stand alone aspx page in another stand alone aspx page using System.Reflection?
I am using the ASP.NET 2.0 Web site project model.
...
Is it possible to pass a function as a parameter in C#? I can do it using the Func or Action classes, but this forces me to declare the entire function signature at once. When I try to use Delegate, I get a compile error saying it can't convert a method group to a Delegate.
I'm working on Axial and I'm trying to allow users to call web...
I have a method fetchObjects(String) that is expected to return an array of Contract business objects. The className parameter tells me what kind of business objects I should return (of course this doesn't make sense in this construed case because I already said I will return Contracts, but it's basically the situation I have in my real ...
Hello,
I'm writing small and very DRY framework, which heavily relies on metadata. I'd like to know if there is a way to obtain method parameter names, i.e. given some method
public void a(int myIntParam, String theString) { ... }
get the strings "myIntParam" and "theString".
I know I could annotate parameters, but that wouldn't be n...
Duplicate: How To Find Where A Ruby Method Is Defined At Runtime
With a given object, is it possible to find out where each method was defined?
...
If you decompile the java.lang.Class class in java from the rt.jar library you will notice there is a native method declaration:
native ConstantPool getConstantPool();
I played a while ago with class decompilation using Sun's .class file specification and I was able to obtain the constant pool record from each .class file. But that wa...
I know I could have an attribute but that's more work than I want to go to... and not general enough.
I want to do something like
class Whotsit
{
private string testProp = "thingy";
public string TestProp
{
get { return testProp; }
set { testProp = value; }
}
}
...
Whotsit whotsit = new Whotsit();
...
I am trying to write a generic Parse method that converts and returns a strongly typed value from a NamedValueCollection. I tried two methods but both of these methods are going through boxing and unboxing to get the value. Does anyone know a way to avoid the boxing? If you saw this in production would you not like it, how bad is it f...
Take the following class as an example:
class Sometype
{
int someValue;
public Sometype(int someValue)
{
this.someValue = someValue;
}
}
I then want to create an instance of this type using reflection:
Type t = typeof(Sometype);
object o = Activator.CreateInstance(t);
Normally this will work, however becaus...
I am trying to build an object through an attribute on a classes property that specifies a column in a supplied data row that is the value of the property, as below:
[StoredDataValue("guid")]
public string Guid { get; protected set; }
[StoredDataValue("PrograGuid")]
public string ProgramGuid { get; protected set; }
In...
FieldInfo has an IsStatic member, but PropertyInfo doesn't. I assume I'm just overlooking what I need.
Type type = someObject.GetType();
foreach (PropertyInfo pi in type.GetProperties())
{
// umm... Not sure how to tell if this property is static
}
...
I'm trying to add a CSS class to the Control that will get the focus, once a page is rendered. While the SetFocus() method of the Page class lets me set the Control, there is no corresponding GetFocus() method.
According to the .Net sources, the information is stored in the private member _focusedControl of the Page class. The property ...
I have a problem with reflection. I need to find the type that instantiates a static member. My code looks like this:
private class SimpleTemplate : PageTemplate
{
internal static readonly IPageProperty NameProperty =
PropertyRepository.Register("Name");
}
The PropertyRepository is a repository of prope...
Given this:
Interface IBase {string X {get;set;}}
Interface ISuper {string Y {get;set;}}
class Base : IBase {etc...}
class Super : Base, ISuper {etc...}
void Questionable (Base b) {
Console.WriteLine ("The class supports the following interfaces... ")
// The Magic Happens Here
}
What can I replace "The Magic" with to display the...
I was wondering how to check whether a variable is a class (not an instance!) or not.
I've tried to use the function isinstance(object, class_or_type_or_tuple) to do this, but I don't know what type would a class will have.
For example, in the following code
class Foo: pass
isinstance(Foo, **???**) # i want to make this return True....
I'm trying to deserialize an array of an type unknown at compile time. At runtime I've discovered the type, but I don't know how to create an instance.
Something like:
Object o = Activator.CreateInstance(type);
which doesn't work because there is no parameterless constructor, Array doesn't seem to have any constructor.
...