Is it possible using reflection to get THE instance of the class of a calling method?
Trying to "hack" a solution for webservices to pass on the Timeout value of the incoming call (When you call a webservice that in turn calls a new webservice using WSE. It sucks when the client sets a timeout of 5 mins and the next level only have the ...
I think that the ability of some reflective managed environments (e.g. .NET) to add custom metadata to code entities in the form of attributes is very powerful. Is there any mechanism for doing something similar for databases?
Databases obviously already have a fair amount of metadata available; for example, you can get a list of all ta...
Hi all,
Pyhon comes with the handy dir() function that would list the content of a class for you. For example, for this class:
class C:
i = 1
a = 'b'
dir(C) would return
['__doc__', '__module__', 'a', 'i']
This is great, but notice how the order of 'a' and 'i' is now different then the order they were defined in.
How can I...
I have a type, t, and I would like to get a list of the public properties that have the attribute MyAttribute.
Currently what I have is this, but I'm thinking there is a better way:
foreach (PropertyInfo prop in t.GetProperties())
{
object[] attributes = prop.GetCustomAttributes(typeof(MyAttribute), true);
if (attributes.Length...
Hi,
I need to use a generic interface like the following:
public interface IContainer<T>
{
IEnumerable<IContent<T>> Contents { get; }
}
An object implementing this interface is returned by a generic method like the following:
IContainer<T> GetContainer<T>(IProperty property);
Type T is unknown until run-time.
Using reflection...
hi guys,
I need to have some mirror objects in WPF. I have a Canvas with some content, and I need 50 visual clones, and if I modify something on the source, it should be updated in these clones.
I know it is easy to do in XAML by binding the Visual of a VisualBrush to the element, but can's seem to do this from code.
Can anyone help ...
Using org.as3commons.reflect I can look-up the class name, and instantiate a class at runtime. I also have (non-working) code which invokes a method. However, I really want to set a property value. I'm not sure if properties are realized as methods internally in Flex.
I have a Metadata class which stores 3 pieces of information: name,...
Imagine I have a C# app sitting on a server somewhere that is creating instances of the Item class and publishing them on a messaging service.
class Item
{
public int ID1, ID2, ID3;
public double Value1, Value2, Value3;
}
Now I have another C# app on a desktop somewhere listening to these messages. I want to be able to create ...
Where described well-known reflection restrictions for Silverlight types?
For example: if I try to set protected or private property value with PropertyInfo.SetValue method I get an exception MethodAccessException.
Why did these restrictions?
...
Here is a test class :
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
public class TestAnnotations {
@interface Annotate{}
@Annotate public void myMethod(){}
public static void main(String[] args) {
try{
Method[] methods = TestAnnotations.class.getDeclaredMethods();
...
For a Type, there is a property IsClass, but how to know a Type is a Struct?
Sorry, I have to add some more information.
I am using C#.
Although IsValueType is a necessary condition, it is obviously not enough. For an Integer is a value type also.
...
We added DynamicProxy to our ASP.NET web app a couple of weeks ago. The code ran fine in dev and QA, but when we pushed to production, we got the following exception (top of stack trace only):
[ArgumentNullException: Invalid internal state.]
System.Reflection.Emit.TypeBuilder._InternalSetMethodIL(Int32 methodHandle, Boolean isInitLoca...
Suppose I have a factory method, which wants to construct an instance of a type chosen at run-time via reflection. Suppose further that my factory method is generic code that doesn't directly reference the assembly that contains the specified type, though it will be run from within an application that has the necessary assembly reference...
I am consuming a web service which has a number of methods (50) which create different objects.
example:
CreateObject1(Object1 obj, int arg2)
CreateObject2(Object2 obj, int arg2)
...
CreateObjectX(ObjectX obj, int arg2)
All Objects (Object1, Object2, ObjectX...) inherit from ObjectBase.
So I am trying to do this...
delegate void DlgtC...
Since class_poseAs(..) is deprecated in Objective-C 2.0, I need to find another way to change the class of an object at runtime. I've found I can change an object's class using object_setClass(..). My problem now is finding all the current instances of a given class in order to update them.
A solution would be to maintain a global dicti...
Hello everybody. Is it possible to get information about class that invoking the other one?
class Bar{
public Bar{}
public String getInvokingClassInfo(){
return "...";
}
}
class Foo{
public Foo(){
Bar bar = new Bar();
System.out.println("Invoking class is: "+bar.getInvokingClassInfo());
}
}
...
How to get 'System.Type' of the module?
For example module:
module Foo =
let bar = 1
And this does not work:
printfn "%s" typeof<Foo>.Name
Error is:
The type 'Foo' is not defined
...
I'm trying to build something like the C# type initalizer dynamically:
MyClass class = new MyClass { MyStringProperty= inputString };
I want to build a generic method that reflects over a given type once and returns a delegate which creates a new instance of the class and populates it based on the input parameter. The method signature...
Hi, I have a custom attribute, inside the constructor of my custom attribute I want to set the value of a property of my attribute to the type of the property my attribute was applied to, is there someway to access the member that the attribute was applied to from inside my attribute class?
...
Is there a built in method, function, API, commonly accepted way, etc. to dump the contents of an instantiated object in Objective C, specifically in Apple's Cocoa/Cocoa-Touch environment?
I want to be able to do something like
MyType *the_thing = [[MyType alloc] init];
NSString *the_dump = [the_thing dump]; //pseudo code
NSLog("Dumped...