In a Java Project of mine, I would like to find out programmatically which classes from a given API are used. Is there a good way to do that? Through source code parsing or byte code parsing maybe? Because Reflection won't be of any use, I'm afraid.
To make things simpler: there are no wildcard imports (import com.mycompany.api.*;) anyw...
Hello,
Suppose you have a text file like:
my_setting = ON
some_method = METHOD_A
verbosity = DEBUG
...
That you wish to to update a corresponding object accordingly:
Setting my_setting = ON;
Method some_method = METHOD_A;
Verbosity verbosity = DEBUG;
...
Where all are different kind of enums.
I would like to have a generic way to...
Hi, in reflection, the private field can be access via getDeclaredField() and setAccessible(true). How to access the private field of a outside class via Objectweb ASM bytecode API?
I set to get the private field from something like, via
Field current = sourceObject.getDeclaredField(privateFieldName);
Field.setAccessible(true);
Type so...
I've been reading the android documentation on reflection, but i'm just not really grasping how to actually use it. Is it multiple class files i'll have to create? Is it breaking it up to certain parts all in the same class file? I want to understand it, I really do, but I just don't get it.
Anyway, I have this simple webview code that...
My employer uses Dotfuscator on all our .Net production software. Because of this, we are absolutely forbidden to use ANY built-in databinding or anything that reflects on property/function names - because dotfuscator changes them and therefore anything bound instantly and irredeemably breaks.
I keep rolling this logic over in my mind ...
I'm trying to find types in an assembly that are of ISomeInterface< AnyType > using linq.
How do I do this?
Here's what I have:
AppDomain.CurrentDomain.GetAssemblies().SelectMany(a=>a.GetTypes().Where(t=> /* t is ISomeInterface<ofAnyType> */))
...
i have a application written in c#.for the purpose of logging we are using nlog. while performing the code review it was found that people were not logging the required debug and info statements in each method call.
What i would like to do is write a small program that will iterate through the assembely and for a particular namespace ...
Trying out a new project with Framework 4.0. I have 2 SQL Server tables with matching DBML entities in my project (EntA and EntB).
EntA has a Notes property that maps to a VarChar(50) column.
EntB has a NoteText property that maps to a Char(100) column.
I have some simple Linq-to-SQL code that prepends the text "* Note: " for each e...
So I have this class
public static class MyClass
{
static MyClass()
{
...
}
}
Which has no methods, fields or properties. All it does is wire up handlers to static events defined elsewhere.
Since the Type initializer never gets called, because the static class is never actually accessed, the events don't get wire...
Hi All,
I am writing some validation code. The code will take data passed into a web service and decide whether it can do the action, or return a message to the caller that they have missed out some fields etc.
I have it mostly working except for arrays. I am marking up the properties with a [RequiredField] attribute to represent field...
I want to disable reflection optimization (testing purposes), but i don't know where to do it. NH 2.1.2 uses hibernate-configuration in XML, and docs clearly state that this setting can not be set here. :/ I tried doing it the old App.config way with key/value pairs, no luck ...
Also, did NH 2+ version change something about reflection...
A suite of data models built on top of Qt's reflection system seems like a natural synergy, but I haven't found such a beast in the Qt library itself or from a 3rd party. Does anyone know if such a thing exists?
I'm look for data models for editing and displaying a collection of QObjects QMetaObject properties. I can kind of understand ...
I have a WebClient instance that receives data from a remote website. I referenced a DownloadProgressChanged event handler and I am trying to access InnerBuffer, which is an internal field in the DownloadBitsState nested class (set as private) in WebClient.
I am using the following code right in the DownloadProgressChanged event handler...
I am getting an InvalidOperationException with the message:
"Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true."
The following is the relevant part of the code:
// Gets the entity type of the table to update.
Type entityType = Jobs.GetType(syncSettings.TableToUpdate);
// Creates...
I'm trying to create a base class for my POCO objects in .NET 4, which will have an Include(string path) method, where path is a "." delimited navigation path of nested ICollection properties of the inheriting class to be enumerated.
For example, given the following classes;
public class Region
{
public string Name { get; set; }
...
Could anyone provide an example how to create a structure instance at runtime? The structure I'm using doesn't define any constructors, just fields. The GetConstructor() method returns null, and so far I was unable to find a way to achieve this.
...
class CBase
{
object A {get;set;}
object B {get;set;}
}
class CDerived : CBase
{
object X {get;set}
object Y {get;set;}
}
I'm trying to get first level properties. For the example above, intended properties are X and Y, not A and B. With the following code i'm getting all the properties {A,B,X,Y}. Is there any solution without att...
I wonder if there is a way to restrict invoke call to a function? Let me make it clear.
[Assembly:a1]
Class A
{
function Af();
}
[Assembly:a2]
Class B
{
function Bf(){
//load Assembly a1
//InvokeMember to Af
}
}
After compilation I will have 2 assemblies. Now if I distribute to client, anyone can copy assembly...
This is mostly for educational purposes. I'm trying to create the InputMapper class, which is used in this example:
var mapper = new InputMapper<SomeType>();
mapper.Map("some user input", someType => someType.IntProperty, "Input was not an integer");
mapper.Map("some user input", someType => someType.BoolProperty, "Input was not a bool"...
I want to compare two values at runtime using reflection. I was using Comparer.Default.Compare(x,y) for this, but I have come to realize that this is not adequate. Let's say I want to compare a double to a single (1.0 == 10). Comparer.Default will throw an exception because it insists that both values must be the same type (double). Howe...