> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# EmbeddedResourceWriter

> Renders text files embedded in an assembly, replacing `{{Token}}` placeholders, and writes them to disk.

## Definition

**Assembly:** CloudNimble.EasyAF.Tools.dll

**Namespace:** CloudNimble.EasyAF.Tools.Scaffolding

**Inheritance:** System.Object

## Syntax

```csharp theme={"dark"}
CloudNimble.EasyAF.Tools.Scaffolding.EmbeddedResourceWriter
```

## Summary

Renders text files embedded in an assembly, replacing `{{Token}}` placeholders, and writes them to disk.

## Remarks

Resources are expected to use path-preserving logical names (for example `Resources/Api/Program.cs`) so that
folder names containing dots are not confused with nested folders. Tokens are replaced in a single pass, so a token
value that itself looks like a token is written literally. A placeholder with no matching token is an error rather
than something to ship. Line endings are normalized to [NewLine](https://learn.microsoft.com/dotnet/api/system.environment.newline).

## Constructors

### &#x20;.ctor

Initializes a new instance of the [EmbeddedResourceWriter](https://easyaf.dev/api-reference/CloudNimble/EasyAF/Tools/Scaffolding/EmbeddedResourceWriter.md) class that reads the EasyAF Tools
assembly's `Resources/` folder.

#### Syntax

```csharp theme={"dark"}
public EmbeddedResourceWriter(System.Collections.Generic.IReadOnlyDictionary<string, string> tokens)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `tokens` | `System.Collections.Generic.IReadOnlyDictionary<string, string>` | The tokens that replace `{{Name}}` placeholders. |

### &#x20;.ctor

Initializes a new instance of the [EmbeddedResourceWriter](https://easyaf.dev/api-reference/CloudNimble/EasyAF/Tools/Scaffolding/EmbeddedResourceWriter.md) class.

#### Syntax

```csharp theme={"dark"}
public EmbeddedResourceWriter(System.Collections.Generic.IReadOnlyDictionary<string, string> tokens, System.Reflection.Assembly assembly, string rootFolder)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `tokens` | `System.Collections.Generic.IReadOnlyDictionary<string, string>` | The tokens that replace `{{Name}}` placeholders. |
| `assembly` | `System.Reflection.Assembly` | The assembly the resources are embedded in. |
| `rootFolder` | `string` | The logical folder resource names are relative to. |

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public Object()
```

## Properties

### &#x20;Assembly

Gets the assembly the resources are read from.

#### Syntax

```csharp theme={"dark"}
public System.Reflection.Assembly Assembly { get; }
```

#### Property Value

Type: `System.Reflection.Assembly`

### &#x20;ResourceNames

Gets the names of the available resources, relative to [EmbeddedResourceWriter.RootFolder](https://easyaf.dev/api-reference/CloudNimble/EasyAF/Tools/Scaffolding/EmbeddedResourceWriter.md#rootfolder), with forward slashes, sorted.

#### Syntax

```csharp theme={"dark"}
public System.Collections.Generic.IReadOnlyList<string> ResourceNames { get; }
```

#### Property Value

Type: `System.Collections.Generic.IReadOnlyList<string>`

### &#x20;RootFolder

Gets the logical folder that resource names are relative to (for example `Resources`).

#### Syntax

```csharp theme={"dark"}
public string RootFolder { get; }
```

#### Property Value

Type: `string`

### &#x20;Tokens

Gets the tokens that replace `{{Name}}` placeholders.

#### Syntax

```csharp theme={"dark"}
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tokens { get; }
```

#### Property Value

Type: `System.Collections.Generic.IReadOnlyDictionary<string, string>`

## Methods

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual bool Equals(object obj)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `obj` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Render

Renders a resource with its tokens replaced.

#### Syntax

```csharp theme={"dark"}
public string Render(string resourceName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `resourceName` | `string` | The resource name relative to [EmbeddedResourceWriter.RootFolder](https://easyaf.dev/api-reference/CloudNimble/EasyAF/Tools/Scaffolding/EmbeddedResourceWriter.md#rootfolder), for example `Api/Program.cs`. |

#### Returns

Type: `string`
The rendered text.

#### Exceptions

| Exception | Description |
| - | - |
| `FileNotFoundException` | Thrown when no resource with that name exists. |
| `InvalidOperationException` | Thrown when the resource contains a placeholder with no matching token. |

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual string ToString()
```

#### Returns

Type: `string?`

### &#x20;WriteAsync

Renders a resource and writes it to disk as UTF-8 without a byte order mark, creating parent directories and
replacing any existing file.

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.Task<string> WriteAsync(string resourceName, string destinationPath, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `resourceName` | `string` | The resource name relative to [EmbeddedResourceWriter.RootFolder](https://easyaf.dev/api-reference/CloudNimble/EasyAF/Tools/Scaffolding/EmbeddedResourceWriter.md#rootfolder). |
| `destinationPath` | `string` | The file to write. |
| `cancellationToken` | `System.Threading.CancellationToken` | A token to cancel the operation. |

#### Returns

Type: `System.Threading.Tasks.Task<string>`
The full path of the written file.

#### Exceptions

| Exception | Description |
| - | - |
| `FileNotFoundException` | Thrown when no resource with that name exists. |
| `InvalidOperationException` | Thrown when the resource contains a placeholder with no matching token. Nothing is written. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.