A little background first. I am looking into the possibility of implementing Ruby's ActiveRecord in Java as cleanly and succinctly as possible. To do this I would need to allow for the following type of method call:
Person person = Person.find("name", "Mike");
Which would resolve to something like:
ActiveRecord.find(Person.class, "na...
Is it possible to get the parameter name (where I have parmName below)?
Or perhaps in the MSIL code there are only relative positions, no absolute parm names?
I have an unusualy case using HIP within Microsoft Host Integration Server. When fields are NULL and the error goes back to CICS (on the mainframe), the error is "A CALL TO VERI...
How can I tell whether Silverlight 2 is sufficient for an assembly or Silverlight 3 is required?
I have all information that is available through reflection (Mono.Cecil).
Same question for SL 3 versus 4.
Thanks in advance.
...
How could I make this work?:
public class myClass
{
public string first;
public int second;
public string third;
}
public string tester(object param)
{
//Catch the name of what was passed not the value and return it
}
//So:
myClass mC = new myClass();
mC.first = "ok";
mC.second = 12;
mC.third = "ko";
//then would return its type...
I have POJO class
Class Book {
private String id;
private String title;
Public Book() {
}
//implement setter and getter
..............
}
main() {
Book book = new Book();
book.setId(1);
book.setTitle("new moon");
}
How to get all instance variable of book object
I want the result become -> 1, "new moon"
without using the getter m...
I have a C# Visual Studio 2008 project and I want use a COM interop XXXXLib (XXXX.dll).
Of course I have to add reference to %windir%\system32\xxxx.dll before, and VS will add Interop.xxxx.dll to the project folder, and now I have to distribute this 200 KB library with my simple 4 KB application.
But, now I know that PCs don't have XXX...
It's there a way to invoke a method and the return type is strong typed ?
There is an example of code
public static IQueryable<T> FilterVersion<T>(this Table<T> t, IVersionIndexFilter version)
where T : class
{
try
{
// Define the new type of my table
Type versionTableType = Type.GetType(typeof(T)...
How can I get the values of parms (in a loop using reflection).
In previous question, someone showed me how to loop through the parms using reflection.
static void Main(string[] args)
{
ManyParms("a","b","c",10,20,true,"end");
Console.ReadLine();
}
static void ManyParms(string a, string b, string c, int d, short e, bool f, s...
How do you check if a assembly loaded is a valid .NET assembly? I currently have this code but unmanaged DLL's throw a BadImageFormatException.
string[] filepaths = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.AllDirectories);
List<Type> potentialEffects = new List<Type>();
foreach (string f...
I have been trying to determine the type of a field in a class. I've seen all the introspection methods but haven't quite figured out how to do it. This is going to be used to generate xml/json from a java class. I've looked at a number of the questions here but haven't found exactly what I need.
Example:
class Person {
public fina...
I need to instantiate WPF types (say, a UserControl or a Page) via reflection for a designer. The problem I'm having is that when I attempt to instantiate these using Activator.CreateInstance I get a TargetInvocationException which wraps, in the end, an exception thrown by the StaticResource markup extension.
Clarification: The types ...
Presume that there are methodA() , methodB() and methodC().
And methodC() is called at the run-time.
Is is possible to know methodC() is called from what method?
I was thinking if CallStack can be read at the run-time for some checks? If yes, I think it should not be a big deal.
Any ideas?
Thanks!
...
Hi
I am loading an assembly in C# using reflection:
Assembly = Assembly.Load([assembly_bytestream]);
The assembly being loaded references another two assemblies. To my understanding reflection will load the main assembly and then search the GAC for the referenced assemblies, if it cannot find it there, you can then incorparate an ass...
Sup Guys,
On my Bussiness Layer, I have something like
Dim object as New ExampleObject
Where ExampleObject inherits BaseExampleObject.
I want to know how can I access ExampleObject Properties by reflection on my BaseExampleObject.
Something like:
MyBase.GetType.GetProperty("PropertyName").GetValue(mybase.gettype, Nothing)
Of cou...
Dear sirs and ladies.
First, a little introduction.
I have to functions:
static class C
{
static void F1(Type type)
{
// Do something to invoke F2<T>
}
static void F2<T>()
{
// bla bla bla
}
}
I wish to invoke F1(Type), which in turn should transition to the generic context pertinent to the given type parameter a...
So I have tried GetType() but for some reason, It does include the namespace...
Does C# not have a property for a class specifying its name?
For example:
public class Parent : System.Web.UI.UserControl {
public someFunction(){
Child child = new Child();
Console.WriteLine(child.ThePropertyThatContainsTheName);
}
}...
Hello,
I've got a method (fyi, I'm using c#), accepting a parameter of type "Func", let's say it's defined as such:
MethodAcceptingFuncParam(Func<bool> thefunction);
I've defined the function to pass in as such:
public bool DoStuff()
{
return true;
}
I can easily call this as such:
MethodAcceptingFuncParam(() => { return Do...
How can I find a generic overloaded method? For example, Queryable's
public static IQueryable<TResult> Select<TSource , TResult> ( this IQueryable<TSource> source , Expression<Func<TSource , int , TResult>> selector );
I've looked for existing solutions, and they're either not generic enough (are based on the method's parameters count...
I have an interesting situation and am trying to do something that I'm not even sure is possible.
I have a .NET 2.0 project that via reflection loads an assembly, and calls a specific method on that assembly. We are looking at moving forward and starting to use .NET 3.5 in the environment, but want to minimize risk with regard to this ...
I have code a bit like this
public class MyObject
{
private bool IsValidDay(ref DateTime theDate)
{
...
}
}
MethodInfo[] methods = myObjectInstance.GetType().GetMethod("IsValidDay", BindingFlags.Instance | BindingFlags.NonPublic);
object[] args = { null };
bool val = (bool)method.Invoke(myObjectInstance, args);
But ...