I have a windows form with a listview control. I have a selectedIndex changed event where i am performing some action. Through reflection I am trying to set the value of the list view.
But the event is not getting fired. Any help will be helpfull.
Edit
The event looks like
private void LV1_SelectedIndexChanged(object sender, Event...
I have two interfaces, a generic and a non-generic that have an inheritence hierarchy:
public interface IGenericRelation<TParent, TChild> : IRelation
public interface IRelation
The generic one is implemented by several server controls that are loaded dynamically and I wish to enumerate on the collection of controls that implement th...
What is the best way to know if the code block is inside TransactionScope?
Is Transaction.Current a realiable way to do it or there are any subtleties?
Is it possible to access internal ContextData.CurrentData.CurrentScope (in System.Transactions) with reflection? If yes, how?
Thank you in advance.
...
How do you reflectively, or dynamically, execute code in .Net? If an XML contains something inside '[]' I want to handle the text not as text but as code:
<Name>DateZero</Name>
<Value>DateTime.Now.AddDays(-2)</Value>
<Name>DateOne</Name>
<Value>[DateTime.Now.AddDays(-1).ToString("MM/dd/yy")]</Value>
<Name>DateTwo</Name>
<Value>[DateT...
I have two objects that contain some properties that are exactly the same (same name, type). What I want to do is populate one object's identical properties with another object's properties. I am trying to do this in code, but it's not working. The Bin object's properties are not being set.
class Basket{
public Basket(int itemId, in...
I'm trying to determine if the MethodInfo object that I get from a GetMethod call on a type instance is implemented by the type or by it's base.
For example:
Foo foo = new Foo();
MethodInfo methodInfo = foo.GetType().GetMethod("ToString",BindingFlags|Instance);
the ToString method may be implemented in the Foo class or not. I want t...
I would like to perform a test if an object is of a generic type. I've tried the following without success:
public bool Test()
{
List<int> list = new List<int>();
return list.GetType() == typeof(List<>);
}
What am I doing wrong and how do I perform this test?
...
Hey everyone,
I have a .Net app that's compiled as "Any CPU". I am running it on a x64 OS so it's running as 64bit. The application loads other assemblies that the user provides. It uses reflection of course to read types from the user provided assembly. Everything works fine if the user assembly is compiled as "Any CPU". But if the ass...
Hi!
Background: I'm using WPF and C# (3.5) and am working on an app that allows a user to view a form/window/usercontrol that's already part of a compiled assembly. When they view it, they should be able to click on any control (buttons, textboxes, even labels), a little popup editor should appear by the control where they can then ty...
I'm having some trouble using reflection to differentiate between a non-generic and a generic method on a generic class. Here's a test case I'm working with:
public class Foo<T>
{
public string Bar( T value ) { return "Called Bar(T)"; }
public string Bar( int value ) { return "Called Bar(int)"; }
public static void CallBar<TR>(F...
Hello,
I am trying to use reflection to create object array of the type created from reflection like the folowing:
Client[] newArray = new Client[] {client1, client2};
I need to somehow get the Client object type to create the object so it can be passed through.
Any help would be greatly appreciated.
Cheers,
Rob
object clientObjec...
I have a linq Context that I am looking at all the data Tables, I am trying to get the list of fields in all tables
foreach (var code in ctx.GetType().GetProperties())
{
Console.WriteLine(code.PropertyType + " - " + code.Name + " ");
if (code.PropertyType.ToString().Contains("System.Data.Linq.Tab...
I cant get the method info for an extension method as I would suspect. Whats wrong?
_toStringMethod = typeof(ObjectExtensions).GetMethod("TryToString",
BindingFlags.Public | BindingFlags.Static);
...
public class Foo
{
public string Bar {get; set;}
}
How do I get the value of Bar, a string property, via reflection? The following code will throw an exception if the PropertyInfo type is a System.String
Foo f = new Foo();
f.Bar = "Jon Skeet is god.";
foreach(var property in f.GetType().GetProperties())
{
object o...
I wrote this example to help explain. As you can see I have an object hierarchy. I'd like to modify the GetFeatures() function to only return the features added by constructor of object type I instantiated. For example, BasicModel.GetFeatures(new LuxuryModel()) should only return the features "Leather Seats" and "Sunroof". I don't mind u...
Why does the following code produce no output?
static void Main(string[] args)
{
FieldInfo[] fi = typeof(MyStruct).GetFields(BindingFlags.Public);
foreach (FieldInfo info in fi)
{
Console.WriteLine(info.Name);
}
}
public struct MyStruct
{
public int one;
public...
Hey anyone,
I got a question about Java Reflections: I have to checkout, if a certain field of a class is an array.
But my problem is: If i run isArray() on the attribute of the class directly, it works. But if I use it in the way below, it won"t work. I guess because the "real" array is in this Field class?
Any idea how i get it to work...
Say you have a flexunit test that looks like this:
package foo {
import flexunit.framework.TestCase;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedSuperclassName;
class DescribeTypeTest {
public function testDescribeInnerType():void {
var currentInstance:ChildBar = new ChildBar();
...
In the spirit of the c# question..
What is the equivalent statements to compare class types in VB.NET?
...
I am currently writing some code to save general objects to XML using reflection in c#.
The problem is when reading the XML back in some of the objects are structs and I can't work out how to initialise the struct. For a class I can use
ConstructorInfo constructor = SomeClass.GetConstructor(Type.EmptyTypes);
however, for a struct, t...