reflection

Is it possible to obtain class summary at runtime?

Hi. Is it possible to obtain class summary at runtime in C#? I would like to obtain class summary through reflection and then write it to console. By class summary I mean summary comments before class definition, something like this: /// <summary> /// some description /// </summary> class SomeClass { } I don't know if these comments ...

Problems loading assembly dependencies dynamically at run-time

Hi, let me try to explain my problem. I'm currently trying to develop a small "plugin-framework" written in .Net (mainly for experimenting a bit). So the idea is to have a main application to which "plugins" can be added by deploying dlls in a specific folder "plugins" of the main application. Everything works fine, the plugins are inst...

How can I render reflections in OpenGL ES on the iPhone without a stencil buffer?

I'm looking for an alternative technique for rendering reflections in OpenGL ES on the iPhone. Usually I would do this by using the stencil buffer to mark where the reflection can be seen (the reflective surface) and then render the reversed image only in those pixels. Thus when the reflected object moves off the surface its reflection...

Delegate.CreateDelegate vs DynamicMethod vs Expression

Questions about Making reflection fly and exploring delegates... If I need to create delegates Func<T, TResult> to methods on dynamically loaded types I could potentially use (1) Delegate.CreateDelegate (2) DynamicMethod (3) Expression trees. Lets say the set of dynamically loaded types/methods are reflected once at application startup...

getClass() and static methods: What is the best practice?

I am looking to provide some convenience through reflection to programmers who will be using my code. To achieve my desired result I would like to get the class object for classes that extend my code. Even though they can't override the static method I wish to access the information from, it would be currently helpful. I may end up si...

Dumping a java object's properties

Is there a library that will recursively dump/print an objects properties? I'm looking for something similar to the console.dir() function in Firebug. I'm aware of the commons-lang ReflectionToStringBuilder but it does not recurse into an object. I.e., if I run the following: public class ToString { public static void main(String...

How can I get the list of a columns in a table for a SQLite database?

I am looking to retrieve a list of columns in a table. The database is the latest release of SQLite (3.6, I believe). I am looking for code that does this with a SQL query. Extra bonus points for metadata related to the columns (e.g. length, data type, etc...) ...

Is there a framework attribute to hide a member from reflection in .Net?

Is there an attribute that hides a member (specifically a property) from typeof(MyType).GetProperties() in .net? I'm looking for a quick fix - i.e. not creating custom attributes etc.. thanks ...

What is the opposite of Type.MakeByRefType

The Type.MakeByRefType method in .NET returns a by-ref version of a type, e.g. passing the type of System.Int32 returns a type representing System.Int32&. However, if you already have a System.Int32&, what is the mechanism for obtaining a plain old System.Int32? There doesn't seem to be an opposite method to remove the by-ref modifier. ...

What's the best way to discover all subroutines a Perl module has?

What's the best way to programatically discover all of the subroutines a perl module has? This could be a module, a class (no @EXPORT), or anything in-between. Edit: All of the methods below look like they will work. I'd probably use the Class::Sniff or Class::Inspector in production. However, Leon's answer is marked as 'accepted' ...

.net Databinding - Referencing Anonymous Type Properties

I have bound an ASP.net GridView to a collection of anonymous types. How can I reference one of the properties of the anonymous types in the RowDataBound event handler? I am already aware of the way to cast the anonymous type like this: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowTyp...

Best way to get a Type object from a string in .NET

What is the best way to convert a string into a Type object in .NET? Issues to consider: The type may be in a different assembly. The type's assembly may not be loaded yet. This is my attempt, but it doesn't address the second issue Public Function FindType(ByVal name As String) As Type Dim base As Type base = Reflection.A...

Fastest way to call a COM objects method without using a RCW

I'm trying to find the cleanest and fastest way for calling a COM objects methods. I was using a RCW for the object but every time a new version of the third party COM object comes out its GUID changes which then renders the RCW useless, so I had to change and start using Type mytype = Type.GetTypeFromProgID("MyCOMApp.Application");...

Enum vs Lookup table vs Enum reflection vs State pattern

The software I will be building will involve "application" switching between different status a lot. Certain tasks can be done depends on the status an application is at. I was thinking about using enum as the status public class Application { public int Id {get;set;} public Status {get;set;} } public enum Status { [Description("N...

NHibernate - Reflection or DynamicMethod ?

I have used NHibernbate in few projects and now learned about few more ORMs also. I understand that, NHibernate binds Class to Datalayer dynamically during runtime using the mapping file. My Question is , how this late binding is done ? I mean, which Methodology is used, 'Reflection' or 'DynamicMethod' ? In case, if it uses Reflection,...

Find assemblies in a directory

How can I get a list of assemblies in a given location? I'm trying to reflect over the appdomain, and that's giving me everything that's loaded. I just want what's in the executing assembly's directory. ...

Activator and static classes

I'm tossing around the idea of using the Activator class in order to get access to resources in an assembly that I would otherwise create a circular reference for (dependency injection). I've done it before with vanilla classes that I needed a reference to, but my question is: can I use the Activator to get access to a static class? T...

Retrieving the calling method name from within a method (C#)

I have a method in an object that is called from a number of places within the object. Is there a quick and easy way to get the name of the method that called this popular method. Pseudo Code EXAMPLE: public Main() { PopularMethod(); } public ButtonClick(object sender, EventArgs e) { PopularMethod(); } public Button2Click(o...

Is reflection really THAT slow that I shouldn't use it when it makes sense to?

The "elegant" solution to a problem I am having is to use attributes to associate a class and its properties with another's. The problem is, to convert it to the other, I'd have to use reflection. I am considering it for a server-side app that will be hosted on the cloud. I've heard many rumblings of "reflection is slow, don't use it,...

How to correctly load PresentationFramework assembly from the GAC?

I need to dynamically get the list of Controls in the PresentationFramework assembly. For now, I can load the assembly with this piece of code: var asmName = new AssemblyName("PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); var asm = Assembly.Load(asmName); However, if in the future the...