Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
ComMethodDesc.cs110 linesDownload Raw Back to ComInterop
1// Licensed to the .NET Foundation under one or more agreements.2// The .NET Foundation licenses this file to you under the MIT license.3 4using System.Diagnostics;5using System.Runtime.InteropServices.ComTypes;6 7namespace System.Management.Automation.ComInterop8{9    internal class ComMethodDesc10    {11        internal readonly INVOKEKIND InvokeKind;12 13        private ComMethodDesc(int dispId)14        {15            DispId = dispId;16        }17 18        internal ComMethodDesc(string name, int dispId)19            : this(dispId)20        {21            // no ITypeInfo constructor22            Name = name;23        }24 25        internal ComMethodDesc(string name, int dispId, INVOKEKIND invkind)26            : this(name, dispId)27        {28            InvokeKind = invkind;29        }30 31        internal ComMethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc)32            : this(funcDesc.memid)33        {34            InvokeKind = funcDesc.invkind;35 36            string[] rgNames = new string[1 + funcDesc.cParams];37            typeInfo.GetNames(DispId, rgNames, rgNames.Length, out int cNames);38 39            bool skipLast = false;40            if (IsPropertyPut && rgNames[rgNames.Length - 1] == null)41            {42                rgNames[rgNames.Length - 1] = "value";43                cNames++;44                skipLast = true;45            }46            Debug.Assert(cNames == rgNames.Length);47            Name = rgNames[0];48 49            ParamCount = funcDesc.cParams;50            ReturnType = ComUtil.GetTypeFromTypeDesc(funcDesc.elemdescFunc.tdesc);51            ParameterInformation = ComUtil.GetParameterInformation(funcDesc, skipLast);52        }53 54        public string Name { get; }55 56        public int DispId { get; }57 58        public bool IsPropertyGet59        {60            get61            {62                return (InvokeKind & INVOKEKIND.INVOKE_PROPERTYGET) != 0;63            }64        }65 66        public bool IsDataMember67        {68            get69            {70                //must be regular get71                if (!IsPropertyGet || DispId == ComDispIds.DISPID_NEWENUM)72                {73                    return false;74                }75 76                //must have no parameters77                return ParamCount == 0;78            }79        }80 81        public bool IsPropertyPut82        {83            get84            {85                return (InvokeKind & (INVOKEKIND.INVOKE_PROPERTYPUT | INVOKEKIND.INVOKE_PROPERTYPUTREF)) != 0;86            }87        }88 89        public bool IsPropertyPutRef90        {91            get92            {93                return (InvokeKind & INVOKEKIND.INVOKE_PROPERTYPUTREF) != 0;94            }95        }96 97        internal int ParamCount { get; }98 99        public Type ReturnType { get; set; }100 101        public Type InputType { get; set; }102 103        public ParameterInformation[] ParameterInformation104        {105            get;106            set;107        }108    }109}110