Hi,
I need to fetch all the properties of an anonmous type which can be written to.
eg:
var person = new {Name = "Person's Name", Age = 25};
Type anonymousType = person.GetType();
var properties = anonymousType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
The problem is that all the properties have their ...
I was going through Getting Started (with PostSharp)
And when I saw PostSharp injected (is this expression is right?) an aspect code into assembly, I saw this oddly named class marked with CompilerGeneratedAttribute.
It is named <>AspectsImplementationDetails_1.
As far as I know, class name cannot be started with <>.
But how is it po...
I'm trying to add generic service support to our IoC container, and I have a question.
Let's say I have the following type:
public interface IService<T> { ... }
public class Service<T> : IService<T> { ... }
and then the following code:
Type type = typeof(Service<>); // <-- notice no specific type here
ConstructorInfo ctor = LogicToF...
Using reflection (i'm guessing?), is it possible to create a method that will return a collection of all objects that inherit from an interface named IBlahblah?
public interface IBlahblah;
...
I'm learning scala and can't find out how to do this:
I'm doing a mapper between scala objects and google appengine entities, so if i have a class like this:
class Student {
var id:Long
var name:String
}
I need to create an instance of that class, in java i would get the Field by it's name and then do field.set(object, value)...
Are there any good algorithms for determining the "best" type to instantiate in order to fulfill a request?
For instance say I have the following classes:
public interface ISometype<T> {}
public class SomeTypeImpl<T>:ISometype<T> {}
public class SomeSpecificTypeImpl<T>:ISometype<T> where T: ISpecificSpecifier {}
public interface ISpeci...
Greetings,
I have a large number of fitnesse tests for a project (1000+). Over time as features change, and shared fixtures come and go we have been left with unused orphaned code. But how to find it?
For those who don't know how fit works, you have a wiki page with a like like this:
| When a User Adds | 1 | and | 2 | He is returned...
Hi there,
I do need a solution for loading lists of objects - lookups where only one property is referenced from the current object as in this example.
class LookupObjectAddress
{
[...]
public string City
{ get; set; }
[...]
}
class WorkingObject
{
// references the property from LookupObjectAddress
public string City
{ get; s...
So I want to be able to add/remove class methods at runtime. Before you tell me that's horrible pratice in oop, it might be, but I don't really care. The reason I want to be able to do this is because I want the application to be very modular, so some plugin could extend some base class and add methods to it without killing the the main ...
Hi, I will get dll's dynamically. I need to load the dll and get the namespace, classname to invoke a method (the method name is static it will be always "OnStart()").
Basically I need to run a method by loading the dll. Can somebody help!!!.
...
I'm using reflection to access and store properties and fields. However, to avoid having redundant data, I want to get rid of auto-implemented properties' backing fields, which are also enumerated as normal fields. Looks like these backing fields are named as "{PropertyName}k_BackingField", and it would seem that I could make do with jus...
Hello, I'm creating 'generic' wrapper above SQL procedures, and I can resolve all required parameters' names and sqltypes, but is there any way how to get it's 'underlying' .NET type?
My goal is to do something like:
SqlParameter param;
object value;
object correctParam = param.GetNETType().GetMethod("Parse",
new Type[] { typeof(...
I'm looking for a way to extract the essence of a signature in Java. The reason is that I want to use the signature as a unique key in a Map for my java.lang.reflect.Proxies.
With this code:
public interface MyInterface {
public int compute(String s);
}
...
public static void main (String... args) throws Exception {
InvocationHand...
a. My C# program will load a dll (which is dynamic), for now let's take a.dll (similarly my program will load more dll like b.dll, c.dll, etc....).
b. My program will invoke a method "Onstart" inside a.dll (it's constant for all the dll).
I am able to achieve the above 2 cases by reflection mechanism.
The problem is
a. If my a.dll ha...
How can I access a simple java object as a bean?
For example:
class Simple {
private String foo;
String getFoo() {
return foo;
}
private void setFoo( String foo ) {
this.foo = foo;
}
}
Now I want to use this object like this:
Simple simple = new Simple();
simple.setFoo( "hello" );
checkSettings( ...
How will I know if an object instance is a property or a sub property of another object instance?
for example I have this class structure:
public class Car
{
public Manufacturer Manufacturer {get;set;}
}
public class Manufacturer
{
public List<Supplier> {get;set;}
}
public class Supplier
{
string SupplierName {get...
I have the following method:
object GetIndexer()
The result of the method is an indexer of the type:
SomeCollection<T>
Now T can be anything, by I know that each T extends the type Y.
I tried casting
SomeCollection<Y> result= (SomeCollection<Y>) GetIndexer()
It didn't work.
What I need to know is how to access a property for ...
Hi all,
I am using PostSharp to add some compile time logic to my attributes - in once case [IndexedCategory ("CatName", CatIndex)]. The trouble comes comes in because IndexedCategory derives from CompoundAspect - which has a reasonable number of named params.
Is there any way which I can prevent these from being accessed / shown by i...
I'm using reflection to examine the following method declaration and am wondering if it is possible to determine that the method's sole parameter is a function pointer.
public ref class T
{
public:
void foo(Int32 (*)(String^, array<TimeSpan>^)) { }
};
When inspecting the ParameterInfo object for foo's parameter, it shows that the ...
I am using VB.Net. I have an object class called clsA(of T as clsB). Depending on what T is, I want to do different things. Let's say that clsC and clsD both inherit clsB and therefore can be used for T.
If I have an instance of clsA(of clsC), how can I get the inside type (i.e. clsC) using reflection? Solutions in C#.Net would be fi...