# IResourceWithCustomWithReference<TSelf>

- Kind: `interface`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.3.0`
- Namespace: `Aspire.Hosting.ApplicationModel`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/IResourceWithCustomWithReference.cs)
- Implements: [IResource](/reference/api/csharp/aspire.hosting/iresource.md)

Defines custom `WithReference` dispatch behavior for a resource type.

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public interface IResourceWithCustomWithReference<TSelf>
    : Aspire.Hosting.ApplicationModel.IResource
    where TSelf : IResource, IResourceWithCustomWithReference<TSelf>
{
    // ...
}
```

## Type Parameters

- `TSelf` -- The concrete resource type that provides the custom dispatch behavior.

## Remarks

This contract is used by the internal ATS-visible `withReference` dispatcher to route references to resource-specific logic at runtime. Implementations may customize dispatch based on either the source or destination resource type.

## Methods

- [TryWithReference(IResourceBuilder<TDestination>, IResourceBuilder<IResource>, string?, bool, string?)](/reference/api/csharp/aspire.hosting/iresourcewithcustomwithreference-1/methods.md#trywithreference-iresourcebuilder-tdestination-iresourcebuilder-iresource-string-bool-string) : `IResourceBuilder<TDestination>` `static` `abstract` -- Applies a reference from `source` to `builder` using resource-specific behavior.
