DistributedApplicationBuilderExtensions.TryCreateResourceBuilder<T> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Attempts to create a new resource builder based on the name of an existing resource.
public static bool TryCreateResourceBuilder<T>(this Aspire.Hosting.IDistributedApplicationBuilder builder, string name, out Aspire.Hosting.ApplicationModel.IResourceBuilder<T>? resourceBuilder) where T : Aspire.Hosting.ApplicationModel.IResource;
static member TryCreateResourceBuilder : Aspire.Hosting.IDistributedApplicationBuilder * string * IResourceBuilder -> bool (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)
<Extension()>
Public Function TryCreateResourceBuilder(Of T As IResource) (builder As IDistributedApplicationBuilder, name As String, ByRef resourceBuilder As IResourceBuilder(Of T)) As Boolean
Type Parameters
- T
Type of resource.
Parameters
- builder
- IDistributedApplicationBuilder
The distributed application builder.
- name
- String
The name of an existing resource.
- resourceBuilder
- IResourceBuilder<T>
When this method returns, contains the resource builder if the resource was found and is of the correct type; otherwise, null.
Returns
true if the resource was found and is of the correct type; otherwise, false.
Remarks
This method is similar to CreateResourceBuilder<T>(IDistributedApplicationBuilder, String) but returns false instead of throwing an exception when the resource is not found or is not of the correct type.