Class MemberReflectionOptions
- Namespace
- Cuemon.Reflection
- Assembly
- Cuemon.Core.dll
Configuration options for MemberReflection.
public class MemberReflectionOptions : IParameterObject
- Inheritance
-
MemberReflectionOptions
- Implements
Examples
The following example demonstrates how to use
using System;
using System.Linq;
using System.Reflection;
using Cuemon;
using Cuemon.Reflection;
namespace MyApp.Examples;
public static class MemberReflectionOptionsExample
{
public static void Demonstrate()
{
BindingFlags publicInstanceFlags = MemberReflection.CreateFlags(options =>
{
options.ExcludePrivate = true;
options.ExcludeStatic = true;
});
var publicDateSpanMembers = typeof(DateSpan)
.GetMembers(publicInstanceFlags)
.Select(member => member.Name)
.Distinct()
.OrderBy(name => name)
.Take(8);
Console.WriteLine(string.Join(", ", publicDateSpanMembers));
BindingFlags declaredOnlyFlags = MemberReflection.CreateFlags(options =>
{
options.ExcludePrivate = true;
options.ExcludeStatic = true;
options.ExcludeInheritancePath = true;
});
Console.WriteLine(typeof(DateSpan).GetMethods(publicInstanceFlags).Length);
Console.WriteLine(typeof(DateSpan).GetMethods(declaredOnlyFlags).Length);
var documentedOptions = new MemberReflectionOptions
{
ExcludePrivate = true,
ExcludeStatic = true,
ExcludeInheritancePath = true
};
Console.WriteLine($"{documentedOptions.ExcludePrivate}/{documentedOptions.ExcludeStatic}/{documentedOptions.ExcludeInheritancePath}/{documentedOptions.ExcludePublic}");
}
}
Constructors
MemberReflectionOptions()
Initializes a new instance of the MemberReflectionOptions class.
public MemberReflectionOptions()
Remarks
The following table shows the initial property values for an instance of MemberReflectionOptions.
| Property | Initial Value |
|---|---|
| ExcludeInheritancePath | false |
| ExcludePrivate | false |
| ExcludeStatic | false |
| ExcludePublic | false |
Properties
ExcludeInheritancePath
Gets or sets a value indicating whether derived members of a type's inheritance path are excluded from the binding constraint.
public bool ExcludeInheritancePath { get; set; }
Property Value
- bool
trueif derived members of a type's inheritance path are excluded from the binding constraint; otherwise,false.
ExcludePrivate
Gets or sets a value indicating whether non-public members are excluded from the binding constraint.
public bool ExcludePrivate { get; set; }
Property Value
- bool
trueif non-public members are excluded from the binding constraint; otherwise,false.
ExcludePublic
Gets or sets a value indicating whether public members are excluded from the binding constraint.
public bool ExcludePublic { get; set; }
Property Value
- bool
trueif public members are excluded from the binding constraint; otherwise,false.
ExcludeStatic
Gets or sets a value indicating whether static members are excluded from the binding constraint.
public bool ExcludeStatic { get; set; }
Property Value
- bool
trueif static members are excluded from the binding constraint; otherwise,false.