Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
DispCallable.cs48 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.Dynamic;5using System.Globalization;6using System.Linq.Expressions;7 8namespace System.Management.Automation.ComInterop9{10    /// <summary>11    /// This represents a bound dispmember on a IDispatch object.12    /// </summary>13    internal sealed class DispCallable : IPseudoComObject14    {15        internal DispCallable(IDispatchComObject dispatch, string memberName, int dispId)16        {17            DispatchComObject = dispatch;18            MemberName = memberName;19            DispId = dispId;20        }21 22        public override string ToString() => $"<bound dispmethod {MemberName}>";23 24        public IDispatchComObject DispatchComObject { get; }25 26        public IDispatch DispatchObject => DispatchComObject.DispatchObject;27 28        public string MemberName { get; }29 30        public int DispId { get; }31 32        public DynamicMetaObject GetMetaObject(Expression parameter)33        {34            return new DispCallableMetaObject(parameter, this);35        }36 37        public override bool Equals(object obj)38        {39            return obj is DispCallable other && other.DispatchComObject == DispatchComObject && other.DispId == DispId;40        }41 42        public override int GetHashCode()43        {44            return DispatchComObject.GetHashCode() ^ DispId;45        }46    }47}48