Hi
I have created many annotation in my life and now came to strange case that i need this annotation to do and dont think it is supported by Java at all. Please someone tell me that i am right or wrong.
Here is my annotation :
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface DetailsField {
public ...
I want to create an instance of value types like System.String, System.Boolean, System.Int32, etc. I get qualified names of types like System.String or MyNamespace.Employee and I have to create an instance and return back. I use Activator.CreateInstance and FormatterServices.GetUninitializedObject to create instances. But it fails in cas...
In Eclipse and a class is being loaded that should not be possible. In debug mode, I can pause it and see a call to class a.b.c BUT a.b.c class should exist anywhere since it has been renamed. My assumption is that there is an old jar file being called...but I cannot find it. So how do I find the jar file that class a.b.c is in while...
Hi,
I have a VB.NET website which has a static (shared) class from which I need to obtain the value of specific variables that may exist anywhere in the application's scope. The reason I have this need is that I have snippets of text coming from a database which contain embedded variable names, such as [[FirstName]]. I need to repla...
To facilitate control reuse we created a solution with three separate projects: a control library, Silverlight client, and ASP.NET backend. The control library has no reference to the RIA Services-generated data model classes so when it needs to interact with it, we use reflection.
This has worked fine so far but I've hit a bump. I ha...
Is there some way through the standard library or some already existing library to determine the degree of relation between two classes/interfaces in Java?
Let's say I have an object and a list of classes/interfaces. Now I basically want to know the one class of that list, that has the shortest inheritance-tree path to this object.
I ...
I've used NDoc for quite a while now using a customised build (i.e. slightly bug-fixed build) of NDoc Enhanced (http://sourceforge.net/projects/ndoc-e/) but I've run into a strange issue with methods that have parameters which themselves take generic parameters.
For example anything that has a Dictionary as a parameter where the type pa...
Is any practical way to reference a method on a class in a type-safe manner? A basic example is if I wanted to create something like the following utility function:
public Result validateField(Object data, String fieldName,
ValidationOptions options) { ... }
In order to call it, I would have to do:
valida...
So I'm developing something that works on dynamic variables using C# 4. And I'm in a situation where I have two variables a and b and I know that either a.Foo(b) or b.Foo(a) is defined. However I don't know which so at the moment I use something like this:
dynamic a, b, result;
...
try
{
result = a.Foo(b);
}
catch
{
result = b....
I'm trying to query attributes and access the base type of several attributes. For some reason it is failing to cast properly and not executing as expected. Here is the code below:
internal static void ValidateProperties(TModel model, ModelStateDictionary modelState)
{
Type type = model.GetType();
Pr...
I want to create an instance of type t with reflection, that is
Type t = typeof(string);
string s = (t)Activator.CreateInstance(t); // this fails because of convertion
string s = Activator.CreateInstance(t) as t // also fails
Is there a way to perform such a convertion?
Thanks.
...
hi,
i want to invoke a method using reflection. i am having two projects AA and BB. AA has dependency on BB but BB does not have. Now the use case is that i have to call a class of AA from BB. can any one suggest me how to do that..
i have used ReflectionUtils class for the same..
Method getMethod = null;
getMethod = ReflectionUtils....
Scenario
I need to build a table of data from a list of objects given a specification. In example, I have a list/array of Order objects, and a string specification detailing what the data table should contain e.g "ID;Date;Customer.ID;Customer.Name;Orderlines.Product.ID;Orderlines.Quantity;Orderlines.UnitPrice".
The order class class co...
To make debug-time introspection into classes easy, I'd like to make a generic toString method in the base class for the objects in question. As it's not performance critical code, I'd like to use Reflection to print out field name/value pairs ("x=1, y=2" etc).
Is there an easy way to do this? I tried several potential solutions, and ...
I'm trying to retrieve a custom Attribute set on a page's class from inside the MasterPage. Normally to do this I would need to reflect directly on the specific class, but inside the Master page it's always referred to as the Page type (the parent class).
How do I determine the specific type of the Page property?
Here's an example of w...
We have code to log data in our Ruby 1.8.6 web application. You call it roughly as follows:
$log.info("Some text here")
Now, in the logged output, I would like to include the module where that line appeared. I know that the Kernel#caller will give me an array where I can pull out the file and line number that the log line occurred, ...
I've been working on an API that encapsulates another, trickier-to-use API. The goal is for my API to not require the user to touch any of the old API by 1) not requiring any parameters of classes in the old API and 2) not returning any instances of classes in the old API. Is there a program, perhaps a Visual Studio plugin, that can an...
I am trying to write a general method to parse objects from strings. To be clear, I have the following not-so-elegant implementation:
public static Object parseObjectFromString(String s, Class class) throws Exception {
String className = class.getSimpleName();
if(className.equals("Integer")) {
return Integer.parseInt(s);
}
e...
I was very confused about the reflection and wrapper, I know that reflection can reflect the object into another object type, wrapper can convert the primitive type into object. Is this correct?
...
I need a Class which has an semi-automatic 'to_s' method (to generate XML in fact).
I would like to iterate through all the automatic methods set up in my 'attr_accessor' line:
class MyClass
attr_accessor :id,:a,:b,:c
end
c=MyClass.new
So far I'm doing a basic:
c.methods - Object.methods
=> ["b", "b=", "c", "c=", "id=", "a", "a...