Whats the shortest way to assert that an attribute is applied to method in c#?
Whats the shortest way to assert that an attribute is applied to method in c#? I'm using nunit-2.5 :) ...
Whats the shortest way to assert that an attribute is applied to method in c#? I'm using nunit-2.5 :) ...
Hi, I wish to initialize an array of java methods in the child class, as a class field like so void callme() {System.out.println("hi!");} Method[] actions = new Method[] {&callme,&callme}; and call all methods in this array at parent class like so: for (meth:actions) {meth.invoke();} However currently I cannot find a way to implici...
I have created a managed dll and I would like to get the executable name it is attached to.... I have read this: http://stackoverflow.com/questions/121116/how-to-get-the-executable-path-from-a-managed-dll It works fine with .net executables.... but when the dll runs under a com process, I don't have a .Net assembly... so Assembly.GetEnt...
Hi, Is there any way to add Field (or FieldInfo, maybe this is the same) to the class in runtime? Thanks, Paul. ...
Is there a penalty for calling newInstance() or is it the same mechanism underneath? How much overhead if any does newInstance() have over the new keyword* ? *: Discounting the fact that newInstance() implies using reflection. ...
I'm reading information from an XML which contains the type of an object that I need to instantiate along with it's constructor parameters. The object type is actually in another project, within a sibling namespace. (I need to create a Company.Project2.Type within Company.Project1 class.) I found this question, but it doesn't handle th...
The code below successfully recognizes internal classes which are decorated with my custom "Module" attribute, I load the assembly like this: Assembly assembly = Assembly.GetExecutingAssembly(); However, when I load in an external module and look through its classes, it finds the classes in the external assembly but does not recognize...
Hello, Let me describe the problem and the solution i currently have and maybe you can help enlighten me on why it's a bad idea (assuming it is) and what i can do to make it a better system. right now i have 600 "rippers" that parse files and rip them to csv or other formats. the rippers all implement a common interface and base class....
As a perl programmer I can evaluate strings as code If I wished, Can I do the same in C#( with strings or some other object containing user input)? What I want to accomplish is to create an object where its methods may be predefined in my source code or may be defined at run-time by the user by entering a string that represents C# code...
I'm using LINQ-to-XML to query a file for a list of objects. They all have the same structure (a set number of options, a list of parameters of indeterminate length). Based on their name in the XML file, I want to use the parameters for entirely different things - so I made subclasses of this object. My question is - how do I invoke th...
Example: MyProgram.exe is executed. It calls MyClassLibrary1.dll which calls MyClassLibrary2.dll. How can I determine from within MyClassLibrary2.dll what the assembly version of MyProgram.exe is? Is this possible? Thanks. ...
I need to implement the method: object GetFactory(Type type); This method needs to return a Func<T> where typeparam 'T' is the 'type'. So, my problem is that I don't know how to create a Func<?> at runtime using reflection. Activator.CreateInstance doesn't work because there are no constructors on delegates. Any Ideas? ...
I want to load to new AppDomin some assembly which has a complex references tree (MyDll.dll -> Microsoft.Office.Interop.Excel.dll -> Microsoft.Vbe.Interop.dll -> Office.dll -> stdole.dll) As far as I understood, when an assembly is been loaded to AppDomain, it's references would not be loaded automatically, and I have to load them manua...
This is similar to Invoking a method using reflection on a singleton object but it has a much deeper context. First I want to say this is for a project I was just playing around with ideas on, this is in NO way production code, and the project has taken a VERY different path, but this problem still haunts me so here it goes. I have a s...
Hello, For pupose of explaining let's say that I have a Company object which has an Address property of type Address. so it would be something like: public class Company { Address CompanyAddress; } public class Address { int Number; string StreetName; } Now I have a method that works with any kind of object ty...
I'm looping through an array of class names in PHP, fetched via get_declared_classes(). How can I check each class name to detect whether or not that particular class is an abstract class or not? ...
Let's say that I have the following delegate: public delegate void Example(); and a class such as the following: public class TestClass { Example FailingTest = () => Assert.Equal(0,1); } How can I use reflection to get the name "FailingTest"? So far I have tried: var possibleFields = typeof(TestClass).GetFields(relevant_bindi...
At the moment my code successfully sets the value of fields/properties/arrays of an object using reflection given a path to the field/property from the root object. e.g. //MyObject.MySubProperty.MyProperty SetValue('MySubProperty/MyProperty', 'new value', MyObject); The above example would set 'MyProperty' property of the 'MyObject' ...
Strange one here. My MVC Web Application's version number is not printing correctly to my view according to what is set in AssemblyInfo.cs. The definition I have set in set AssemblyInfo.cs is '1.0.232.0'. I have tried multiple methods in order to print it: <%= System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToStri...
Is there anyway I can get the name of class property "IntProperty"? public class ClassName { public static int IntProperty { get { return 0; } } } //something like below but I want to get the string of "IntProperty" ClassName.IntProperty.GetType().Name Basically what I want to do is to dyanmically save property name string into dat...