Class TypedMemberMap<T>
A class that contains the members of a certain type.
Inheritance
Inherited Members
Namespace: SpiceSharp.Reflection
Assembly: SpiceSharp.dll
Syntax
public class TypedMemberMap<T> : IParameterImporter<T>, IPropertyExporter<T>, IMemberMap
Type Parameters
| Name | Description |
|---|---|
| T | The base type. |
Constructors
TypedMemberMap(IEqualityComparer<String>)
Initializes a new instance of the TypedMemberMap<T> class.
Declaration
public TypedMemberMap(IEqualityComparer<string> comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEqualityComparer<System.String> | comparer | The comparer. |
Properties
Comparer
Gets the comparer used to compare member names.
Declaration
public IEqualityComparer<string> Comparer { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEqualityComparer<System.String> | The comparer. |
Members
Gets the members.
Declaration
public IEnumerable<MemberDescription> Members { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<MemberDescription> | The members. |
Methods
Add(MemberDescription)
Adds a member description to the map.
Declaration
public void Add(MemberDescription member)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberDescription | member | The member to add. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown if a member with the same name is already defined. |
CreateGetter(Object, String)
Creates a getter for parameter with the specified name.
Declaration
public Func<T> CreateGetter(object source, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | source | The source object. |
| System.String | name | The name of the parameter. |
Returns
| Type | Description |
|---|---|
| System.Func<T> | The function that returns the parameter; or |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
CreateSetter(Object, String)
Creates a setter for the parameter with the specified name.
Declaration
public Action<T> CreateSetter(object source, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | source | The source object. |
| System.String | name | The name of the parameter. |
Returns
| Type | Description |
|---|---|
| System.Action<T> | The action that sets the parameter; or |
TryGet(Object, String, out Boolean)
Tries getting the value of a parameter.
Declaration
public T TryGet(object source, string name, out bool isValid)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | source | The source object. |
| System.String | name | The name. |
| System.Boolean | isValid | If set to |
Returns
| Type | Description |
|---|---|
| T | The parameter value. |
Remarks
This method does not follow the regular TryGet convention due to the interface being covariant.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
TrySet(Object, String, T)
Tries setting a parameter value.
Declaration
public bool TrySet(object source, string name, T value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | source | The source object. |
| System.String | name | The parameter name. |
| T | value | The parameter value. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
| System.ArgumentException | Thrown if the value is invalid for the parameter. |