Table of Contents

Class MetadataExtensions

Namespace
Savvyio
Assembly
Savvyio.Core.dll

Extension methods for the IMetadata interface.

public static class MetadataExtensions
Inheritance
Object
MetadataExtensions

Methods

GetCausationId<T>(T)

Gets the string representation of the causation identifier from the request.

public static string GetCausationId<T>(this T request)
    where T : IMetadata

Parameters

request T

The IMetadata to extend.

Returns

String

The string representation of the causation identifier from the request.

Type Parameters

T

The model that implements the IMetadata interface.

GetCorrelationId<T>(T)

Gets the string representation of the correlation identifier from the request.

public static string GetCorrelationId<T>(this T request)
    where T : IMetadata

Parameters

request T

The IMetadata to extend.

Returns

String

The string representation of the correlation identifier from the request.

Type Parameters

T

The model that implements the IMetadata interface.

GetMemberType<T>(T)

Gets the string representation of the underlying member type of request.

public static string GetMemberType<T>(this T request)
    where T : IMetadata

Parameters

request T

The IMetadata to extend.

Returns

String

The string representation of the member type from the request.

Type Parameters

T

The model that implements the IMetadata interface.

Remarks

The underlying System.Type of a model expressed as a string representation (fully qualified name of the type, including its namespace, comma delimited with the simple name of the assembly).

MergeMetadata<TSource, TDestination>(TDestination, TSource)

Copies model from the source to the destination if not already existing.

public static TDestination MergeMetadata<TSource, TDestination>(this TDestination destination, TSource source)
    where TSource : IMetadata where TDestination : IMetadata

Parameters

destination TDestination

The IMetadata to extend. Receives model from source.

source TSource

The model that will give metadata to destination.

Returns

TDestination

A reference to destination after the operation has completed.

Type Parameters

TSource

The giving type of the model that implements the IMetadata interface.

TDestination

The receiving type of the model that implements the IMetadata interface.

SaveMetadata<T>(T, String, Object)

Add or update a set of model to the request.

public static T SaveMetadata<T>(this T request, string key, object value)
    where T : IMetadata

Parameters

request T

The IMetadata to extend.

key String

The key of the element to add or update.

value Object

The value of the element to add or update.

Returns

T

A reference to request after the operation has completed.

Type Parameters

T

The model that implements the IMetadata interface.

Exceptions

System.ArgumentNullException

request cannot be null -or- key cannot be null.

SetCausationId<T>(T, String)

Assigns a new causationId to the request.

public static T SetCausationId<T>(this T request, string causationId)
    where T : IMetadata

Parameters

request T

The IMetadata to extend.

causationId String

The causation identifier of the model.

Returns

T

A reference to request after the operation has completed.

Type Parameters

T

The model that implements the IMetadata interface.

SetCorrelationId<T>(T, String)

Assigns a new correlationId to the request.

public static T SetCorrelationId<T>(this T request, string correlationId)
    where T : IMetadata

Parameters

request T

The IMetadata to extend.

correlationId String

The correlation identifier of the model.

Returns

T

A reference to request after the operation has completed.

Type Parameters

T

The model that implements the IMetadata interface.

SetEventId<T>(T, String)

Assigns a new eventId to the request.

public static T SetEventId<T>(this T request, string eventId)
    where T : IMetadata

Parameters

request T

The IMetadata to extend.

eventId String

The event identifier of the model.

Returns

T

A reference to request after the operation has completed.

Type Parameters

T

The model that implements the IMetadata interface.

SetMemberType<T>(T, Type)

Assigns a new type to the request.

public static T SetMemberType<T>(this T request, Type type)
    where T : IMetadata

Parameters

request T

The IMetadata to extend.

type Type

The type of the model.

Returns

T

A reference to request after the operation has completed.

Type Parameters

T

The model that implements the IMetadata interface.

Remarks

The type is converted to its equivalent string representation (fully qualified name of the type, including its namespace, comma delimited with the simple name of the assembly).

SetTimestamp<T>(T, Nullable<DateTime>)

Assigns a new timestamp (System.DateTime.UtcNow value) to the request.

public static T SetTimestamp<T>(this T request, DateTime? utcTimestamp = null)
    where T : IMetadata

Parameters

request T

The IMetadata to extend.

utcTimestamp Nullable<DateTime>

The optional System.DateTime value expressed as the Coordinated Universal Time (UTC).

Returns

T

A reference to request after the operation has completed.

Type Parameters

T

The model that implements the IMetadata interface.

Exceptions

ArgumentException

utcTimestamp (when set) was not expressed as the Coordinated Universal Time (UTC).