with dynamic, awkward reflection no more?
C# 4.0 introduces dynamic keyword, which will look up at run-time. Does this mean we'll need awkward reflection no more? If does, Can you show up an example of it? ...
C# 4.0 introduces dynamic keyword, which will look up at run-time. Does this mean we'll need awkward reflection no more? If does, Can you show up an example of it? ...
I want to remove all null properties in a generic object. It doesn't have to be recursive, one level deep is also fine. The reason I need is for a custom JavascriptConvertor implementation for JSON serialization which gives me: {"Name":"Aleem", "Age":null, "Type":"Employee"} And I would like to skip over the null object. The function ...
My PC have a dual core CPU and I was wondering - would it be possible to reduce .NET reflection times by two, if I start processing in a two thread. By "processing" I have meant the following: 1.loading the assembly 2.getting all types out of it (.GetTypes()) 3.processing these types 4.querying these types for methods etc. If yes - w...
Hi, I have multiple instances of a class in my code, each with difference configs etc. This class has a delegate eventhandler method which receives event from a sender and then need to perform some action with one of the above objects. I would like to know if reflection can resolve this. private CatClass cat1; private CatClass cat2; p...
Hi folks, I am trying to write a method for a Compact Framework 2.0 dll which will return the name of the parent application from which the dll is called but I am struggling to see how to do this. Using reflection I am able to get the dll I have written etc - any ideas how to get the application name? Thanks Morris ...
Hello I have a function that accepts any object, then it gets values from the properties or fields that it has as input. It currently looks like this: private string GetFieldValue(object o, Field f) { //field.name is name of property or field MemberInfo[] mi = o.GetType().GetMember(field.name, MemberTypes.Field | MemberTypes....
I am trying to make a method that will go through a list of generic objects and replace all their properties of type string which is either null or empty with a replacement. How is a good way to do this? I have this kind of... shell... so far: public static void ReplaceEmptyStrings<T>(List<T> list, string replacement) { var proper...
I am trying to determine the class type of a class using reflection and then do something specific. For example, if the class is a double, use a double specific method. I am attempting to use if(f.getClass() == Double.class) However, I am getting a compiler error: "Incompatible operand types Class <capture#1-of ? extends Field> a...
I am attempting to edit some resources in another .NET executable, using reflection. Is this possible/how would I do this? Or am I going down completely the wrong route? ...
Hi, I have 2 different java projects, one has 2 classes dynamicbeans.DynamicBean2 dynamic.Validator On the other project, I load both of these classes dynamically and store them on an Object class Form { Class beanClass; Class validatorClass; Validator validator; } I then go ahead and create a Validator object using v...
I started looking at Silverlight.FX by Nikhil Kothari to replace Prism/Unity with our Silverlight 3 project. So far I like the code layout and structure. It looks well thought out. But I can't get a lot of the samples working due to a System.Reflection.AmbiguousMatchException. Anyone else seeing this? Should I not be using this framewo...
Hey, I want to print out the contents of a backing bean in an auto-generated way. So all the contents appear on a JSP. Is this possible anyhow? Thanks in advance, Daniel ...
hey guys, I'm very excited about the dynamic features in C# (C#4 dynamic keyword - why not?), especially because in certain Library parts of my code I use a lot of reflection. My question is twofold: 1. does "dynamic" replace Generics, as in the case below? Generics method: public static void Do_Something_If_Object_Not_Null<SomeType...
Hi girls and guys! I am currently working on a little localization framework for WPF (don't even think about pointing me to locBAML...) and wondered if it was possible to find out the containing assembly of a specified DependencyObject. For example: I have a normal window definition in XAML in the file Window1.xaml. The window contains...
Hi, I am wondering how I can fetch the incoming arguments of my method in an array. Or just retrieve the values of my arguments dynamicly. Meaning, a call like: MyMethod(10, "eleven"); For method: void MyMethod(int Test, str Test2) {} Would resolve in an array like: {{"Test" => 10}, {"Test2", "eleven"}} Would be even better if I cou...
Hi Guys, Its been one of those days can someone help me out with this. I have 2 Stock Objects which I want to compare properties of at runtime. One instance is the cached instance, the other is a new stock instance which has just been delivered to my system, which may or may not equal the cached instance. See below where m is a method ...
I have an ojbect with a function that takes an out argument. I want to call this function using reflection's Invoke. However, I can't find a way to specify that it's an out argument, as it is returned null. Class Foo { void Do(out string a){ a="fx call"; } } Foo f = new Foo(); string param = string.Empty; f.GetType().GetMethod("Do...
Consider this scenario: I've an XML file called person.xml with the following data in it. <person> <name>MrFoo</name> <age>28</age> </person> If I want to read this XML into a Java object, I would be creating a Java bean called PersonBean (with getters/setters for the attributes) as: class Person{ String name; int age...
I want to enforce on my code base immutable rule with following test [TestFixture] public class TestEntityIf { [Test] public void IsImmutable() { var setterCount = (from s in typeof (Entity).GetProperties(BindingFlags.Public | BindingFlags.Instance) where s.CanWrite select s) ...
I have an instance of System.Type, for which "IsArray" returns true. How can I determine the "nested type" of the array type? i.e. Type GetArrayType(Type t) { if(t.IsArray) { // What to put here? } throw new Exception("Type is not an array"); } Assert.That(GetArrayType(typeof(string[])), Iz.EqualTo(typeof(str...