class at runtime
Is there a way to create Java classes @ at runtime (classes methods n variables), with using Java reflection API ...
Is there a way to create Java classes @ at runtime (classes methods n variables), with using Java reflection API ...
I have 2 dimensional list created at runtime (the number of entries in either dimension is unknown). For example: long_list = [ [2, 3, 6], [3, 7, 9] ] I want to iterate through it by getting the ith entry from each list inside the long_list: for entry in long_list.iter(): #entry will be [2, 3] then [3, 7] then [6, 9] I know tha...
I have an object which has a huge number of properties. I'd like to get the value of each of those properties by simply looping through the properties collection of the object. I've looked into the PropertyInfo.GetValue() method however it's not making much sense in the context I have. Here's an example of what i'm trying to do (this c...
I am loading some assemblies at run time and invoking methods on them using Reflections (MethodInfo.Invoke). Now I want to make these calls asynchronous. So I am thinking of using Delegate.BeginInvoke(). But I am not sure how to create delegate instance by providing function name at run-time. (All examples I see have delegate instance t...
Let me explain. I have a List into which I am adding various ASP.NET controls. I then wish to loop through the list and set a CssClass, however not every Control supports the property CssClass. What I would like to do is test if the underlying instance type supports the CssClass property and set it, but I'm not sure how to do the conver...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding Array type. The best I could come up with is this: Class arrayOfFooClass = java.lang.reflect.Array.newInstance(fooClass, 0).getClass(); Is there a way to do this without creating the new instance? ...
I have a data access library that has a few classes that all implement the same interface, which has a generic type parameter: public interface IGetByCommonStringRepository<TEntity> { TEntity GetByCommonStringColumn(string commonString); } public class Repository1<Entity1> : IGetByCommonStringRepository<Entity1> { public Entity...
I have written a command manager that uses reflection to make calls to various methods and it works wonderfully except that when an exception happens in one of the handlers the break into debugging happens in the command manager and not at the point the exception was originally thrown. Is there a way to get it to break into the exception...
I'm trying to write a simple Resource Manager for the little hobby game I'm writing. One of the tasks that this resource manager needs to do is unloading unused resources. I can think of doing this in two ways: When an object no longer requires a reference to the resource, it must call a method of the Resource Manager to signify it is ...
I'm in scala writing a serializer that saves an object (or Model) to the database (for app engine), and I need to treat some fields as special cases. For example, if the field is of type Array[Byte], I Save it as a blob. And I need to treat Enumerations as special cases too, but I can't find out how to know if a type is an enumeration. ...
Hi All, I'm trying to add items to a listbox,combobox, radiolist using reflection. The code I have at the moment is as follows: public static Control ConfigureControl(Control control, ControlConfig ctrlconf) { if (control is TextBox) { // ... } else { // get the prop...
Hi, I have an existing heirarchy of classes, say something like this: Business - Division - ProjectTeam - Employee These classes are instantiated via deserialization. However, now I need to expose extra fields in the Employee for a particular user of the library i.e. say something like this: SpecialBusiness (extends Bus...
I need to save powerpoints as HTML with c#. I also need to turn on animations with the 'ShowSlideAnimation' property. The first code block works fine, but when I duplicate the code with reflection, I am unable to get the 'WebOptions' property because it is null. I chose to do this without referencing the office assemblies because some...
How can I test a private method of an abstract class using reflection (using C#)? I am specifically interested in adapting the code found in this thread. I am aware of the discussion around the principle of testing private codes in the first place (one should not in general !!). I have already decided to do that for my situation because...
Take the following property: public string Foo { get; private set; } Using reflection, I can still set the value of this property from outside the owning class. Is there a way to prevent this? Removing the set accessor is not an option as it must be WCF friendly. ...
I want include the Type name of each object in my collection from my GridView. I have a collection which has four different types in it that all derive from a base class. Call them, Foo, Bar, Fizz, and Buzz. I want to have that column read, Foo, Bar, Fizz or Buzz, respectively. Below is the Binding I'm using, however, it doesn't work...
1.. Is there any performance overhead caused by the usage of attributes? Think for a class like: public class MyClass { int Count {get;set;} } where it has 10 attibutes (attributes being classes, where the attribute classes themselves are way larger than MyClass itself like: public class FirstAttribute : Attribute ...
What's the reason for not being able to use static methods, instance methods, etc as a argument to an attribute in .NET? Why doesn't C# allow this? ...
I have a piece of code where i need to pass the class of a field in a method. Because of the mechanics of my code i can only handle reference objects only and not primitives. I want an easy way of determining if a Field's type is primitive and swap it with the appropriate wrapper class. So in code what i do so far is something like this ...
This is a dirty thing to do, and I feel dirty for doing it: public abstract class InterestRate { // irrelevant details public static T ImpliedRate<T>( double factor, double time, DayCounter dayCounter ) where T : NonCompoundedInterestRate { MethodInfo methodInfo = typeof(T).GetMethod( ...