Imagine type like this (C#):
public interface IAmGeneric<T>
{
void SoAmI<T1>(T one, T1 two);
}
Given I have open generic MethodInfo from open generic version of the type (IAmGeneric<>.SoAmI<>()) and the following array
new[] { typeof(int), typeof(string) }'
I'm looking for well performing and reliable way of getting closed versi...
I'm trying to write a data access layer for an AJAX web project. This DAL has to convert data coming in via an AJAX servlet to objects that can be passed to a PreparedStatement for execution.
Data in the AJAX servlet, retrieved by using HttpServletRequest.getParameter(...), come in as strings.
In each data class, I have a known set of ...
I made a custom Annotation for my project which will be used only with fields, that is
@MyAnnotation int myVariable
I have another class which will be in charge of performing some actions according to the variables values.The project has an undetermined number of classes with annotations included. How can I access them using my anno...
Hi,
I'm attempting to dynamically register entities and configurations with a context (ef4 code-only)
I would normally do:
Private Shared Sub ConfigureDatabase(ByRef Builder As ContextBuilder(Of ContextExtension))
'Load configurations for each of the tables (Entity sets) in our database...
ConfigureEntity(Builder, New ContactConfi...
Hi folks,
I'm trying to find the first property of a class that is an Integer .. and get it's value.
So i've got the following code .. which always returns false:
foreach(var property in type.GetProperties(BindingFlags.Public |
BindingFlags.Instance))
{
var someType = property.PropertyType is int; // Always false.
}
Why is ...
how to set text property assigned to the control created dynamically usiong reflection?
Type type = Type.GetType(strFullName);
object instance = Activator.CreateInstance(type);
ctrlTemp = (Control)instance;
ctrlTemp.ID = "Hello";
ctrlTemp.Text???
Panel1.Controls.Add(ctrlTemp);
...
I have an abstract generic class.
public abstract class FieldHandlerWithData<DataType extends Parcelable>
extends FieldHandler
Now I have an object c
Class<? extends FieldHandler> c = getHandlerClass(type);
and now I want to test if c inherits FieldHandlerWithData (directly or indirectly).
How to determine whether c inherits F...
Hello,
I have an app which I want to run on as many Android phones as possible. My current solution is to just compile it with the newest version and doing the critical code in sections that will only be used on devices with the correct Android version. This worked fine until I started using Android 2.2. Now running the app on older pho...
My question is there any way to retrieve the parameter list with its value using Reflection?
I want to use reflection to get the parameter list from the PropertyInfo.
Author author = (Author)attribute;
string name = author.name;
is not OK. As there will be many Attribute, which is not typeof Author.
[AttributeUsage(AttributeTarget...
The web service has SoapExtension, which contains an error handler and serializing error in a format xml.
<? Xml version = "1.0" encoding = "utf-8" standalone = "yes"?>
<Exception Type="System.NullReferenceException"> Exception text. </ Exception>
How to make error handler, which call error of "Type"? E.g.:
Type _type = Type.GetType(...
I am trying to search 33 .dll to find references for a method, It takes more than 10 minutes to through all the dlls and find references.
Is there a way to speed up things.
each of these dll's approximately has 450 classes and each of this class has approximately 200 methods each
Step that I follow:
`
assemblyName = System.IO.Path.Ge...
I'm trying to use Assembly.Load(Byte[]) in a Silverlight 4 app and i'm getting MethodAccessException. As far as I understand that's because my app code is Transparent and this method is Critical. Is there any SafeCritical API to load assembly from byte array?
Then I want to create an instance of type (SL app doesn't have a compile time ...
Some background to my issue:
It appears that there is a change/bug in Mvc2 concerning ValidateAntiForgeryTokenAttribute.
When upgrading from Mvc1 to Mvc2, users with an active session will receive the following error when they request a page using ValidateAntiForgeryTokenAttribute:
Unable to cast object of type 'System.Web.UI.Trip...
Hello,
Basically I just want to get the properties of the derived class with [Test] attribute from the base class.
Here is my sample code:
namespace TestConsole
{
public class BaseClass
{
private System.Int64 _id;
public BaseClass()
{ }
[Test]
public System.Int64 ID
{
...
Possible Duplicate:
When should I use attribute in C#?
Hi, I am trying to understand how Attributes in .net works.
As we all know Attributes are of two types metadata and context attributes.
Metadata attributes: it allows some data to be attached to a class or method. This data becomes part of the metadata for the class, an...
If the ms variable is a MemoryStream and contains a .Net assembly, you would normally run it like this:
var asm = Assembly.Load(ms.ToArray());
var entry = asm.EntryPoint;
var inst = asm.CreateInstance(entry.Name);
entry.Invoke(inst, null);
This works well on console applications and windows forms applications, however, WPF applicat...
Let's say I have retrieved a System.Type object using reflection and want to use that type to convert a List<Object> into another List of that type.
If I try:
Type type = GetTypeUsingReflection();
var myNewList = listObject.ConvertAll(x => Convert.ChangeType(x, type));
I get an exception since the object does not implement the IConv...
.NET 4.0 don't use medium trust it got a different kind of security, does that mean it's ok to use like NHibernate on hostings that support .NET 4.0? I mean straight out the gate with it no modifications with proxy.
...
I want to find all the method calls in one class which are made on another class.
For example:
If class1 calls class2.Foo() but not class2.Bar() then I want to know about it.
Almost like an analysis of coupling. Is this possible with reflection?
...
Let's say I have a class like so:
class Gerbil{
int id;
float x,y,z;
}
Let's further say this is part of a real-time simulation where I have a server/client setup and I change a property on the server-side:
//...
gerbil.x = 9.0;
//...
Now I want to send over this change to the client to synchronize the world state. However,...