本文整理汇总了C#中System.Dynamic.DynamicMetaObject.GetLimitType方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicMetaObject.GetLimitType方法的具体用法?C# DynamicMetaObject.GetLimitType怎么用?C# DynamicMetaObject.GetLimitType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Dynamic.DynamicMetaObject
的用法示例。
在下文中一共展示了DynamicMetaObject.GetLimitType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertTo
public DynamicMetaObject ConvertTo(Type toType, ConversionResultKind kind, DynamicMetaObject arg, OverloadResolverFactory resolverFactory, DynamicMetaObject errorSuggestion) {
ContractUtils.RequiresNotNull(toType, "toType");
ContractUtils.RequiresNotNull(arg, "arg");
Type knownType = arg.GetLimitType();
// try all the conversions - first look for conversions against the expression type,
// these can be done w/o any additional tests. Then look for conversions against the
// restricted type.
BindingRestrictions typeRestrictions = arg.Restrictions.Merge(BindingRestrictionsHelpers.GetRuntimeTypeRestriction(arg.Expression, arg.GetLimitType()));
DynamicMetaObject res =
TryConvertToObject(toType, arg.Expression.Type, arg, typeRestrictions) ??
TryAllConversions(resolverFactory, toType, kind, arg.Expression.Type, typeRestrictions, arg) ??
TryAllConversions(resolverFactory, toType, kind, arg.GetLimitType(), typeRestrictions, arg) ??
errorSuggestion ??
MakeErrorTarget(toType, kind, typeRestrictions, arg);
if ((kind == ConversionResultKind.ExplicitTry || kind == ConversionResultKind.ImplicitTry) && toType.IsValueType) {
res = new DynamicMetaObject(
AstUtils.Convert(
res.Expression,
typeof(object)
),
res.Restrictions
);
}
return res;
}
示例2: MakeDeleteMemberTarget
private DynamicMetaObject MakeDeleteMemberTarget(SetOrDeleteMemberInfo delInfo, DynamicMetaObject target, DynamicMetaObject errorSuggestion) {
Type type = target.GetLimitType();
BindingRestrictions restrictions = target.Restrictions;
DynamicMetaObject self = target;
if (typeof(TypeTracker).IsAssignableFrom(type)) {
restrictions = restrictions.Merge(
BindingRestrictions.GetInstanceRestriction(target.Expression, target.Value)
);
type = ((TypeTracker)target.Value).Type;
self = null;
}
delInfo.Body.Restrictions = restrictions;
if (self == null || !MakeOperatorDeleteMemberBody(delInfo, self, type, "DeleteMember")) {
MemberGroup group = GetMember(MemberRequestKind.Delete, type, delInfo.Name);
if (group.Count != 0) {
if (group[0].MemberType == TrackerTypes.Property) {
MethodInfo del = ((PropertyTracker)group[0]).GetDeleteMethod(PrivateBinding);
if (del != null) {
MakePropertyDeleteStatement(delInfo, self, del);
return delInfo.Body.GetMetaObject(target);
}
}
delInfo.Body.FinishCondition(errorSuggestion ?? MakeError(MakeUndeletableMemberError(GetDeclaringMemberType(group), delInfo.Name), typeof(void)));
} else {
delInfo.Body.FinishCondition(errorSuggestion ?? MakeError(MakeMissingMemberErrorForDelete(type, self, delInfo.Name), typeof(void)));
}
}
return delInfo.Body.GetMetaObject(target);
}
示例3: GetPythonType
public static PythonType/*!*/ GetPythonType(DynamicMetaObject/*!*/ value) {
if (value.HasValue) {
return DynamicHelpers.GetPythonType(value.Value);
}
return DynamicHelpers.GetPythonTypeFromType(value.GetLimitType());
}
示例4: Call
/// <summary>
/// Provides default binding for performing a call on the specified meta objects.
/// </summary>
/// <param name="signature">The signature describing the call</param>
/// <param name="target">The meta object to be called.</param>
/// <param name="args">
/// Additional meta objects are the parameters for the call as specified by the CallSignature in the CallAction.
/// </param>
/// <param name="resolverFactory">Overload resolver factory.</param>
/// <param name="errorSuggestion">The result should the object be uncallable.</param>
/// <returns>A MetaObject representing the call or the error.</returns>
public DynamicMetaObject Call(CallSignature signature, DynamicMetaObject errorSuggestion, OverloadResolverFactory resolverFactory,ClrMethod method, DynamicMetaObject target, params DynamicMetaObject[] args)
{
ContractUtils.RequiresNotNullItems(args, "args");
ContractUtils.RequiresNotNull(resolverFactory, "resolverFactory");
TargetInfo targetInfo = GetTargetInfo(method, target, args);
if (targetInfo != null)
{
// we're calling a well-known MethodBase
DynamicMetaObject res = MakeMetaMethodCall(signature, resolverFactory, targetInfo);
if (res.Expression.Type.IsValueType)
{
if (res.Expression.Type == Types.Void)
res = new DynamicMetaObject(
Expression.Block(Types.Object[0],
res.Expression,
Expression.Constant(null)),
res.Restrictions
);
else
res = new DynamicMetaObject(
Expression.Convert(res.Expression, typeof(object)),
res.Restrictions
);
}
return res;
}
else
{
// we can't call this object
return errorSuggestion ?? MakeCannotCallRule(target, target.GetLimitType());
}
}
示例5: Call
internal static DynamicMetaObject Call(DynamicMetaObjectBinder call, DynamicMetaObject target, DynamicMetaObject[] args)
{
Assert.NotNull(call, args);
Assert.NotNullItems(args);
if (target.NeedsDeferral())
return call.Defer(ArrayUtils.Insert(target, args));
foreach (var mo in args)
{
if (mo.NeedsDeferral())
{
RestrictTypes(args);
return call.Defer(
ArrayUtils.Insert(target, args)
);
}
}
DynamicMetaObject self = target.Restrict(target.GetLimitType());
ValidationInfo valInfo = BindingHelpers.GetValidationInfo(target);
TotemType tt = DynamicHelpers.GetTotemType(target.Value);
TotemContext toContext = GetTotemContext(call);
throw new NotImplementedException();
}
示例6: ConvertTo
public DynamicMetaObject ConvertTo(Type toType, ConversionResultKind kind, DynamicMetaObject arg) {
ContractUtils.RequiresNotNull(toType, "toType");
ContractUtils.RequiresNotNull(arg, "arg");
Type knownType = arg.GetLimitType();
// try all the conversions - first look for conversions against the expression type,
// these can be done w/o any additional tests. Then look for conversions against the
// restricted type.
BindingRestrictions typeRestrictions = arg.Restrictions.Merge(BindingRestrictionsHelpers.GetRuntimeTypeRestriction(arg.Expression, arg.GetLimitType()));
return
TryConvertToObject(toType, arg.Expression.Type, arg) ??
TryAllConversions(toType, kind, arg.Expression.Type, arg.Restrictions, arg) ??
TryAllConversions(toType, kind, arg.GetLimitType(), typeRestrictions, arg) ??
MakeErrorTarget(toType, kind, typeRestrictions, arg);
}
示例7: GetTotemType
public static TotemType GetTotemType(DynamicMetaObject value)
{
if (value.HasValue)
{
return DynamicHelpers.GetTotemType(value.Value);
}
return DynamicHelpers.GetTotemType(value.GetLimitType());
}
示例8: DeleteMember
public DynamicMetaObject DeleteMember(string name, DynamicMetaObject target, OverloadResolverFactory resolutionFactory) {
ContractUtils.RequiresNotNull(name, "name");
ContractUtils.RequiresNotNull(target, "target");
return MakeDeleteMemberTarget(
new SetOrDeleteMemberInfo(
name,
resolutionFactory
),
target.Restrict(target.GetLimitType())
);
}
示例9: MakeSetMemberTarget
private DynamicMetaObject MakeSetMemberTarget(SetOrDeleteMemberInfo memInfo, DynamicMetaObject target, DynamicMetaObject value) {
Type type = target.GetLimitType();
Expression self = target.Expression;
target = target.Restrict(target.GetLimitType());
memInfo.Body.Restrictions = target.Restrictions;
if (typeof(TypeTracker).IsAssignableFrom(type)) {
type = ((TypeTracker)target.Value).Type;
self = null;
memInfo.Body.Restrictions = memInfo.Body.Restrictions.Merge(
BindingRestrictions.GetInstanceRestriction(target.Expression, target.Value)
);
}
MakeSetMemberRule(memInfo, type, self, value);
return memInfo.Body.GetMetaObject(target, value);
}
示例10: DeleteMember
public DynamicMetaObject DeleteMember(string name, DynamicMetaObject target, Expression codeContext) {
ContractUtils.RequiresNotNull(name, "name");
ContractUtils.RequiresNotNull(target, "target");
return MakeDeleteMemberTarget(
new SetOrDeleteMemberInfo(
name,
codeContext
),
target.Restrict(target.GetLimitType())
);
}
示例11: Call
/// <summary>
/// Provides default binding for performing a call on the specified meta objects.
/// </summary>
/// <param name="signature">The signature describing the call</param>
/// <param name="target">The meta object to be called.</param>
/// <param name="args">
/// Additional meta objects are the parameters for the call as specified by the CallSignature in the CallAction.
/// </param>
/// <param name="resolverFactory">Overload resolver factory.</param>
/// <returns>A MetaObject representing the call or the error.</returns>
public DynamicMetaObject Call(CallSignature signature, OverloadResolverFactory resolverFactory, DynamicMetaObject target, params DynamicMetaObject[] args) {
ContractUtils.RequiresNotNullItems(args, "args");
ContractUtils.RequiresNotNull(resolverFactory, "resolverFactory");
TargetInfo targetInfo = GetTargetInfo(signature, target, args);
if (targetInfo != null) {
// we're calling a well-known MethodBase
return MakeMetaMethodCall(signature, resolverFactory, targetInfo);
} else {
// we can't call this object
return MakeCannotCallRule(target, target.GetLimitType());
}
}
示例12: MakeDeleteMemberTarget
private DynamicMetaObject MakeDeleteMemberTarget(SetOrDeleteMemberInfo delInfo, DynamicMetaObject target) {
Type type = target.GetLimitType();
BindingRestrictions restrictions = target.Restrictions;
Expression self = target.Expression;
// needed for DeleteMember call until DynamicAction goes away
OldDynamicAction act = OldDeleteMemberAction.Make(
this,
delInfo.Name
);
if (typeof(TypeTracker).IsAssignableFrom(type)) {
restrictions = restrictions.Merge(
BindingRestrictions.GetInstanceRestriction(target.Expression, target.Value)
);
type = ((TypeTracker)target.Value).Type;
self = null;
}
delInfo.Body.Restrictions = restrictions;
if (self == null || !MakeOperatorDeleteMemberBody(delInfo, self, type, "DeleteMember")) {
MemberGroup group = GetMember(act, type, delInfo.Name);
if (group.Count != 0) {
if (group[0].MemberType == TrackerTypes.Property) {
MethodInfo del = ((PropertyTracker)group[0]).GetDeleteMethod(PrivateBinding);
if (del != null) {
MakePropertyDeleteStatement(delInfo, self, del);
return delInfo.Body.GetMetaObject(target);
}
}
delInfo.Body.FinishCondition(MakeError(MakeUndeletableMemberError(GetDeclaringMemberType(group), delInfo.Name)));
} else {
delInfo.Body.FinishCondition(MakeError(MakeMissingMemberError(type, delInfo.Name)));
}
}
return delInfo.Body.GetMetaObject(target);
}
示例13: Call
/// <summary>
/// Provides default binding for performing a call on the specified meta objects.
/// </summary>
/// <param name="signature">The signature describing the call</param>
/// <param name="target">The meta object to be called.</param>
/// <param name="args">
/// Additional meta objects are the parameters for the call as specified by the CallSignature in the CallAction.
/// </param>
/// <param name="resolverFactory">Overload resolver factory.</param>
/// <returns>A MetaObject representing the call or the error.</returns>
public DynamicMetaObject Call(CallSignature signature, OverloadResolverFactory resolverFactory, DynamicMetaObject target, params DynamicMetaObject[] args) {
ContractUtils.RequiresNotNullItems(args, "args");
ContractUtils.RequiresNotNull(resolverFactory, "resolverFactory");
TargetInfo targetInfo = GetTargetInfo(target, args);
if (targetInfo != null) {
// we're calling a well-known MethodBase
DynamicMetaObject res = MakeMetaMethodCall(signature, resolverFactory, targetInfo);
if (res.Expression.Type.IsValueType) {
res = new DynamicMetaObject(
AstUtils.Convert(res.Expression, typeof(object)),
res.Restrictions
);
}
return res;
} else {
// we can't call this object
return MakeCannotCallRule(target, target.GetLimitType());
}
}
示例14: MakeCallSignatureResult
private static DynamicMetaObject MakeCallSignatureResult(MethodBase[] methods, DynamicMetaObject target) {
List<string> arrres = new List<string>();
if (methods != null) {
foreach (MethodBase mb in methods) {
StringBuilder res = new StringBuilder();
string comma = "";
foreach (ParameterInfo param in mb.GetParameters()) {
res.Append(comma);
res.Append(param.ParameterType.Name);
res.Append(" ");
res.Append(param.Name);
comma = ", ";
}
arrres.Add(res.ToString());
}
}
return new DynamicMetaObject(
AstUtils.Constant(arrres.ToArray()),
BindingRestrictionsHelpers.GetRuntimeTypeRestriction(target.Expression, target.GetLimitType()).Merge(target.Restrictions)
);
}
示例15: TryInvertedComparison
private DynamicMetaObject TryInvertedComparison(OperatorInfo info, OverloadResolverFactory resolverFactory, DynamicMetaObject target, DynamicMetaObject[] args) {
ExpressionType revOp = GetInvertedOperator(info.Operator);
OperatorInfo revInfo = OperatorInfo.GetOperatorInfo(revOp);
Debug.Assert(revInfo != null);
// try the 1st type's opposite function result negated
MethodBase[] targets = GetApplicableMembers(target.GetLimitType(), revInfo);
if (targets.Length > 0) {
return TryMakeInvertedBindingTarget(resolverFactory, targets, args);
}
return null;
}