2016-03-30 14:20:52 -07:00
|
|
|
/********************************************************************++
|
|
|
|
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
--********************************************************************/
|
|
|
|
|
|
|
|
|
|
#if !SILVERLIGHT
|
|
|
|
|
|
|
|
|
|
#if !CLR2
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
#else
|
|
|
|
|
using Microsoft.Scripting.Ast;
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-07-29 13:02:49 -07:00
|
|
|
namespace System.Management.Automation.ComInterop
|
|
|
|
|
{
|
|
|
|
|
internal class ConvertArgBuilder : SimpleArgBuilder
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
private readonly Type _marshalType;
|
|
|
|
|
|
|
|
|
|
internal ConvertArgBuilder(Type parameterType, Type marshalType)
|
2016-07-29 13:02:49 -07:00
|
|
|
: base(parameterType)
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
_marshalType = marshalType;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-29 13:02:49 -07:00
|
|
|
internal override Expression Marshal(Expression parameter)
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
parameter = base.Marshal(parameter);
|
|
|
|
|
return Expression.Convert(parameter, _marshalType);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-29 13:02:49 -07:00
|
|
|
internal override Expression UnmarshalFromRef(Expression newValue)
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
return base.UnmarshalFromRef(Expression.Convert(newValue, ParameterType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|