Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
SplatCallSite.cs39 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;5using System.Diagnostics;6using System.Runtime.CompilerServices;7 8namespace System.Management.Automation.ComInterop9{10    internal sealed class SplatCallSite11    {12        // Stored callable IDynamicMetaObjectProvider.13        internal readonly object _callable;14 15        // Can the number of arguments to a given event change each call?16        // If not, we don't need this level of indirection--we could cache a17        // delegate that does the splatting.18        private CallSite<Func<CallSite, object, object[], object>> _site;19 20        internal SplatCallSite(object callable)21        {22            Debug.Assert(callable != null);23            _callable = callable;24        }25 26        public delegate object InvokeDelegate(object[] args);27 28        internal object Invoke(object[] args)29        {30            Debug.Assert(args != null);31 32            // Create a CallSite and invoke it.33            _site ??= CallSite<Func<CallSite, object, object[], object>>.Create(SplatInvokeBinder.Instance);34 35            return _site.Target(_site, _callable, args);36        }37    }38}39