2016-03-30 14:20:52 -07:00
|
|
|
/********************************************************************++
|
|
|
|
|
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 AstUtils = System.Management.Automation.Interpreter.Utils;
|
|
|
|
|
|
2016-07-29 13:02:49 -07:00
|
|
|
namespace System.Management.Automation.ComInterop
|
|
|
|
|
{
|
|
|
|
|
internal class ComClassMetaObject : DynamicMetaObject
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
internal ComClassMetaObject(Expression expression, ComTypeClassDesc cls)
|
2016-07-29 13:02:49 -07:00
|
|
|
: base(expression, BindingRestrictions.Empty, cls)
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
}
|
|
|
|
|
|
2016-07-29 13:02:49 -07:00
|
|
|
public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args)
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
return new DynamicMetaObject(
|
|
|
|
|
Expression.Call(
|
|
|
|
|
AstUtils.Convert(Expression, typeof(ComTypeClassDesc)),
|
|
|
|
|
typeof(ComTypeClassDesc).GetMethod("CreateInstance")
|
|
|
|
|
),
|
|
|
|
|
BindingRestrictions.Combine(args).Merge(
|
|
|
|
|
BindingRestrictions.GetTypeRestriction(Expression, typeof(ComTypeClassDesc))
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|