// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using WindowsPackageManager.Interop;
namespace Microsoft.CmdPal.Ext.WinGet.WindowsPackageManager.Interop;
#nullable disable
internal sealed class ClassModel
{
///
/// Gets the interface for the projected class type generated by CsWinRT
///
public Type InterfaceType { get; init; }
///
/// Gets the projected class type generated by CsWinRT
///
public Type ProjectedClassType { get; init; }
///
/// Gets the Clsids for each context (e.g. OutOfProcProd, OutOfProcDev)
///
public IReadOnlyDictionary Clsids { get; init; }
///
/// Get CLSID based on the provided context
///
/// Context
/// CLSID for the provided context.
/// Throw an exception if the clsid context is not available for the current instance.
public Guid GetClsid(ClsidContext context)
{
return !Clsids.TryGetValue(context, out var clsid)
? throw new InvalidOperationException($"{ProjectedClassType.FullName} is not implemented in context {context}")
: clsid;
}
///
/// Get IID corresponding to the COM object
///
/// IID.
public Guid GetIid() => InterfaceType.GUID;
}