mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-18 05:05:36 +00:00
40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
/********************************************************************++
|
|||
|
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||
|
|
--********************************************************************/
|
||
|
|
|
||
|
|
#if !SILVERLIGHT // ComObject
|
||
|
|
|
||
|
|
#if !CLR2
|
||
|
|
using System.Linq.Expressions;
|
||
|
|
#else
|
||
|
|
using Microsoft.Scripting.Ast;
|
||
|
|
#endif
|
||
|
|
|
||
|
|
using System.Dynamic;
|
||
|
|
//using AstUtils = Microsoft.Scripting.Ast.Utils;
|
||
|
|
using System.Management.Automation.Interpreter;
|
||
|
|
using AstUtils = System.Management.Automation.Interpreter.Utils;
|
||
|
|
|
||
|
|
namespace System.Management.Automation.ComInterop {
|
||
|
|
|
||
|
|
internal class ComClassMetaObject : DynamicMetaObject {
|
||
|
|
internal ComClassMetaObject(Expression expression, ComTypeClassDesc cls)
|
||
|
|
: base(expression, BindingRestrictions.Empty, cls) {
|
||
|
|
}
|
||
|
|
|
||
|
|
public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) {
|
||
|
|
return new DynamicMetaObject(
|
||
|
|
Expression.Call(
|
||
|
|
AstUtils.Convert(Expression, typeof(ComTypeClassDesc)),
|
||
|
|
typeof(ComTypeClassDesc).GetMethod("CreateInstance")
|
||
|
|
),
|
||
|
|
BindingRestrictions.Combine(args).Merge(
|
||
|
|
BindingRestrictions.GetTypeRestriction(Expression, typeof(ComTypeClassDesc))
|
||
|
|
)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif
|
||
|
|
|