13 interfaces inheriting from IResource
Aspire.Hosting (10)
Aspire.Hosting.Azure (3)
8 implementations of IResource
Aspire.Hosting (1)
Aspire.Hosting.Azure.CosmosDB (1)
Aspire.Hosting.Azure.EventHubs (1)
Aspire.Hosting.Azure.ServiceBus (1)
Aspire.Hosting.Azure.SignalR (1)
Aspire.Hosting.Azure.Storage (1)
Aspire.Hosting.Tests (2)
493 references to IResource
Aspire.Hosting (262)
ApplicationModel\ResourceExtensions.cs (28)
11/// Provides extension methods for the <see cref="IResource"/> interface.
22public static bool TryGetLastAnnotation<T>(this IResource resource, [NotNullWhen(true)] out T? annotation) where T : IResourceAnnotation
43public static bool TryGetAnnotationsOfType<T>(this IResource resource, [NotNullWhen(true)] out IEnumerable<T>? result) where T : IResourceAnnotation
65public static bool HasAnnotationOfType<T>(this IResource resource) where T : IResourceAnnotation
77public static bool TryGetAnnotationsIncludingAncestorsOfType<T>(this IResource resource, [NotNullWhen(true)] out IEnumerable<T>? result) where T : IResourceAnnotation
114public static bool HasAnnotationIncludingAncestorsOfType<T>(this IResource resource) where T : IResourceAnnotation
147public static bool TryGetEnvironmentVariables(this IResource resource, [NotNullWhen(true)] out IEnumerable<EnvironmentCallbackAnnotation>? environmentVariables)
274this IResource resource,
304(DistributedApplicationOperation.Run, IResourceBuilder<IResource> rb) when rb.Resource is IValueProvider provider => await GetValue(key: null, provider, logger, resource.IsContainer(), containerHostName, cancellationToken).ConfigureAwait(false),
306(DistributedApplicationOperation.Publish, IResourceBuilder<IResource> rb) when rb.Resource is IManifestExpressionProvider provider => new(provider.ValueExpression, false),
335this IResource resource,
363(DistributedApplicationOperation.Run, IResourceBuilder<IResource> rb) when rb.Resource is IValueProvider provider => await GetValue(key, provider, logger, resource.IsContainer(), containerHostName, cancellationToken).ConfigureAwait(false),
365(DistributedApplicationOperation.Publish, IResourceBuilder<IResource> rb) when rb.Resource is IManifestExpressionProvider provider => new(provider.ValueExpression, false),
384this IResource resource,
435if (valueProvider is IResource resource)
472public static bool TryGetContainerMounts(this IResource resource, [NotNullWhen(true)] out IEnumerable<ContainerMountAnnotation>? volumeMounts)
483public static bool TryGetEndpoints(this IResource resource, [NotNullWhen(true)] out IEnumerable<EndpointAnnotation>? endpoints)
494public static bool TryGetUrls(this IResource resource, [NotNullWhen(true)] out IEnumerable<ResourceUrlAnnotation>? urls)
503/// <returns>An enumeration of <see cref="EndpointReference"/> based on the <see cref="EndpointAnnotation"/> annotations from the resources' <see cref="IResource.Annotations"/> collection.</returns>
532public static bool TryGetContainerImageName(this IResource resource, [NotNullWhen(true)] out string? imageName)
562public static int GetReplicaCount(this IResource resource)
579public static DeploymentTargetAnnotation? GetDeploymentTargetAnnotation(this IResource resource, IComputeEnvironmentResource? targetComputeEnvironment = null)
625internal static ContainerLifetime GetContainerLifetimeType(this IResource resource)
641internal static bool TryGetContainerImagePullPolicy(this IResource resource, [NotNullWhen(true)] out ImagePullPolicy? pullPolicy)
659internal static bool SupportsProxy(this IResource resource)
669internal static IResource GetRootResource(this IResource resource) =>
681internal static string[] GetResolvedResourceNames(this IResource resource)
ApplicationModel\ResourceNotificationService.cs (14)
23private readonly ConcurrentDictionary<(IResource, string), ResourceNotificationState> _resourceNotificationStates = new();
142private async Task WaitUntilHealthyAsync(IResource resource, IResource dependency, WaitBehavior waitBehavior, CancellationToken cancellationToken)
303private async Task WaitUntilCompletionAsync(IResource resource, IResource dependency, int exitCode, CancellationToken cancellationToken)
365public async Task WaitForDependenciesAsync(IResource resource, CancellationToken cancellationToken)
453var versionsSeen = new Dictionary<(IResource, string), long>();
500public Task PublishUpdateAsync(IResource resource, string resourceId, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
586private CustomResourceSnapshot UpdateCommands(IResource resource, CustomResourceSnapshot previousState)
662public async Task PublishUpdateAsync(IResource resource, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
671private static CustomResourceSnapshot GetCurrentSnapshot(IResource resource, ResourceNotificationState notificationState)
699private ResourceNotificationState GetResourceNotificationState(IResource resource, string resourceId) =>
742public class ResourceEvent(IResource resource, string resourceId, CustomResourceSnapshot snapshot)
747public IResource Resource { get; } = resource;
Dcp\DcpExecutor.cs (16)
347_resourceState.ApplicationModel.TryGetValue(resourceName, out var appModelResource))
411private static string GetResourceType<T>(T resource, IResource appModelResource) where T : CustomResource
580_resourceState.ApplicationModel.TryGetValue(appModelResourceName, out var appModelResource))
917private void EnsureRequiredAnnotations(IResource resource)
925private static void SetInitialResourceState(IResource resource, IAnnotationHolder annotationHolder)
941async Task CreateResourceExecutablesAsyncCore(IResource resource, IEnumerable<AppResource> executables, CancellationToken cancellationToken)
1107foreach (var container in modelContainerResources)
1163private static DcpInstance GetDcpInstance(IResource resource, int instanceIndex)
1246var modelContainerResource = cr.ModelResource;
1287private static async Task ApplyBuildArgumentsAsync(Container dcpContainerResource, IResource modelContainerResource, CancellationToken cancellationToken)
1365private void AddServicesProducedInfo(IResource modelResource, IAnnotationHolder dcpResource, AppResource appResource)
1638private async Task<(List<(string Value, bool IsSensitive)>, bool)> BuildArgsAsync(ILogger resourceLogger, IResource modelResource, CancellationToken cancellationToken)
1666private async Task<List<ContainerCreateFileSystem>> BuildCreateFilesAsync(IResource modelResource, CancellationToken cancellationToken)
1696private async Task<(List<EnvVar>, bool)> BuildEnvVarsAsync(ILogger resourceLogger, IResource modelResource, CancellationToken cancellationToken)
1723private async Task<(List<string>, bool)> BuildRunArgsAsync(ILogger resourceLogger, IResource modelResource, CancellationToken cancellationToken)
1783private static List<VolumeMount> BuildContainerMounts(IResource container)
Dcp\DcpExecutorEvents.cs (3)
11internal record OnResourceStartingContext(CancellationToken CancellationToken, string ResourceType, IResource Resource, string? DcpResourceName);
13internal record OnResourceChangedContext(CancellationToken CancellationToken, string ResourceType, IResource Resource, string DcpResourceName, ResourceStatus Status, Func<CustomResourceSnapshot, CustomResourceSnapshot> UpdateSnapshot);
14internal record OnResourceFailedToStartContext(CancellationToken CancellationToken, string ResourceType, IResource Resource, string? DcpResourceName);
Orchestrator\ApplicationOrchestrator.cs (13)
20private readonly ILookup<IResource, IResource> _parentChildLookup;
106foreach (var resource in _model.Resources)
114var resource = @event.Resource;
169static Task PublishUpdateAsync(ResourceNotificationService notificationService, IResource resource, string? resourceId, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
182private async Task ProcessUrls(IResource resource, CancellationToken cancellationToken)
245async Task ProcessValueAsync(IResource resource, IValueProvider vp)
369private async Task SetChildResourceAsync(IResource resource, string? state, DateTime? startTimeStamp, DateTime? stopTimeStamp)
371foreach (var child in _parentChildLookup[resource])
389foreach (var resource in _model.Resources)
393var parent = resource is IResourceWithParent hasParent
413private static ImmutableArray<HealthReportSnapshot> GetInitialHealthReports(IResource resource)
424private async Task PublishConnectionStringAvailableEvent(IResource resource, CancellationToken cancellationToken)
Orchestrator\RelationshipEvaluator.cs (19)
13public static ILookup<IResource, IResource> GetParentChildLookup(DistributedApplicationModel model)
18.Select(x => (Child: (IResource)x, Parent: x.Parent))
24private static IEnumerable<(IResource Child, IResource Parent)> GetParentChildRelationshipsFromAnnotations(DistributedApplicationModel model)
26static bool TryGetParent(IResource resource, [NotNullWhen(true)] out IResource? parent)
39static IResource? SelectParentResource(IResource? resource) => resource switch
41IResource r when TryGetParent(r, out var parent) => parent,
54private static void ValidateRelationships((IResource Child, IResource Parent)[] relationships)
64var visited = new Stack<IResource>();
70static void ValidateNoCircularDependencies(Dictionary<IResource, IResource> childToParentLookup, IResource child, Stack<IResource> visited)
73if (childToParentLookup.TryGetValue(child, out var parent))
ResourceBuilderExtensions.cs (41)
278public static IResourceBuilder<T> WithManifestPublishingCallback<T>(this IResourceBuilder<T> builder, Action<ManifestPublishingContext> callback) where T : IResource
295public static IResourceBuilder<T> WithPublishingCallback<T>(this IResourceBuilder<T> builder, Func<PublishingContext, Task> callback) where T : IResource
311public static IResourceBuilder<T> WithManifestPublishingCallback<T>(this IResourceBuilder<T> builder, Func<ManifestPublishingContext, Task> callback) where T : IResource
768where T : IResource
791where T : IResource
812where T : IResource
833where T : IResource
855where T : IResource
910where T : IResource
981public static IResourceBuilder<T> ExcludeFromManifest<T>(this IResourceBuilder<T> builder) where T : IResource
999/// resources, calling <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> also results
1015public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResourceWithWaitSupport
1035/// resources, calling <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource}, WaitBehavior)"/> also results
1043/// behavior with the <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> overload.</para>
1057public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior waitBehavior) where T : IResourceWithWaitSupport
1065private static IResourceBuilder<T> WaitForCore<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior? waitBehavior, bool addRelationship) where T : IResourceWithWaitSupport
1067if (builder.Resource as IResource == dependency.Resource)
1092foreach (var referencedResource in cs.ConnectionStringExpression.ValueProviders.OfType<IResource>())
1127public static IResourceBuilder<T> WithExplicitStart<T>(this IResourceBuilder<T> builder) where T : IResource
1158public static IResourceBuilder<T> WaitForCompletion<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, int exitCode = 0) where T : IResourceWithWaitSupport
1163if (builder.Resource as IResource == dependency.Resource)
1188/// the <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> to associate a resource
1214public static IResourceBuilder<T> WithHealthCheck<T>(this IResourceBuilder<T> builder, string key) where T : IResource
1413CommandOptions? commandOptions = null) where T : IResource
1480bool isHighlighted = false) where T : IResource
1823IResource resource,
1824string type) where T : IResource
1842IResource resource) where T : IResource
1859ReferenceExpression expression) where T : IResource
1870where T : IResource
1874void AddReference(IResource resource)
1886if (value is IResource resource)
1890else if (value is IResourceBuilder<IResource> resourceBuilder)
1918IResourceBuilder<IResource> resourceBuilder) where T : IResource
1951IResourceBuilder<IResource> parent) where T : IResource
1981IResource parent) where T : IResource
Aspire.Hosting.Azure (21)
AzureResourcePreparer.cs (11)
51internal static List<(IResource Resource, IAzureResource AzureResource)> GetAzureResourcesFromAppModel(DistributedApplicationModel appModel)
58var azureResources = new List<(IResource, IAzureResource)>();
59foreach (var resource in appModel.Resources)
90foreach (var resource in appModel.Resources)
104private async Task BuildRoleAssignmentAnnotations(DistributedApplicationModel appModel, List<(IResource Resource, IAzureResource AzureResource)> azureResources, AzureProvisioningOptions options, CancellationToken cancellationToken)
130foreach (var resource in resourceSnapshot)
232static bool IsResourceValidForRoleAssignments(IResource resource)
238private static Dictionary<AzureProvisioningResource, IEnumerable<RoleDefinition>> GetAllRoleAssignments(IResource resource)
253IResource resource,
285IResource resource,
356private async Task<HashSet<IAzureResource>> GetAzureReferences(IResource resource, CancellationToken cancellationToken)
Provisioning\Provisioners\AzureProvisioner.cs (6)
44private ILookup<IResource, IResourceWithParent>? _parentChildLookup;
64async Task UpdateStateAsync((IResource Resource, IAzureResource AzureResource) resource, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
97async Task AfterProvisionAsync((IResource Resource, IAzureResource AzureResource) resource)
131async Task<bool> WaitForRoleAssignments((IResource Resource, IAzureResource AzureResource) resource)
198IList<(IResource Resource, IAzureResource AzureResource)> azureResources,
255private async Task ProcessResourceAsync(IConfiguration configuration, Lazy<Task<ProvisioningContext>> provisioningContextLazy, (IResource Resource, IAzureResource AzureResource) resource, CancellationToken cancellationToken)
Aspire.Hosting.Azure.AppConfiguration (3)
Aspire.Hosting.Azure.AppContainers (13)
Aspire.Hosting.Azure.AppService (6)
Aspire.Hosting.Azure.CognitiveServices (3)
Aspire.Hosting.Azure.ContainerRegistry (4)
Aspire.Hosting.Azure.EventHubs (3)
Aspire.Hosting.Azure.Functions (2)
Aspire.Hosting.Azure.KeyVault (3)
Aspire.Hosting.Azure.Search (3)
Aspire.Hosting.Azure.ServiceBus (3)
Aspire.Hosting.Azure.SignalR (3)
Aspire.Hosting.Azure.Storage (3)
Aspire.Hosting.Azure.Tests (39)
Aspire.Hosting.Azure.WebPubSub (3)
Aspire.Hosting.Containers.Tests (11)
Aspire.Hosting.Docker (11)
Aspire.Hosting.Docker.Tests (1)
Aspire.Hosting.Kafka.Tests (1)
Aspire.Hosting.Keycloak.Tests (2)
Aspire.Hosting.Kubernetes (19)
Aspire.Hosting.Milvus.Tests (2)
Aspire.Hosting.MySql.Tests (4)
Aspire.Hosting.Oracle.Tests (3)
Aspire.Hosting.PostgreSQL (3)
Aspire.Hosting.PostgreSQL.Tests (7)
Aspire.Hosting.Qdrant.Tests (3)
Aspire.Hosting.Redis (2)
Aspire.Hosting.Redis.Tests (4)
Aspire.Hosting.Testing (10)
Aspire.Hosting.Testing.Tests (3)
Aspire.Hosting.Tests (25)
Aspire.Playground.Tests (3)
Stress.AppHost (5)