/ src / modules / cmdpal / Core / Microsoft.CmdPal.Core.ViewModels / DetailsElementViewModel.cs
DetailsElementViewModel.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using Microsoft.CmdPal.Core.ViewModels.Models;
 6  using Microsoft.CommandPalette.Extensions;
 7  
 8  namespace Microsoft.CmdPal.Core.ViewModels;
 9  
10  public abstract partial class DetailsElementViewModel(IDetailsElement _detailsElement, WeakReference<IPageContext> context) : ExtensionObjectViewModel(context)
11  {
12      private readonly ExtensionObject<IDetailsElement> _model = new(_detailsElement);
13  
14      public string Key { get; private set; } = string.Empty;
15  
16      public override void InitializeProperties()
17      {
18          var model = _model.Unsafe;
19          if (model is null)
20          {
21              return;
22          }
23  
24          Key = model.Key ?? string.Empty;
25          UpdateProperty(nameof(Key));
26      }
27  }