4 instantiations of ResourceViewModel
Aspire.Dashboard (1)
ResourceService\Partials.cs (1)
23return new()
Aspire.Dashboard.Components.Tests (2)
Pages\ResourcesTests.cs (1)
357return new ResourceViewModel
tests\Shared\DashboardModel\ModelTestHelpers.cs (1)
27return new ResourceViewModel
Aspire.Dashboard.Tests (1)
tests\Shared\DashboardModel\ModelTestHelpers.cs (1)
27return new ResourceViewModel
201 references to ResourceViewModel
Aspire.Dashboard (130)
Components\Controls\ResourceActions.razor.cs (4)
40public required Func<ResourceViewModel, CommandViewModel, bool> IsCommandExecuting { get; set; } 46public required ResourceViewModel Resource { get; set; } 49public required Func<ResourceViewModel, string> GetResourceName { get; set; } 55public required ConcurrentDictionary<string, ResourceViewModel> ResourceByName { get; set; }
Components\Controls\ResourceDetails.razor.cs (7)
20public required ResourceViewModel Resource { get; set; } 23public required ConcurrentDictionary<string, ResourceViewModel> ResourceByName { get; set; } 46private ResourceViewModel? _resource; 182foreach (var match in matches) 184items.Add(ResourceDetailRelationshipViewModel.Create(match, ResourceViewModel.GetResourceName(match, ResourceByName), resourceRelationships)); 204foreach (var otherResource in otherResources) 210items.Add(ResourceDetailRelationshipViewModel.Create(otherResource, ResourceViewModel.GetResourceName(otherResource, ResourceByName), resourceRelationships));
Components\Pages\ConsoleLogs.razor.cs (13)
102private readonly ConcurrentDictionary<string, ResourceViewModel> _resourceByName = new(StringComparers.ResourceName); 188foreach (var resource in snapshot) 199if (ResourceViewModel.TryGetResourceByName(ResourceName, _resourceByName, out var selectedResource)) 241void SetSelectedResourceOption(ResourceViewModel resource) 389private string GetResourceName(ResourceViewModel resource) => ResourceViewModel.GetResourceName(resource, _resourceByName); 392ConcurrentDictionary<string, ResourceViewModel> resourcesByName, 420foreach (var resource in grouping.Select(g => g.Value).OrderBy(r => r, ResourceViewModelNameComparer.Instance)) 429SelectViewModel<ResourceTypeDetails> ToOption(ResourceViewModel resource, bool isReplica, string applicationName) 443var resourceName = ResourceViewModel.GetResourceName(resource, resourcesByName); 572private async Task OnResourceChanged(ResourceViewModelChangeType changeType, ResourceViewModel resource) 708public required ResourceViewModel? SelectedResource { get; set; }
Components\Pages\Resources.razor.cs (22)
87private ResourceViewModel? SelectedResource { get; set; } 90private readonly ConcurrentDictionary<string, ResourceViewModel> _resourceByName = new(StringComparers.ResourceName); 115private bool Filter(ResourceViewModel resource) 225foreach (var resource in snapshot) 284private bool UpdateFromResource(ResourceViewModel resource) 297private bool UpdateFromResource(ResourceViewModel resource, Func<string, bool> resourceTypeVisible, Func<string, bool> stateVisible, Func<string, bool> healthStatusVisible) 354if (resources._resourceByName.TryGetValue(id, out var resource)) 367if (resources._resourceByName.TryGetValue(id, out var resource)) 377internal IEnumerable<ResourceViewModel> GetFilteredResources() 496if (_resourceByName.TryGetValue(ResourceName, out var selectedResource)) 526private async Task ShowContextMenuAsync(ResourceViewModel resource, int screenWidth, int screenHeight, int clientX, int clientY) 562private async Task ShowResourceDetailsAsync(ResourceViewModel resource, string? buttonId) 575var current = resource; 618private string GetResourceName(ResourceViewModel resource) => ResourceViewModel.GetResourceName(resource, _resourceByName); 620private bool HasMultipleReplicas(ResourceViewModel resource) 643private string GetRowClass(ResourceViewModel resource) 646private async Task ExecuteResourceCommandAsync(ResourceViewModel resource, CommandViewModel command) 651private static string GetUrlsTooltip(ResourceViewModel resource) 705foreach (var resource in resourcesWithChildren) 712foreach (var resource in resourcesWithChildren) 731private static List<DisplayedUrl> GetDisplayedUrls(ResourceViewModel resource)
Components\ResourcesGridColumns\StateColumnDisplay.razor.cs (1)
15public required ResourceViewModel Resource { get; set; }
Components\ResourcesGridColumns\UnreadLogErrorsBadge.razor.cs (2)
17public required ResourceViewModel Resource { get; set; } 29private (string? applicationName, int unviewedErrorCount) GetUnviewedErrorCount(ResourceViewModel resource)
Components\ResourcesGridColumns\UrlsColumnDisplay.razor.cs (1)
14public required ResourceViewModel Resource { get; set; }
Extensions\ResourceViewModelExtensions.cs (10)
10public static bool IsRunningState(this ResourceViewModel resource) 15public static bool IsFinishedState(this ResourceViewModel resource) 20public static bool IsExitedState(this ResourceViewModel resource) 25public static bool IsStopped(this ResourceViewModel resource) 30public static bool IsUnusableTransitoryState(this ResourceViewModel resource) 35public static bool IsRuntimeUnhealthy(this ResourceViewModel resource) 40public static bool IsNotStarted(this ResourceViewModel resource) 45public static bool IsWaiting(this ResourceViewModel resource) 50public static bool IsUnknownState(this ResourceViewModel resource) => resource.KnownState is KnownResourceState.Unknown; 52public static bool HasNoState(this ResourceViewModel resource) => string.IsNullOrEmpty(resource.State);
Model\BrowserLinkOutgoingPeerResolver.cs (1)
22public bool TryResolvePeer(KeyValuePair<string, string>[] attributes, out string? name, out ResourceViewModel? matchedResource)
Model\DashboardCommandExecutor.cs (4)
35public async Task ExecuteAsync(ResourceViewModel resource, CommandViewModel command, Func<ResourceViewModel, string> getResourceName) 87public async Task ExecuteAsyncCore(ResourceViewModel resource, CommandViewModel command, Func<ResourceViewModel, string> getResourceName)
Model\IOutgoingPeerResolver.cs (1)
8bool TryResolvePeer(KeyValuePair<string, string>[] attributes, out string? name, out ResourceViewModel? matchedResourced);
Model\ResourceDetailRelationshipViewModel.cs (2)
8public required ResourceViewModel Resource { get; init; } 18public static ResourceDetailRelationshipViewModel Create(ResourceViewModel resource, string resourceName, IEnumerable<RelationshipViewModel> matches)
Model\ResourceGraph\ResourceGraphMapper.cs (5)
16public static ResourceDto MapResource(ResourceViewModel r, IDictionary<string, ResourceViewModel> resourcesByName, IStringLocalizer<Columns> columnsLoc) 30foreach (var match in matches) 38var resourceName = ResourceViewModel.GetResourceName(r, resourcesByName); 49DisplayName = ResourceViewModel.GetResourceName(r, resourcesByName),
Model\ResourceGridViewModel.cs (3)
11public required ResourceViewModel Resource { get; init; } 36public static List<ResourceGridViewModel> OrderNestedResources(List<ResourceGridViewModel> initialGridVMs, Func<ResourceViewModel, bool> isCollapsed) 58void AddChildViewModel(ResourceViewModel resource, ResourceGridViewModel parent, int depth, bool hidden)
Model\ResourceIconHelpers.cs (1)
13public static Icon GetIconForResource(ResourceViewModel resource, IconSize desiredSize)
Model\ResourceMenuItems.cs (3)
25ResourceViewModel resource, 28Func<ResourceViewModel, string> getResourceName, 34Func<ResourceViewModel, CommandViewModel, bool> isCommandExecuting,
Model\ResourceOutgoingPeerResolver.cs (8)
15private readonly ConcurrentDictionary<string, ResourceViewModel> _resourceByName = new(StringComparers.ResourceName); 34foreach (var resource in snapshot) 51if (!_resourceByName.TryGetValue(resource.Name, out var existingResource) || !AreEquivalent(resource.Urls, existingResource.Urls)) 97public bool TryResolvePeer(KeyValuePair<string, string>[] attributes, out string? name, out ResourceViewModel? matchedResource) 102internal static bool TryResolvePeerNameCore(IDictionary<string, ResourceViewModel> resources, KeyValuePair<string, string>[] attributes, [NotNullWhen(true)] out string? name, [NotNullWhen(true)] out ResourceViewModel? resourceMatch) 131bool TryMatchResourceAddress(string value, [NotNullWhen(true)] out string? name, [NotNullWhen(true)] out ResourceViewModel? resourceMatch) 141name = ResourceViewModel.GetResourceName(resource, resources);
Model\ResourceSourceViewModel.cs (2)
15internal static ResourceSourceViewModel? GetSourceViewModel(ResourceViewModel resource) 42static CommandLineInfo? GetCommandLineInfo(ResourceViewModel resourceViewModel)
Model\ResourceStateViewModel.cs (4)
23internal static ResourceStateViewModel GetStateViewModel(ResourceViewModel resource, IStringLocalizer<Columns> loc) 31private static (Icon icon, Color color) GetStateIcon(ResourceViewModel resource) 104internal static string GetResourceStateTooltip(ResourceViewModel resource, IStringLocalizer<Columns> loc) 142private static string GetStateText(ResourceViewModel resource, IStringLocalizer<Columns> loc)
Model\ResourceUrlHelpers.cs (1)
11public static List<DisplayedUrl> GetUrls(ResourceViewModel resource, bool includeInternalUrls = false, bool includeNonEndpointUrls = false)
Model\ResourceViewModel.cs (10)
106public static string GetResourceName(ResourceViewModel resource, IDictionary<string, ResourceViewModel> allResources) 111public static string GetResourceName(ResourceViewModel resource, IEnumerable<ResourceViewModel> allResources) 114foreach (var item in allResources) 136public static bool TryGetResourceByName(string resourceName, IDictionary<string, ResourceViewModel> resourceByName, [NotNullWhen(true)] out ResourceViewModel? resource) 154public sealed class ResourceViewModelNameComparer : IComparer<ResourceViewModel> 158public int Compare(ResourceViewModel? x, ResourceViewModel? y)
Model\ResourceViewModelExtensions.cs (14)
12public static bool IsContainer(this ResourceViewModel resource) 17public static bool IsProject(this ResourceViewModel resource) 22public static bool IsExecutable(this ResourceViewModel resource, bool allowSubtypes) 37public static bool TryGetExitCode(this ResourceViewModel resource, out int exitCode) 42public static bool TryGetContainerImage(this ResourceViewModel resource, [NotNullWhen(returnValue: true)] out string? containerImage) 47public static bool TryGetProjectPath(this ResourceViewModel resource, [NotNullWhen(returnValue: true)] out string? projectPath) 52public static bool TryGetExecutablePath(this ResourceViewModel resource, [NotNullWhen(returnValue: true)] out string? executablePath) 57public static bool TryGetExecutableArguments(this ResourceViewModel resource, out ImmutableArray<string> arguments) 62public static bool TryGetAppArgs(this ResourceViewModel resource, out ImmutableArray<string> arguments) 67public static bool TryGetAppArgsSensitivity(this ResourceViewModel resource, out ImmutableArray<bool> argParams) 72private static bool TryGetCustomDataString(this ResourceViewModel resource, string key, [NotNullWhen(returnValue: true)] out string? s) 84private static bool TryGetCustomDataStringArray(this ResourceViewModel resource, string key, out ImmutableArray<string> strings) 109private static bool TryGetCustomDataBoolArray(this ResourceViewModel resource, string key, out ImmutableArray<bool> bools) 134private static bool TryGetCustomDataInt(this ResourceViewModel resource, string key, out int i)
Otlp\Storage\TelemetryRepository.cs (3)
1075var uninstrumentedPeer = hasUninstrumentedPeer ? ResolveUninstrumentedPeerResource(span, _outgoingPeerResolvers) : null; 1096private static ResourceViewModel? ResolveUninstrumentedPeerResource(OtlpSpan span, IEnumerable<IOutgoingPeerResolver> outgoingPeerResolvers) 1101if (resolver.TryResolvePeer(span.Attributes, out _, out var matchedResourced))
ResourceService\DashboardClient.cs (4)
42private readonly Dictionary<string, ResourceViewModel> _resourceByName = new(StringComparers.ResourceName); 338var viewModel = resource.ToViewModel(_knownPropertyLookup, _logger); 358var viewModel = change.Upsert.ToViewModel(_knownPropertyLookup, _logger); 365if (_resourceByName.Remove(change.Delete.ResourceName, out var removed))
ResourceService\IDashboardClient.cs (2)
60ImmutableArray<ResourceViewModel> InitialState, 65ResourceViewModel Resource);
ResourceService\Partials.cs (2)
19public ResourceViewModel ToViewModel(IKnownPropertyLookup knownPropertyLookup, ILogger logger) 48throw new InvalidOperationException($@"Error converting resource ""{Name}"" to {nameof(ResourceViewModel)}.", ex);
Aspire.Dashboard.Components.Tests (33)
Controls\ResourceDetailsTests.cs (16)
25var resource1 = ModelTestHelpers.CreateResource( 38builder.Add(p => p.ResourceByName, new ConcurrentDictionary<string, ResourceViewModel>([new KeyValuePair<string, ResourceViewModel> (resource1.Name, resource1)])); 71var resource2 = ModelTestHelpers.CreateResource( 109var resource1 = ModelTestHelpers.CreateResource( 122builder.Add(p => p.ResourceByName, new ConcurrentDictionary<string, ResourceViewModel>([new KeyValuePair<string, ResourceViewModel> (resource1.Name, resource1)])); 155var resource2 = ModelTestHelpers.CreateResource( 193var resource1 = ModelTestHelpers.CreateResource( 206builder.Add(p => p.ResourceByName, new ConcurrentDictionary<string, ResourceViewModel>([new KeyValuePair<string, ResourceViewModel> (resource1.Name, resource1)])); 239var resource2 = ModelTestHelpers.CreateResource( 277var resource1 = ModelTestHelpers.CreateResource( 290builder.Add(p => p.ResourceByName, new ConcurrentDictionary<string, ResourceViewModel>([new KeyValuePair<string, ResourceViewModel> (resource1.Name, resource1)])); 323var resource2 = ModelTestHelpers.CreateResource(
Pages\ConsoleLogsTests.cs (8)
49var testResource = ModelTestHelpers.CreateResource(appName: "test-resource", state: KnownResourceState.Running); 50var testResource2 = ModelTestHelpers.CreateResource(appName: "test-resource2", state: KnownResourceState.Running); 131var testResource = ModelTestHelpers.CreateResource(appName: "test-resource", state: KnownResourceState.Running); 181var testResource = ModelTestHelpers.CreateResource(appName: "test-resource", state: KnownResourceState.Running); 238var testResource = ModelTestHelpers.CreateResource(appName: "test-resource", state: KnownResourceState.Running); 292var testResource = ModelTestHelpers.CreateResource( 356var testResource = ModelTestHelpers.CreateResource( 420var testResource = ModelTestHelpers.CreateResource(appName: "test-resource", state: KnownResourceState.Running);
Pages\ResourcesTests.cs (6)
28var initialResources = new List<ResourceViewModel> 117var initialResources = new List<ResourceViewModel> 179var initialResources = new List<ResourceViewModel> 216var initialResources = new List<ResourceViewModel> 313var initialResources = new List<ResourceViewModel> 355private static ResourceViewModel CreateResource(string name, string type, string? state, ImmutableArray<HealthReportViewModel>? healthReports)
Shared\TestDashboardClient.cs (2)
16private readonly IList<ResourceViewModel>? _initialResources; 27IList<ResourceViewModel>? initialResources = null)
tests\Shared\DashboardModel\ModelTestHelpers.cs (1)
12public static ResourceViewModel CreateResource(
Aspire.Dashboard.Tests (38)
ConsoleLogsTests\CreateResourceSelectModelsTests.cs (2)
19var applications = new List<ResourceViewModel> 35var resourcesByName = new ConcurrentDictionary<string, ResourceViewModel>(applications.ToDictionary(app => app.Name));
Integration\Playwright\Infrastructure\MockDashboardClient.cs (1)
12public static readonly ResourceViewModel TestResource1 = ModelTestHelpers.CreateResource(
Model\ResourceGraphMapperTests.cs (9)
19var resource1 = ModelTestHelpers.CreateResource("app1-abcxyc", displayName: "app1", relationships: [new RelationshipViewModel("app2", "Reference")]); 20var resource2 = ModelTestHelpers.CreateResource("app2-123456", displayName: "app2", relationships: ImmutableArray<RelationshipViewModel>.Empty); 21var resources = new Dictionary<string, ResourceViewModel> 39var resource1 = ModelTestHelpers.CreateResource("app1-abcxyc", displayName: "app1", relationships: [new RelationshipViewModel("app2", "Reference")]); 40var resource21 = ModelTestHelpers.CreateResource("app2-123456", displayName: "app2", relationships: ImmutableArray<RelationshipViewModel>.Empty); 41var resource22 = ModelTestHelpers.CreateResource("app2-654321", displayName: "app2", relationships: ImmutableArray<RelationshipViewModel>.Empty); 42var resources = new Dictionary<string, ResourceViewModel> 62var resource = ModelTestHelpers.CreateResource("app1-abcxyc", displayName: "app1", relationships: ImmutableArray<RelationshipViewModel>.Empty); 63var resources = new Dictionary<string, ResourceViewModel>
Model\ResourceMenuItemsTests.cs (3)
25var resource = ModelTestHelpers.CreateResource(); 55var resource = ModelTestHelpers.CreateResource(appName: "test-abc"); 108var resource = ModelTestHelpers.CreateResource(appName: "test-abc");
Model\ResourceSourceViewModelTests.cs (1)
39var resource = ModelTestHelpers.CreateResource(
Model\ResourceStateViewModelTests.cs (1)
78var resource = ModelTestHelpers.CreateResource(
Model\ResourceUrlHelpersTests.cs (1)
12public static List<DisplayedUrl> GetUrls(ResourceViewModel resource, bool includeInternalUrls = false)
Model\ResourceViewModelTests.cs (4)
30var actualStatus = ResourceViewModel.ComputeHealthStatus(reports, state); 50var vm = resource.ToViewModel(new MockKnownPropertyLookup(), NullLogger.Instance); 78var vm = resource.ToViewModel(new MockKnownPropertyLookup(), NullLogger.Instance); 128var viewModel = resource.ToViewModel(new MockKnownPropertyLookup(123, kp), NullLogger.Instance);
ResourceOutgoingPeerResolverTests.cs (11)
15private static ResourceViewModel CreateResource(string name, string? serviceAddress = null, int? servicePort = null, string? displayName = null, KnownResourceState? state = null) 28var resources = new Dictionary<string, ResourceViewModel> 41var resources = new Dictionary<string, ResourceViewModel> 54var resources = new Dictionary<string, ResourceViewModel> 67var resources = new Dictionary<string, ResourceViewModel> 81var resources = new Dictionary<string, ResourceViewModel> 95var resources = new Dictionary<string, ResourceViewModel> 109var resources = new Dictionary<string, ResourceViewModel> 188var resources = new Dictionary<string, ResourceViewModel> 202var resources = new Dictionary<string, ResourceViewModel> 216private static bool TryResolvePeerName(IDictionary<string, ResourceViewModel> resources, KeyValuePair<string, string>[] attributes, out string? peerName)
TelemetryRepositoryTests\TestOutgoingPeerResolver.cs (3)
11private readonly Func<KeyValuePair<string, string>[], (string? Name, ResourceViewModel? Resource)>? _onResolve; 14public TestOutgoingPeerResolver(Func<KeyValuePair<string, string>[], (string? Name, ResourceViewModel? Resource)>? onResolve = null) 38public bool TryResolvePeer(KeyValuePair<string, string>[] attributes, out string? name, out ResourceViewModel? matchedResourced)
TelemetryRepositoryTests\TraceTests.cs (1)
2014var matchedResourced = ModelTestHelpers.CreateResource(appName: "TestPeer");
tests\Shared\DashboardModel\ModelTestHelpers.cs (1)
12public static ResourceViewModel CreateResource(