Declaring a property in a derived class that matches the name of a property in the base class "hides" it (unless it overrides it with the override keyword). Both the base and derived class properties will be returned by Type.GetProperties() if their types don't match. However, if their types do match, shockingly only the derived class'...
Hi all,
I wrote a method which exports values to excel file from an IEnumerable parameter.
Method worked fine for my little test class and i was happy till i test my method with
a LINQ class.
Method:
public static void IEnumerableToExcel<T>(IEnumerable<T> data, HttpResponse Response)
{
Response.Clear();
Response.Co...
Continuing on my quest for a good plugin implementation I have been testing the StructureMap assembly scanning features.
All plugins will inherit from abstract class PluginBase. This will provide access to common application services such as logging. Depending on it's function, each plugin may then implement additional interfaces, for e...
I'am looking for a solution to access 'flatten' (lowest) properties values of a class and its derived via reflection by property names.
ie access either Property1 or Property2 from the ClassB or ClassC type :
public class ClassA
{
public virtual object Property1 { get; set; }
public object Property2 { get; set; ...
So, I have been trying to research this all morning, and have had no luck. I am trying to find a way to dynamically create a method/delegate/lambda that returns a new instance of a certain class (not known until runtime) that inherits from a certain base class.
I can guarantee the following about the unknown/dynamic class
It will alwa...
Possible Duplicate:
Can you find all classes in a package using reflection?
suppose I've a package name as string:
String pkgName = "com.forat.web.servlets";
How to know the types in this package?
...
Is there a simple way to get the PropertyInfo for a property in a delegate, assuming it is a simple property seletor?
Example:
var propertyInfo = Method<MyClass,int>(s => s.Property);
...
PropertyInfo Method(Func<T1,T2> selector)
{
// What goes here?
}
...
Imagine I have the following situation:
Test1.java
import java.lang.ref.WeakReference;
public class Test1
{
public WeakReference fieldName;
public init()
{
fieldName = new WeakReference(this);
Test2.setWeakRef(fieldName);
}
}
Test2.java
import java.lang.ref.WeakReference;
public class Test2
{
...
Say I somehow got an object reference from an other class:
Object myObj = anObject;
Now I can get the class of this object:
Class objClass = myObj.getClass();
Now, I can get all constructors of this class:
Constructor[] constructors = objClass.getConstructors();
Now, I can loop every constructor:
if (constructors.length > 0)
{
...
Hello
I have an object that has a lot of attributes, each one with it's getter and setter. Each attribute has a non primitive type, that I don't know at runtime.
For example, what I have is this:
public class a{
private typeA attr1;
private typeB attr2;
public typeA getAttr1(){ return attr1; }
public typeB getAttr2()...
I want to print out a list of all the different Types loaded in a running .NET process. My plan is to eventually build a GUI app based on this, so I want to do this from my code as opposed to a third party tool. I think my best bet is to use MDbgCore to attach to the running process, and then use MDbgProcess.AppDomains to get CorAppDomai...
hey guys
We have a "log" class which uses Relection.MethodBase to send current class info to the log.
The reflection.MethodBase stuff happens in the class itself.
However, I'd like to move that stuff to a single external "log" singleton type class.
In this scenario the external log class needs to get the CALLING info, not the current...
Hi
i am trying to implement a generic method which allows to output csv file
public static void WriteToCsv<T>(List<T> list) where T : new()
{
const string attachment = "attachment; filename=PersonList.csv";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext...
I have an interesting challenge that I'm wondering if anyone here can give me some direction.
I'm writing a .Net windows forms application that runs on a network and uses an SQL Server to save and pull data.
I want to offer a mini "plugin" API, where developers can build their own assemblies and implement a specific interface (IDataMan...
Hello, all!
I have a SQL Server database for which I have created a strongly-typed DataSet (using the DataSet Designer in Visual Studio 2008), so all the adapters and select commands and whatnot were created for me by the wizard.
It's a small database with largely static data, so I would like to pull the contents of this DB in its en...
Hi,
I'm trying to load an assembly, instantiate a class from that assembly, and then call Run(), which should set a property inside this instance.
Loading the assembly seems to work fine as I'm able to list the types, but the called method seems to be ineffective: the property located in the new instance remains set to null, depsite th...
Hello !
I am building graphs. A graph consists of nodes linked each other with links (indeed my dear).
In order to assign a given behavior to each node, I implemented the strategy pattern.
class Node {
public BaseNodeBehavior Behavior {get; set;}
}
As a result, in many parts of the application, I am extensively using type reflect...
Currently, I have a bunch of Java classes that implement a Processor interface, meaning they all have a processRequest(String key) method. The idea is that each class has a few (say, <10) member Strings, and each of those maps to a method in that class via the processRequest method, like so:
class FooProcessor implements Processor
{
...
using System;
using System.Reflection;
namespace A
{
interface IObjectWithId<TId>
{
TId Id { get; }
}
interface IEntityBase : IObjectWithId<object>
{
new object Id { get; }
}
abstract class BusinessObject<TId> : IObjectWithId<TId>
{
public abstract TId Id { get; }
}
class EntityBase : BusinessObject<objec...
I've modified an object dumping method to avoid circual references causing a StackOverflow error. This is what I ended up with:
//returns all fields of the given object in a string
public static String dumpFields(Object o, int callCount, ArrayList excludeList)
{
//add this object to the exclude list to avoid circual references in th...