本文整理汇总了C#中System.Dynamic.GetMemberBinder.FallbackGetMember方法的典型用法代码示例。如果您正苦于以下问题:C# GetMemberBinder.FallbackGetMember方法的具体用法?C# GetMemberBinder.FallbackGetMember怎么用?C# GetMemberBinder.FallbackGetMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Dynamic.GetMemberBinder
的用法示例。
在下文中一共展示了GetMemberBinder.FallbackGetMember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
var binderDefault = binder.FallbackGetMember(this);
var expression = Expression.Convert(GetMemberAccessExpression(binder.Name), typeof(object));
var dynamicSuggestion = new DynamicMetaObject(expression, BindingRestrictions.GetTypeRestriction(Expression, LimitType)
.Merge(binderDefault.Restrictions));
return binder.FallbackGetMember(this, dynamicSuggestion);
}
示例2: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
ContractUtils.RequiresNotNull(binder, "binder");
string name = binder.Name;
if (name == _info.Name) {
name = "TypeLibDesc";
} else if (name != "Guid" &&
name != "Name" &&
name != "VersionMajor" &&
name != "VersionMinor") {
return binder.FallbackGetMember(this);
}
return new DynamicMetaObject(
Expression.Convert(
Expression.Property(
AstUtils.Convert(Expression, typeof(ComTypeLibInfo)),
typeof(ComTypeLibInfo).GetProperty(name)
),
typeof(object)
),
ComTypeLibInfoRestrictions(this)
);
}
示例3: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
ContractUtils.RequiresNotNull(binder, "binder");
return binder.FallbackGetMember(UnwrapSelf());
}
示例4: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
if (IsOverridden("TryGetMember")) {
return CallMethodWithResult("TryGetMember", binder, NoArgs, (e) => binder.FallbackGetMember(this, e));
}
return base.BindGetMember(binder);
}
示例5: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
var flags = BindingFlags.IgnoreCase | BindingFlags.Static |
BindingFlags.Public;
// consider BindingFlags.Instance if want to return wrapper for
// inst members that is callable.
var members = ReflType.GetMember(binder.Name, flags);
if (members.Length == 1) {
return new DynamicMetaObject(
// We always access static members for type model objects, so the
// first argument in MakeMemberAccess should be null.
RuntimeHelpers.EnsureObjectResult(
Expression.MakeMemberAccess(
null,
members[0])),
// Don't need restriction test for name since this
// rule is only used where binder is used, which is
// only used in sites with this binder.Name.
this.Restrictions.Merge(
BindingRestrictions.GetInstanceRestriction(
this.Expression,
this.Value)
)
);
} else {
return binder.FallbackGetMember(this);
}
}
示例6: BindGetMember
/// <summary>
/// Performs the binding of the dynamic get member operation.
/// </summary>
/// <param name="binder">An instance of the <see cref="GetMemberBinder"/> that represents the details of the dynamic operation.</param>
/// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
public virtual DynamicMetaObject BindGetMember(GetMemberBinder binder) {
ContractUtils.RequiresNotNull(binder, "binder");
return binder.FallbackGetMember(this);
}
示例7: BindGetMember
public override DynamicMetaObject/*!*/ BindGetMember(GetMemberBinder/*!*/ binder) {
var self = (IRubyObject)Value;
return RubyGetMemberBinder.TryBind(self.Class.Context, binder, this) ?? binder.FallbackGetMember(this);
}
示例8: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
{
var prop = _type.GetProperty(binder.Name);
if (prop != null && prop.Methods != null && prop.CompiledMethods == null)
prop.CompiledMethods = _type.MakeCompileMethods(binder.Name);
if (prop != null && prop.CompiledMethods != null)
{
var ret = prop.CompiledMethods(this);
if (ret != null)
return ret;
}
if (prop != null && prop.Getters != null)
{
foreach (var getter in prop.Getters)
{
var ret = getter(this);
if (ret != null)
{
return ret;
}
}
}
ITotemProperty totemProp;
if(_type._customProperties.TryGetValue(binder.Name, out totemProp))
{
return new DynamicMetaObject(
AstUtils.SimpleCallHelper(
Expression.Constant(totemProp, typeof(ITotemProperty)),
typeof(ITotemProperty).GetMethod("Get"),
Expression
),
BindingRestrictions.GetTypeRestriction(Expression, LimitType)
);
}
DynamicMetaObject result;
if (_type.HandleGetMember(binder, this, out result))
return result;
var fallback = binder.FallbackGetMember(this, result);
BindingRestrictions restrictions = fallback.Restrictions.Merge(BindingRestrictions.GetTypeRestriction(Expression, LimitType));
return new DynamicMetaObject(
AssertImplemented(
Expression.Call(
Expression.Constant(_type, typeof(TotemType)),
TotemType.GetMissingPropertyInfo,
Expression,
Expression.Constant(binder.Name, typeof(string))
),
fallback.Expression
),
restrictions
);
}
示例9: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
ContractUtils.RequiresNotNull(binder, "binder");
DynamicMetaObject memberValue = GetDynamicMetaObjectForMember(
binder.Name,
binder.IgnoreCase,
binder.FallbackGetMember(this)
);
return AddDynamicTestAndDefer(
binder,
new DynamicMetaObject[] { this },
Value.Class,
null,
memberValue
);
}
示例10: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
{
return DynamicTryGetMember(binder.Name,
binder.FallbackGetMember(this).Expression,
(tmp) => tmp
);
}
示例11: typeof
public override DynamicMetaObject BindGetMember
(GetMemberBinder binder)
{
var self = this.Expression;
var bag = (FastNBag)base.Value;
int index = bag.GetFastIndex(binder.Name);
Expression target;
// If match found in fast array:
if (index != -1)
{
// Fetch result from fast array.
target =
Expression.Call(
Expression.Convert(self, typeof(FastNBag)),
typeof(FastNBag).GetMethod("GetFastValue"),
Expression.Constant(index)
);
}
// Else, if no match found in fast array, but fast array is full:
else if (bag.fastTable.Count == bag.fastCount)
{
// Fetch result from dictionary.
var keyExpr = Expression.Constant(binder.Name);
var valueExpr = Expression.Variable(typeof(object));
var dictCheckExpr =
Expression.Call(
Expression.Convert(self, typeof(FastNBag)),
typeof(FastNBag).GetMethod("TryGetValue"),
keyExpr,
valueExpr
);
var dictFailExpr =
Expression.Block(
binder.FallbackGetMember(this).Expression,
Expression.Default(typeof(object))
);
target =
Expression.Block(
new[] { valueExpr },
Expression.Condition(
dictCheckExpr,
valueExpr,
dictFailExpr
)
);
}
// Else, no match found in fast array, fast array is not yet full:
else
{
// Fail binding, but only until fast array is updated.
var versionCheckExpr =
Expression.Call(
Expression.Convert(self, typeof(FastNBag)),
typeof(FastNBag).GetMethod("CheckVersion"),
Expression.Constant(bag.Version)
);
var versionMatchExpr =
binder.FallbackGetMember(this).Expression;
var updateExpr =
binder.GetUpdateExpression(versionMatchExpr.Type);
target =
Expression.Condition(
versionCheckExpr,
versionMatchExpr,
updateExpr
);
}
var restrictions = BindingRestrictions
.GetInstanceRestriction(self, bag);
return new DynamicMetaObject(target, restrictions);
}
示例12: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
{
Fallback fallback = null;
if (!this.IsOverridden("TryGetMember"))
{
return base.BindGetMember(binder);
}
if (fallback == null)
{
fallback = e => binder.FallbackGetMember(this, e);
}
return this.CallMethodWithResult("TryGetMember", binder, NoArgs, fallback);
}
示例13: TryGetMember
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (this.UseFallbackMethod)
{
DynamicMetaObject target = new DynamicMetaObject(Expression.Parameter(this.GetType()), BindingRestrictions.Empty);
DynamicMetaObject errorSuggestion = null;
if (this.UseErrorSuggestion)
{
errorSuggestion = new DynamicMetaObject(Expression.Throw(Expression.Constant(new TestDynamicObjectException())), BindingRestrictions.Empty);
}
DynamicMetaObject metaObj = binder.FallbackGetMember(target, errorSuggestion);
Expression<Action> lambda = Expression.Lambda<Action>(metaObj.Expression, new ParameterExpression[] { });
lambda.Compile().Invoke();
}
return _values.TryGetValue(binder.Name, out result);
}
示例14: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
var tmp = Expression.Parameter(typeof(object));
return new DynamicMetaObject(
Expression.Block(
new[] { tmp },
Expression.Condition(
Expression.NotEqual(
Expression.Assign(
tmp,
Expression.Invoke(
Expression.Constant(new Func<object, SymbolId, object>(AttributesAdapter.TryGetMember)),
Expression,
Expression.Constant(SymbolTable.StringToId(binder.Name))
)
),
Expression.Constant(_getFailed)
),
tmp,
Expression.Convert(binder.FallbackGetMember(this).Expression, typeof(object))
)
),
GetRestrictions()
);
}
示例15: BindGetMember
public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
{
return binder.FallbackGetMember(UnwrapSelf());
}