c# - Set object property using reflection - Stack Overflow
Another approach is to get the metadata for the property, and then set it. This will allow you to check for the existence of the property, and verify that it can be set: using System.Reflection; MyObject obj = new MyObject(); PropertyInfo prop = obj.GetType().GetProperty("Name", BindingFlags.Public | BindingFlags.Instance);
c# - 'casting' with reflection - Stack Overflow
Consider the following sample code: public long SomeProperty { get; set; } // value is of type decimal, but is in reality a natural number => cast. instance.SomeProperty = (long)value; Now I need to do something similar through reflection: // throws System.ArgumentException: Decimal can not be converted to Int64.
c# - Reflection: How to Invoke Method with parameters
On .Net 4.7.2 to invoke a method inside a class loaded from an external assembly you can use the following code in VB.net. Dim assembly As Reflection.Assembly = Nothing. Try. assembly = Reflection.Assembly.LoadFile(basePath & AssemblyFileName) Dim typeIni = assembly.[GetType](AssemblyNameSpace & "."
How to dynamically create generic C# object using reflection?
I want to dynamically create TaskA or TaskB using C# reflection (Activator.CreateInstance). However I wouldn't know the type before hand, so I need to dynamically create TaskA based on string like "namespace.TaskA" or "namespace.TaskAB".
reflection - How do I invoke a Java method when given the ...
Method method = c.getDeclaredMethod("method name", parameterTypes); method.invoke(objectToInvokeOn, params); Where: "class name" is the name of the class. objectToInvokeOn is of type Object and is the object you want to invoke the method on. "method name" is the name of the method you want to call.
c# - Adding items to List using reflection - Stack Overflow
I've worked quite a bit with reflection a while ago, and I came to the conclusion that I don't like the overload of GetMethod(string), because I never knew if it would return. Try rather using GetMethod(string, Type[]) or GetMethod(string, BindingFlags). Might not make it work, and might just be me beeing paranoid, but I remember having a lot ...
Checking for IEnumerable with reflection - Stack Overflow
The bare-bones version of this question is, if I have some object o, how would I check to see if o is of some type that implements IEnumerable with reflection? The original question is much more specific, but an answer to the above would be just as good. Sorry if I gave too much detail on this question. END EDIT
reflection - Java: accessing private constructor with type parameters ...
// reflection concept to get constructor of a Singleton class. Constructor constructor = Singleton.class.getDeclaredConstructor(); // change the accessibility of constructor for outside a class object creation. constructor.setAccessible(true); // creates object of a class as constructor is accessible now.
Reflection - get attribute name and value on property
I have solved similar problems by writing a Generic Extension Property Attribute Helper: using System; using System.Linq; using System.Linq.Expressions; using System.Reflection; public static class AttributeHelper { public static TValue GetPropertyAttributeValue( Expression> propertyExpression, Func valueSelector) where TAttribute ...
c# - Getting Enum value via reflection - Stack Overflow
@hvd: Thanks for your comment. I 'd say that the very fact that the second argument passed to Convert.ChangeType is a type object (i.e. an object of type System.Type which is a subclass of System.Reflection.MemberInfo) means that even the conversion itself is using the reflection infrastructure of the .NET CLR! So, I don't think I have ignored ...
|