Hi,
I currently have a function:
public static Attribute GetAttribute(MemberInfo Member, Type AttributeType)
{
Object[] Attributes = Member.GetCustomAttributes(AttributeType, true);
if (Attributes.Length > 0)
return (Attribute)Attributes[0];
else
return null;
}
I am wondering if it would be worthwhile cac...
The issue appears is when I have a class implementing an interface, and extending a class which implements an interface:
class Some : SomeBase, ISome {}
class SomeBase : ISomeBase {}
interface ISome{}
interface ISomeBase{}
Since typeof(Some).GetInterfaces() returns and array with ISome and ISomeBase, i'm not able to distinguish if ISo...
Let's start with a simple test case:
import java.lang.reflect.Field;
public class Test {
private final int primitiveInt = 42;
private final Integer wrappedInt = 42;
private final String stringValue = "42";
public int getPrimitiveInt() { return this.primitiveInt; }
public int getWrappedInt() { return this.wrappedInt; }
...
Lamdbaj allows the definition of closures in the Java language, various examples can be found
here
My question is regarding the underlying Java mechanisms at use, for instance, to define the println closure, the following code is used:
Closure println = closure();
{ of(System.out).println(var(String.class)); }
This closure can be s...
Is there a way to dynamically insert bytecode directly into my C# executable? I'm looking for functionality similar to the asm keyword in C++. Obviously I know I can't insert x86 assembly instructions. I'd only be able insert IL Bytecode.
...
Hi,
I have 4 assemblies:
Tester.exe
ToyInterface.dll
ToyFactory.dll --> reference (ToyInterface.dll)
Toy.dll --> reference (ToyInterface.dll)
Tester.exe
internal ICollection<string> Scan(string path){
return ToyCollection = _reportFactoryType.GetMethod(FACTORY_GET_TOYS).
Invoke(_ToyFactory, null);
}
...
I attended Code Camp 12 recently, and a speaker there said that the new dynamic keyword in C# 4.0 should only be used for interopping with dynamic languages. I think he also said that it is somewhat slow, compared to normal reflection (which itself is somewhat slow).
But then I heard Scott Hanselman mention that the dynamic keyword "ma...
Hi,
I realize the title needs to be read more than once for understanding ... :)
I implemented a custom attribute that i apply to methods in my classes.
all methods i apply the attribute to have the same signature and thus i defined a delegate for them:
public delegate void TestMethod();
I have a struct that accepts that delegate as ...
I'm writing a .SO that gets called by another program and I want to be able to flip a value in memory through a function in the .SO
What I have so far is :
int
axptrace( int numArguments, char* pMessageBuffer, int* pMessageBufferSize,
char* pData[], int* pDataLength[] )
{
printf("Beginning dump attempt..\n");
unsigned int* wkp...
I have this function:
Program A
public ICollection<ReportLocationInfo> GetAllReportsInstalled()
{
return _Reports;
}
I am calling it through reflection dynamically:
Program B
internal ICollection<Object> Scan(string path)
{
MethodInfo GetReports =
_reportFactoryType.GetMethod("GetAllReportsInstalled");
ret...
Hello,
I am following up on this question, 1268817
In the question, we find a way to create an isntance of an object given a the name (as a string) of the class.
But what about to create an array of those objects... how would one initialize that.
I was thinking something in the line of but doesnt seem to work
Object[] xyz = Class....
Hey guys.
I've been using Activator.CreateInstance() in some of my codes. But I was just wondering if there's any risk to making an instance using this?
...
Hello, everyone!
Suppose, I have a lot of classes, which are constructed using Java reflection (for some reason). Now I need to post-inject values to fields, which are
annotated with @PostInject.
public class SomeClass {
@PostInject
private final String someString = null;
public void someMethod() {
// here, someString has a...
In WPF, how do I use reflection to find all classes in a project? I'm interested in obtaining the ones whos names match a certain regular expression.
...
Hi,
I have the following code:
Type type = typeof(T);
foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
Type dataType = type.GetProperty(pi.Name).GetType();
object oldValue = type.GetProperty(pi.Name).GetValue(originalVals, null);
object newValue = type.GetProperty(pi.Name).GetV...
Dear ladies and sirs.
I have a type and an interface and I need to verify that the type implements the interface abstractly.
I have set to write a brute force code using Reflection and it is pretty ugly.
I am wondering if there is a better way than the brute force implementation I am doing now.
Any ideas?
Thanks.
EDIT
Have not che...
I'm trying to figure out how to instantiate a case class object with reflection. Is there any support for this? The closest I've come is looking at scala.reflect.Invocation, but this seems more for executing methods that are a part of an object.
case class MyClass(id:Long, name:String)
def instantiate[T](className:String)(args:Any*) ...
Hi There,
Is it possible to get the comment description of a method or property using reflection. E.g When you use intellisense in Visual Studio to scroll through methods available to object there is a label which describes what the method does. How can I access this data programmatically using reflection?
your thoughts are much apprecia...
Say I have an application that reads a centralized ErrorLog called LogViewer it is mirrored in a few formats (winforms, silverlight, asp.net, asp.net mvc, etc)
Project Names for the actual publish/deployment would be different for each one. Where would I best store the name LogViewer vs LogViewer WinForm (or LogViewer silverlight,etc) t...
Is it possible to do this by streaming the assembly into memory? If so, how does one do this?
Reason:
I don't want to lock the dll that's loaded. I want to have the ability to dynamically load, change the code, compile and reload it again
...