MegaBites-AI/Windows-powershell
0372
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Reflection;5using System.Runtime.InteropServices;6 7#nullable enable8namespace System.Management.Automation9{10 /// <summary>11 /// IInspectable represents the base interface for all WinRT types.12 /// Any run time class exposed through WInRT language projections13 /// like C#, VB.Net, C++ and JavaScript would have implemented14 /// the IInspectable interface.15 /// This interface is needed on long term basis to efficiently support identifying16 /// WinRT type instances created in Powershell session. Hence being17 /// included as part of SMA.18 /// The only purpose of this interface is to identify if the created object is of WinRT type.19 /// Users should not implement this interface for any custom functionalities.20 /// This is like a PInvoke. WinRT team have defined IInspectable in the COM layer.21 /// Through PInvoke this interface is being used in the managed layer.22 /// </summary>23 [Guid("AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90")]24 [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]25 internal interface IInspectable { }26 27 /// <summary>28 /// Helper class for WinRT types.29 /// </summary>30 internal static class WinRTHelper31 {32 internal static bool IsWinRTType(Type type)33 {34 // All WinRT Types would contain the Attributes flag set to TypeAttributes.WindowsRuntime35 // TypeAttributes.WindowsRuntime is part of CLR 4.5. Inorder to build PowerShell for36 // CLR 4.0, a string comparison for the for the existence of TypeAttributes.WindowsRuntime37 // in the Attributes flag is performed rather than the actual bitwise comparison.38 return type.Attributes.ToString().Contains("WindowsRuntime");39 }40 }41}42 