Questions tagged [memberinfo]
13 questions
3
votes
1 answer
How to get the MethodInfo of a function of a class, without string comparison
Similar to a previous question of mine, when I was asking about getting the FieldInfo of a field, How to get the FieldInfo of a field from the value, from the answers there, I compiled this helper class,
using System;
using System.Reflection;
using…

seaders
- 3,878
- 3
- 40
- 64
2
votes
0 answers
mvc getting attributes for derived model
I have 1 base model, a child model and another which is a child of the second one:
class FirstModel
{
public virtual decimal? Property1 { get; set; }
}
class SecondModel : FirstModel
{
public override decimal? Property1 { get; set;…

nickornotto
- 1,946
- 4
- 36
- 68
2
votes
1 answer
Determine if event is static using reflection
I have a System.Reflection.EventInfo object, and I want to know whether the event described by this object is static or not. Unlike System.Reflection.MethodInfo, EventInfo does not have IsStatic property that would tell me what I need. So, how can I…

user3623874
- 520
- 1
- 6
- 25
1
vote
2 answers
Reflection: FindMembers returning empty
I'm trying to list all members with a given attribute, I've implemented a method that uses FindMembers but it always return an empty collection. Can anyone tell me what I'm doing wrong?
public List GetMembers()
{
…

Matheus Simon
- 668
- 11
- 34
1
vote
0 answers
How can I get MemberInfos of a class in the order the members are declared?
Let's say I have the following class:
public class Target
{
public int field1;
public int field2;
public int Prop1 { get; set; }
public int Prop2 { get; set; }
}
If I do a:
foreach(far f in typeof(Target).GetFields())
…

vexe
- 5,433
- 12
- 52
- 81
1
vote
1 answer
How to get MemberInfo of ArrayLength type expressions?
Some trouble with UnaryExpressions.
This works this way:
Expression, object>> k = l => l.Count;
//got member in this case like this
var member = ((k.Body as UnaryExpression).Operand as MemberExpression).Member;
In the above case…

nawfal
- 70,104
- 56
- 326
- 368
0
votes
1 answer
retrieve the instance of a class from the information contained in a MemberInfo in C# WPF
After many fruitless searches I can't find the solution.
I want to do something like this Object obj = memberInfo.GetInstance();
Here is the method:
public static void DefineControl(Window currentForm, Role role)
{
…

Aiorio
- 1
- 2
0
votes
1 answer
Reflection + Linq to get all properties that has Attribute in Assembly
I'm trying to get all properties that has a custom attribute in the assembly.
I did it this way but I'm doing it with two steps that does the same validation.
Ex:
abstract class XX
class Y1 : XX {
[MyCustomAttribute(Value = "val A")]
public…

P. Waksman
- 979
- 7
- 21
0
votes
2 answers
Mailchimp: Get random member info
This is my first time using the MailChimp API, I've been looking at some examples and trying to figure out this on my own but I can't seem to be able to get what I need.
I only have one list on my account and I'm trying to run a contest where I…

pzl-kleur
- 35
- 1
- 7
0
votes
3 answers
Type.GetMember get only members from enum and not from object
I am using Type.GetMember to get enum member. And when my enum value is Equals. It returns the Equals method which is inherited from object. So how could i retrieve only the enum member and not the members from object.
Enum
enum MyEnum{
Equals,
…

Madhu
- 2,416
- 3
- 15
- 33
0
votes
2 answers
Get MemberInfo of child property from a MemberExpression
I am trying to get MemberInfo for a child property from a MemberExpression. I have found ways to get the full name of the nested type, but not a way to get the whole MemberInfo of the nested type. Here is a quick example of the scenario I am talking…

Chris Knight
- 1,448
- 1
- 15
- 21
0
votes
1 answer
What's the filterCriteria in the Type.FindMembers C#
I've been searching he internet for hours without finding a satisfying answer for this
I know it's what determines what would be included in the MemberInfo object but what exactly are the possible values to this
public class TestTypeOf
{
…

Scarnet
- 738
- 2
- 11
- 36
0
votes
1 answer
Constant in MemberInfo
I try to get information about constant in my class Car, but unfortunately in result I get only 4 field (name, currentSpeed, maxSpeed, state). How can I get field const.
Thanks.
public abstract class Car
{
protected string name;
protected…

Makeda
- 47
- 4