Class TypeNameOptions
- Namespace
- Cuemon.Reflection
- Assembly
- Cuemon.Core.dll
Configuration options for ToFriendlyName(IDecorator<Type>, Action<TypeNameOptions>).
public sealed class TypeNameOptions : FormattingOptions, IValidatableParameterObject, IParameterObject
- Inheritance
-
TypeNameOptions
- Implements
- Inherited Members
Examples
The following example demonstrates how to use TypeNameOptions to control the friendly name output of a Type.
using System;
using Cuemon;
using Cuemon.Reflection;
namespace Examples;
public class TypeNameFormattingExample
{
public void Demonstrate()
{
// Direct instantiation of TypeNameOptions
var options = new TypeNameOptions
{
FullName = true,
ExcludeGenericArguments = false
};
Type type = typeof(Console);
string friendlyName = Decorator.Enclose(type).ToFriendlyName(o =>
{
o.FullName = true;
o.ExcludeGenericArguments = false;
});
// friendlyName == "System.Console"
friendlyName = Decorator.Enclose(type).ToFriendlyName(o =>
{
o.FullName = false;
});
// friendlyName == "Console"
}
}
Constructors
TypeNameOptions()
Initializes a new instance of the TypeNameOptions class.
public TypeNameOptions()
Remarks
The following table shows the initial property values for an instance of TypeNameOptions.
| Property | Initial Value |
|---|---|
| ExcludeGenericArguments | false |
| FullName | false |
| FormatProvider | InvariantCulture |
| FriendlyNameStringConverter | |
Properties
ExcludeGenericArguments
Gets or sets a value indicating whether to exclude generic arguments from a Type.
public bool ExcludeGenericArguments { get; set; }
Property Value
FriendlyNameStringConverter
Gets or sets the function delegate that convert a Type object into a human-readable string.
public Func<Type, IFormatProvider, bool, string> FriendlyNameStringConverter { get; set; }
Property Value
- Func<Type, IFormatProvider, bool, string>
The function delegate that convert a Type object into a human-readable string.
Exceptions
- ArgumentNullException
valuecannot be null.
FullName
Gets or sets a value indicating whether to use the fully qualified name of a Type.
public bool FullName { get; set; }
Property Value
Methods
ValidateOptions()
Determines whether the public read-write properties of this instance are in a valid state.
public override void ValidateOptions()
Remarks
This method is expected to throw exceptions when one or more conditions fails to be in a valid state.