CSharpConvertBinder
using System;
using System.Dynamic;
namespace Microsoft.CSharp.RuntimeBinder
{
internal sealed class CSharpConvertBinder : ConvertBinder
{
private CSharpConversionKind _conversionKind;
private bool _isChecked;
private Type _callingContext;
private RuntimeBinder _binder;
internal CSharpConversionKind ConversionKind => _conversionKind;
internal bool IsChecked => _isChecked;
internal Type CallingContext => _callingContext;
public CSharpConvertBinder(Type type, CSharpConversionKind conversionKind, bool isChecked, Type callingContext)
: base(type, conversionKind == CSharpConversionKind.ExplicitConversion)
{
_conversionKind = conversionKind;
_isChecked = isChecked;
_callingContext = callingContext;
_binder = RuntimeBinder.GetInstance();
}
public override DynamicMetaObject FallbackConvert(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
{
return BinderHelper.Bind(this, _binder, new DynamicMetaObject[1] {
target
}, null, errorSuggestion);
}
}
}