Table of Contents

Class NamedArgs

Namespace
StreamJsonRpc
Assembly
StreamJsonRpc.dll

Serves as a wrapper for a named arguments object, allowing access to its properties and fields by name.

public class NamedArgs : IReadOnlyDictionary<string, object?>, IReadOnlyCollection<KeyValuePair<string, object?>>, IEnumerable<KeyValuePair<string, object?>>, IEnumerable
Inheritance
NamedArgs
Implements
Inherited Members
Extension Methods

Remarks

This type implements IReadOnlyDictionary<TKey, TValue> to allow access to the named arguments by their names. It also exposes the declared types of the named arguments via its DeclaredArgumentTypes property, which can be useful for serialization.

Properties

DeclaredArgumentTypes

Gets the declared types of the named arguments.

public IReadOnlyDictionary<string, Type> DeclaredArgumentTypes { get; }

Property Value

IReadOnlyDictionary<string, Type>

Methods

Create(Type, object?)

Creates a NamedArgs instance for the specified named arguments object.

public static NamedArgs? Create(Type objectType, object? namedArgsObject)

Parameters

objectType Type

The type of the namedArgsObject. Must not be object. This is the type whose properties and fields will be used as named arguments. If DataContractAttribute is applied to this type, properties and fields will be included only if DataMemberAttribute is applied to them, and may include non-public members. If DataContractAttribute is not applied, only public properties and fields will be included, and any IgnoreDataMemberAttribute annotated members will be excluded.

namedArgsObject object

The object whose properties or fields name the arguments to pass to the RPC method.

Returns

NamedArgs

An optimized NamedArgs object, or null if namedArgsObject was null.

Exceptions

ArgumentException

Thrown if namedArgsObject is not assignable to objectType, or objectType is object.

Create<T>(T?)

Creates a new instance of the NamedArgs class from the specified object.

public static NamedArgs? Create<T>(T? namedArgsObject)

Parameters

namedArgsObject T
The object whose properties or fields name the arguments to pass to the RPC method.

Returns

NamedArgs

An optimized NamedArgs object, or null if namedArgsObject was null.

Type Parameters

T
The type of the namedArgsObject. Must not be object. This is the type whose properties and fields will be used as named arguments. If DataContractAttribute is applied to this type, properties and fields will be included only if DataMemberAttribute is applied to them, and may include non-public members. If DataContractAttribute is not applied, only public properties and fields will be included, and any IgnoreDataMemberAttribute annotated members will be excluded.