I have an abstract class as follows. I want to get all the values of member variables.
public abstract class PARAMS {
public static final String NAME1 = "VAL1";
public static final String NAME2 = "VAL2";
public static final String NAME3 = "VAL3";
}
The values are retrieved using reflection as follows.
Field[] fields = P...
I have an Android application (java) that was working fine when compiled with the Android 1.6 SDK using the following code from the android.provider.Contacts class:
Uri baseUri = Contacts.Phones.CONTENT_FILTER_URL;
When the 2.0 SDK came out, the android.provider.Contacts class was depreciated and replaced with android.provider.Contact...
I am trying to set a value through reflection. I created this little test program
struct headerIndexes
{
public int AccountNum{ get; set; }
public int other { get; set; }
public int items { get; set; }
}
static void Main(string[] args)
{
headerIndexes headers = new headerIndexes();
...
I am writing a small code generator which would read into an edmx file and create business objects on the base of a template. I am using reflection to spit out the type names.
The problem is when I encounter a property (PropertyInfo) of type Entity Reference, (basically an entity property if there is a referential integrity), the Proper...
List <ClassA> listA; List <ClassB> listB;
Can I use reflection to reflect listA into listB? I got below code but only reflect an object
public static <A, B> B convert(A instance,
Class<B> targetClass) throws Exception {
B target = (B)targetClass.newInstance();
for (Field targetField : targetClas...
public static <A, B> B convert(A instance,
Class<B> targetClass) throws Exception {
B target = (B)targetClass.newInstance();
for (Field targetField : targetClass.getDeclaredFields()) {
targetField.setAccessible(true);
Field field =
instance.getClass().getDeclaredField(targetField.getName())...
While trying to brush up my Ruby skills I keep running across this case which I can't figure out an explanation for by just reading the API docs. An explanation would be greatly appreciated. Here's the example code:
for name in [ :new, :create, :destroy ]
define_method("test_#{name}") do
puts name
end
end
What I want/expect to...
I'm trying to create a delegate of a static method which takes a ref argument. Please don't ask why I'm doing such a cockamamie thing. It's all part of learning how .Net, C#, and reflection work and how to optimize it.
My code is:
public struct DataRow
{
private double t;
static public void Cram_T(ref DataRow...
I've seen a lot of questions asked about instantiating classes from a string but have been unable to find any information on creating a structure the same way.
I have a class which contains a structure like so:
Public Structure callDetails
Public GUID As Guid
Public ringTime as Date
Public CBN As String
etc.
All I really...
I have an implementation building a delegate handler collection.
public class DelegateHandler
{
internal delegate object delegateMethod(object args);
public IntPtr PublishAsyncMethod(MethodInfo method, MethodInfo callback)
{
RuntimeMethodHandle rt;
try
...
Hi! I need to organize some simple security in a class depends on value of the enum.
All that I can figure out is using attribute on a method and then run check then if it fails throw an exception.
Sample:
[ModulePermission(PermissonFlags.Create)]
public void CreateNew()
{
CheckPermission();
System.Windows.Fo...
What should be more proper or what is recommended to use in VB.NET from either reflection vs. late binding:
'Type can be various objects that have a common property for sure.'
Dim type = sender.GetType()
Dim prop = type.GetProperty("Text", 20)
Dim value = property.GetValue(sender, Nothing)
versus:
Dim value = sender.Text
...
I'm creating a WPF application using the MVVM design pattern, and I'm trying to create a Combobox that allows the user to edit the items in the drop-down list at runtime, similar to the way MS Access 2007 lets you do it. So I've created a UserControl that builds on top of a Combobox... when the drop-down is shown, there is a button belo...
Hi all,
I have come across a theory on Auth protocol hacking vulnerability which can be found in http://www.owasp.org/index.php/Reflection_attack_in_an_auth_protocol. I understand how this vulnerability causes problems in exchanging the messages and how to bypass validation to become a logged-in and to be a valid user. The following co...
When catching an exception in .net, you can have as many type-specific exception blocks as needed. But I usually try to have at least one "general" exception catch block. But is there a way to get the type of the "real" exception thrown that is caught by the generic exception handler, perhaps using reflection?
For example, if I have
C...
I'm reading a CSV file and the records are recorded as a string[]. I want to take each record and convert it into a custom object.
T GetMyObject<T>();
Currently I'm doing this through reflection which is really slow. I'm testing with a 515 Meg file with several million records. It takes under 10 seconds to parse. It takes under 20 sec...
Can any one explain the use of Java reflection and introspection? When we need to use both?
...
For various reasons, I need to implement a type caching mechanism in C#. Fortunately, the CLR provides Type.GUID to uniquely identify a type. Unfortunately, I can't find any way to look up a type based on this GUID. There's Type.GetTypeFromCLSID() but based on my understanding of the documentation (and experiments) that does something ve...
I have a file with a dozen classes and i use reflection to generate data from it. I was thinking it may be cool if i had a way to configure all of the classes in that file at once. How might i do this?
-edit- everyone seems confused. I posted a possible solution below.
I want to attach data to a file. While using reflection i would lik...
I googled and someone found the answer and linked but it was dead. How can i find a specific class in a specific file? The poster i found ask that question and found how to do it in a namespace but i would like to find one specific to a file. This question is to answer my other question but now that i thought of this i would like to know...