Class MemberArgument
- Namespace
- Cuemon.Reflection
- Assembly
- Cuemon.Core.dll
Represent the argument given to a member in the context of reflection.
public class MemberArgument
- Inheritance
-
MemberArgument
Examples
The following example demonstrates how to create and use MemberArgument instances to represent method parameters and their values, with priority support for ordering.
using System;
using Cuemon.Reflection;
namespace MyApp.Reflection
{
public static class MemberArgumentExamples
{
public static void Demonstrate()
{
// Create a MemberArgument to represent a method parameter and its value.
var arg = new MemberArgument("id", 42);
Console.WriteLine("Name: {0}", arg.Name); // id
Console.WriteLine("Value: {0}", arg.Value); // 42
Console.WriteLine("Priority: {0}", arg.Priority); // 0
// Create arguments for use with MemberParser rehydration.
var args = new[]
{
new MemberArgument("name", "Widget"),
new MemberArgument("price", 19.99m),
new MemberArgument("quantity", 100)
};
// Priority can control the order of processing.
args[0].Priority = 2;
args[1].Priority = 1;
args[2].Priority = 0;
foreach (var a in args)
{
Console.WriteLine("{0} = {1} (priority {2})", a.Name, a.Value, a.Priority);
// Update a value after creation.
var updatable = new MemberArgument("status", "pending");
updatable.Value = "shipped";
updatable.Priority = 5;
Console.WriteLine("Updated: {0}", updatable); // [status, shipped, 5]
}}}
}
Constructors
MemberArgument(string, object, int)
Initializes a new instance of the MemberArgument class.
public MemberArgument(string name, object value, int priority = 0)
Parameters
namestringThe name of the parameter.
valueobjectThe argument value.
priorityintThe priority of this member when performing filtering and/or ordering.
Exceptions
- ArgumentNullException
namecannot be null.
Properties
Name
Gets the name of a parameter.
public string Name { get; }
Property Value
- string
The name of a parameter.
Priority
Gets or sets the priority of this member when performing filtering and/or ordering.
public int Priority { get; set; }
Property Value
- int
The priority of this member when performing filtering and/or ordering.
Value
Gets or sets the value of the argument.
public object Value { get; set; }
Property Value
- object
The value of the argument.
Methods
ToString()
Returns a string that represents this instance.
public override string ToString()