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

# MessageBase

> Base class providing a complete implementation of common message functionality.

## Definition

**Assembly:** CloudNimble.SimpleMessageBus.Core.dll

**Namespace:** CloudNimble.SimpleMessageBus.Core

**Inheritance:** System.Object

## Syntax

```csharp theme={"dark"}
CloudNimble.SimpleMessageBus.Core.MessageBase
```

## Summary

Base class providing a complete implementation of common message functionality.

## Remarks

MessageBase provides a convenient base class that implements all core message interfaces, making it easy
to create new message types without having to implement the common functionality manually. It automatically
handles ID generation, metadata initialization, tracking properties, and provides constructors for creating
child messages with proper lineage tracking.

This class is abstract and must be inherited to create concrete message types. It's recommended to use this
base class for most message implementations unless you have specific requirements that prevent inheritance.

## Examples

```csharp theme={"dark"}
// Simple message inheriting from MessageBase
public class OrderCreatedMessage : MessageBase
{
    public string OrderNumber { get; set; }
    public decimal TotalAmount { get; set; }
    public DateTime CreatedAt { get; set; }
}

// Creating a root message
var orderMessage = new OrderCreatedMessage
{
    OrderNumber = "ORD-001",
    TotalAmount = 99.99m,
    CreatedAt = DateTime.UtcNow
};

// Creating a child message with proper lineage
public class PaymentProcessedMessage : MessageBase
{
    public decimal Amount { get; set; }
    public string PaymentMethod { get; set; }

    public PaymentProcessedMessage(IMessage parent) : base(parent)
    {
        // Child-specific initialization
    }
}

var paymentMessage = new PaymentProcessedMessage(orderMessage)
{
    Amount = 99.99m,
    PaymentMethod = "CreditCard"
};
// paymentMessage.ParentId == orderMessage.Id
// paymentMessage.CorrelationId == orderMessage.CorrelationId
```

## Constructors

### <Icon icon="hammer" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> .ctor <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

## Properties

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> CorrelationId

#### Syntax

```csharp theme={"dark"}
public System.Guid CorrelationId { get; set; }
```

#### Property Value

Type: `System.Guid`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Id

#### Syntax

```csharp theme={"dark"}
public System.Guid Id { get; set; }
```

#### Property Value

Type: `System.Guid`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Metadata

#### Syntax

```csharp theme={"dark"}
public System.Collections.Concurrent.ConcurrentDictionary<string, object> Metadata { get; set; }
```

#### Property Value

Type: `System.Collections.Concurrent.ConcurrentDictionary<string, object>`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> ParentId

#### Syntax

```csharp theme={"dark"}
public System.Nullable<System.Guid> ParentId { get; set; }
```

#### Property Value

Type: `System.Nullable<System.Guid>`

## Methods

### <Icon icon="code-fork" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Equals <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### <Icon icon="thumbtack" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Equals <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### <Icon icon="code-fork" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> GetHashCode <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `int`

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> GetType <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `System.Type`

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> MemberwiseClone <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `object`

### <Icon icon="thumbtack" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> ReferenceEquals <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### <Icon icon="code-fork" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> ToString <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `string?`

## Related APIs

* CloudNimble.SimpleMessageBus.Core.IMessage
* CloudNimble.SimpleMessageBus.Core.IMetadataAware
* CloudNimble.SimpleMessageBus.Core.ITrackable
