I'm digging into Reflection for the first time and I'm truely stuck. I've googled everything I can think of. I'm 90% where I wanna be now.
I'm trying to return the value of a Property in a custom class through Reflection.
Here's my class declaration:
Public Class Class2
Private newPropertyValue2 As String
Public Property NewP...
Hi,
I do some type analysis in runtime using Reflection. If I have a MethodInfo instance,
how can I figure out if this is a "real" method or is a getter/setter method of a property? And if it is a property, how can I find the its hosting PropertyInfo back?
...
I am stepping though some code and looking at a PropertyInfo object and want to know how to get its base.Name
I can see this in the debugger but I am not sure how to do this as there is no "base" property on a PropertyInfo
...
I'm customizing how an object type is displayed in a PropertyGrid by implementing ICustomTypeDescriptor. I'm allowing the user to create their own custom properties that are stored in a single dictionary of keys and values. I'm able to create all the PropertyDescriptors for these values and view them in the property grid. However, I also...
refers to : http://stackoverflow.com/questions/906327/reflection-setting-type-of-returned-obj
I have a object Call Jobcard with a few properties, one of which is another object called Customer with its own properties, one of which is another nested object called Adress.
These 2 functions will be handling other object types as well.
pr...
I have a linq Context that I am looking at all the data Tables, I am trying to get the list of fields in all tables
foreach (var code in ctx.GetType().GetProperties())
{
Console.WriteLine(code.PropertyType + " - " + code.Name + " ");
if (code.PropertyType.ToString().Contains("System.Data.Linq.Tab...
I have a class Bar like this:
class Foo : IFoo {
[Range(0,255)]
public int? FooProp {get; set}
}
class Bar : IFoo
{
private Foo foo = new Foo();
public int? FooProp { get { return foo.FooProp; }
set { foo.FooProp= value; } }
}
I need to find the attribute [Range(0,255)] reflecting ONLY on the property ...
Hi
I am trying to get the ID field name (property name) of an entity, is it possible?
User user= new User(); //User is an Entity
string idField = ??????? //user.UserId
...
Hi, I'd like to set a property of an object through reflection, with a value of type string.
So, for instance, suppose I have a Ship class, with a property of Latitude, which is a double.
Here's what I'd like to do:
Ship ship = new Ship();
string value = "5.5";
PropertyInfo propertyInfo = ship.GetType().GetProperty("Latitude");
propert...
I have the following code;
public class DataReader<T> where T : class
{
public T getEntityFromReader(IDataReader reader, IDictionary<string, string> FieldMappings)
{
T entity = Activator.CreateInstance<T>();
Type entityType = entity.GetType();
PropertyInfo[] pi = entityType.Get...
When I use PropertyInfo.SetValue in asp.net , it throws a stackoverflow exception.
That I write this code:
for (int i = 0; i < rivalSeriesIDList.Count; i++)
{
cardb_series rivalSeries = seriesBll.GetSeriesInfoByID(rivalSeriesIDList[i].ToString());
this.GetType().GetProperty("brandid" + (i + 1)).SetValue(this, riv...
I need to know if the type of a property in a class is a generic collection (List, ObservableCollection) using the PropertyInfo class.
enter code here
foreach (PropertyInfo p in (o.GetType()).GetProperties())
{
if(p is Collection<T> ????? )
}
...
Can anyone help me.
I have an application it contain many aspx pages. here i am collecting all controls id's(ex:label1,texbox1,grid1.....etc ) from all page in the application
till its working fine....
now i want to collect text property of that contros(ex: label1 have text property StudentId ...etc) how i can do it....
here i have cod...
Let me explain. I have a List into which I am adding various ASP.NET controls.
I then wish to loop through the list and set a CssClass, however not every Control supports the property CssClass.
What I would like to do is test if the underlying instance type supports the CssClass property and set it, but I'm not sure how to do the conver...
Give a class like below, how can i find the name of one particluar property?
public class Student
{
public int Grade
{
get;
set;
}
public string TheNameOfTheGradeProperty
{
get
{
return ????
}
}
// More properties..
}
So i would like to return the st...
Some code:
foreach (System.Reflection.PropertyInfo pi in myObject.GetType().GetProperties())
{
if (pi.CanWrite)
{
object value = pi.GetValue(Properties, null);
// if (value is not default)
// {
X.addAttribute(pi.Name, value);
...
I have some code that is using reflection to pull property values from an object. In some cases the properties may throw exceptions, because they have null references etc.
object result;
try
{
result = propertyInfo.GetValue(target, null);
...
I have a function with this code:
foreach (PropertyInfo propertyInfo in typeof(T).GetProperties()){
//SOME CODE
if (propertyInfo.CanWrite)
propertyInfo.SetValue(myCopy, propertyInfo.GetValue(obj, null), null);
}
I would avoid to check "collection" properties; to do this now I have insert this control:
if (propertyInfo.PropertyTy...
I'm trying to use PropertyInfo interate through a class and create a datatable from it. However it returns no values. I'm a little stumped;
public class thetransactions
{
public string FirstName;
public string Surname;
public string PreviousOwner;
public string NewOwner;
public string postcode;
public string[] ...
I have problem with reflection, dynamic invoking objects and reading collection values.
In Referenced COM/Interop it would look like this:
ICollection collection = (ICollection)sth.getCollection("parameter");
SomeObject obj = (SomeObject)collection["id='1'"]; //DB WHERE condition
Unfortunetly i need to make it with reflection and dyna...