#### [Abblix\.Utils](https://www.abblix.com/en/docs/api/abblix-utils 'index')
### [Abblix\.Utils](https://www.abblix.com/en/docs/api/abblix-utils/Abblix.Utils 'Abblix\.Utils')

## ObjectExtensions Class

Provides extension methods for objects to ensure non\-null values\.

```csharp
public static class ObjectExtensions
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → ObjectExtensions
### Methods

## ObjectExtensions\.NotNull\<T\>\(this Nullable\<T\>, string\) Method {#Abblix.Utils.ObjectExtensions.NotNull_T_(thisSystem.Nullable_T_,string)}

Ensures that the specified nullable value type is not null\.
Throws an InvalidOperationException if it is null\.

```csharp
public static T NotNull<T>(this System.Nullable<T> value, string valueName)
    where T : struct;
```
#### Type parameters

###### `T` {#Abblix.Utils.ObjectExtensions.NotNull_T_(thisSystem.Nullable_T_,string).T}

The type of the nullable value type\.
#### Parameters

###### `value` [System\.Nullable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1')[T](https://www.abblix.com/en/docs/api/abblix-utils/Abblix.Utils.ObjectExtensions#Abblix.Utils.ObjectExtensions.NotNull_T_(thisSystem.Nullable_T_,string).T 'Abblix\.Utils\.ObjectExtensions\.NotNull\<T\>\(this System\.Nullable\<T\>, string\)\.T')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1') {#Abblix.Utils.ObjectExtensions.NotNull_T_(thisSystem.Nullable_T_,string).value}

The nullable value type to check for null\.

###### `valueName` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Utils.ObjectExtensions.NotNull_T_(thisSystem.Nullable_T_,string).valueName}

The name of the nullable value type, which will be used in the exception message if the value is null\.

#### Returns
[T](https://www.abblix.com/en/docs/api/abblix-utils/Abblix.Utils.ObjectExtensions#Abblix.Utils.ObjectExtensions.NotNull_T_(thisSystem.Nullable_T_,string).T 'Abblix\.Utils\.ObjectExtensions\.NotNull\<T\>\(this System\.Nullable\<T\>, string\)\.T')  
The original non\-null value of type T\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown when the input value is null\.

## ObjectExtensions\.NotNull\<T\>\(this T, string\) Method {#Abblix.Utils.ObjectExtensions.NotNull_T_(thisT,string)}

Ensures that the specified nullable reference type is not null\.
Throws an InvalidOperationException if it is null\.

```csharp
public static T NotNull<T>(this T? value, string valueName)
    where T : class;
```
#### Type parameters

###### `T` {#Abblix.Utils.ObjectExtensions.NotNull_T_(thisT,string).T}

The type of the nullable reference type\.
#### Parameters

###### `value` [T](https://www.abblix.com/en/docs/api/abblix-utils/Abblix.Utils.ObjectExtensions#Abblix.Utils.ObjectExtensions.NotNull_T_(thisT,string).T 'Abblix\.Utils\.ObjectExtensions\.NotNull\<T\>\(this T, string\)\.T') {#Abblix.Utils.ObjectExtensions.NotNull_T_(thisT,string).value}

The nullable reference type to check for null\.

###### `valueName` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Utils.ObjectExtensions.NotNull_T_(thisT,string).valueName}

The name of the nullable reference type, which will be used in the exception message if the value is null\.

#### Returns
[T](https://www.abblix.com/en/docs/api/abblix-utils/Abblix.Utils.ObjectExtensions#Abblix.Utils.ObjectExtensions.NotNull_T_(thisT,string).T 'Abblix\.Utils\.ObjectExtensions\.NotNull\<T\>\(this T, string\)\.T')  
The original non\-null value of type T\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown when the input value is null\.

## ObjectExtensions\.ToAsync\<T\>\(this T\) Method {#Abblix.Utils.ObjectExtensions.ToAsync_T_(thisT)}

Wraps a single value as an [System\.Collections\.Generic\.IAsyncEnumerable&lt;&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1 'System\.Collections\.Generic\.IAsyncEnumerable\`1') that yields exactly
one element\. Useful for adapting non\-streaming sources to APIs that consume an
async sequence \- for example handing a single signing key to a verifier that
expects a candidate\-key stream\.

```csharp
public static System.Collections.Generic.IAsyncEnumerable<T> ToAsync<T>(this T value);
```
#### Type parameters

###### `T` {#Abblix.Utils.ObjectExtensions.ToAsync_T_(thisT).T}

The type of the value to wrap\.
#### Parameters

###### `value` [T](https://www.abblix.com/en/docs/api/abblix-utils/Abblix.Utils.ObjectExtensions#Abblix.Utils.ObjectExtensions.ToAsync_T_(thisT).T 'Abblix\.Utils\.ObjectExtensions\.ToAsync\<T\>\(this T\)\.T') {#Abblix.Utils.ObjectExtensions.ToAsync_T_(thisT).value}

The value to yield\.

#### Returns
[System\.Collections\.Generic\.IAsyncEnumerable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1 'System\.Collections\.Generic\.IAsyncEnumerable\`1')[T](https://www.abblix.com/en/docs/api/abblix-utils/Abblix.Utils.ObjectExtensions#Abblix.Utils.ObjectExtensions.ToAsync_T_(thisT).T 'Abblix\.Utils\.ObjectExtensions\.ToAsync\<T\>\(this T\)\.T')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1 'System\.Collections\.Generic\.IAsyncEnumerable\`1')  
An [System\.Collections\.Generic\.IAsyncEnumerable&lt;&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1 'System\.Collections\.Generic\.IAsyncEnumerable\`1') producing [value](https://www.abblix.com/en/docs/api/abblix-utils/Abblix.Utils.ObjectExtensions#Abblix.Utils.ObjectExtensions.ToAsync_T_(thisT).value 'Abblix\.Utils\.ObjectExtensions\.ToAsync\<T\>\(this T\)\.value')
            once and then completing\.
