MegaBites-AI/Windows-powershell
0372
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.Linq.Expressions;6using AstUtils = System.Management.Automation.Interpreter.Utils;7 8namespace System.Management.Automation.ComInterop9{10 internal class ComClassMetaObject : DynamicMetaObject11 {12 internal ComClassMetaObject(Expression expression, ComTypeClassDesc cls)13 : base(expression, BindingRestrictions.Empty, cls)14 {15 }16 17 public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args)18 {19 return new DynamicMetaObject(20 Expression.Call(21 AstUtils.Convert(Expression, typeof(ComTypeClassDesc)),22 typeof(ComTypeClassDesc).GetMethod(nameof(ComTypeClassDesc.CreateInstance))23 ),24 BindingRestrictions.Combine(args).Merge(25 BindingRestrictions.GetTypeRestriction(Expression, typeof(ComTypeClassDesc))26 )27 );28 }29 }30}31 