本文整理汇总了C#中Microsoft.Scripting.Actions.MemberTracker类的典型用法代码示例。如果您正苦于以下问题:C# MemberTracker类的具体用法?C# MemberTracker怎么用?C# MemberTracker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberTracker类属于Microsoft.Scripting.Actions命名空间,在下文中一共展示了MemberTracker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MakeNonPublicMemberGetError
/// <summary>
/// Called when the user is accessing a protected or private member on a get.
///
/// The default implementation allows access to the fields or properties using reflection.
/// </summary>
public virtual ErrorInfo MakeNonPublicMemberGetError(OverloadResolverFactory resolverFactory, MemberTracker member, Type type, DynamicMetaObject instance) {
switch (member.MemberType) {
case TrackerTypes.Field:
FieldTracker ft = (FieldTracker)member;
return ErrorInfo.FromValueNoError(
Ast.Call(
AstUtils.Convert(AstUtils.Constant(ft.Field), typeof(FieldInfo)),
typeof(FieldInfo).GetMethod("GetValue"),
AstUtils.Convert(instance.Expression, typeof(object))
)
);
case TrackerTypes.Property:
PropertyTracker pt = (PropertyTracker)member;
return ErrorInfo.FromValueNoError(
MemberTracker.FromMemberInfo(pt.GetGetMethod(true)).Call(resolverFactory, this, instance).Expression
);
default:
throw new InvalidOperationException();
}
}
开发者ID:techarch,项目名称:ironruby,代码行数:27,代码来源:DefaultBinder.cs
示例2: MakeGenericBodyWorker
private void MakeGenericBodyWorker(GetMemberInfo getMemInfo, Type type, MemberTracker tracker, Expression instance) {
if (instance != null) {
tracker = tracker.BindToInstance(instance);
}
Expression val = tracker.GetValue(getMemInfo.CodeContext, this, type);
if (val != null) {
getMemInfo.Body.FinishCondition(val);
} else {
ErrorInfo ei = tracker.GetError(this);
if (ei.Kind != ErrorInfoKind.Success && getMemInfo.IsNoThrow) {
getMemInfo.Body.FinishCondition(MakeOperationFailed());
} else {
getMemInfo.Body.FinishCondition(MakeError(tracker.GetError(this), typeof(object)));
}
}
}
开发者ID:Hank923,项目名称:ironruby,代码行数:18,代码来源:DefaultBinder.GetMember.cs
示例3: IsTrackerApplicableForType
private static bool IsTrackerApplicableForType(Type type, MemberTracker mt) {
return mt.DeclaringType == type || type.IsSubclassOf(mt.DeclaringType);
}
开发者ID:Hank923,项目名称:ironruby,代码行数:3,代码来源:DefaultBinder.GetMember.cs
示例4: ReturnMemberTracker
/// <summary>
/// Provides an opportunity for languages to replace all MemberTracker's with their own type.
///
/// Alternatlely a language can expose MemberTracker's directly.
/// </summary>
/// <param name="memberTracker">The member which is being returned to the user.</param>
/// <param name="type">Tthe type which the memberTrack was accessed from</param>
/// <returns></returns>
public virtual DynamicMetaObject ReturnMemberTracker(Type type, MemberTracker memberTracker) {
if (memberTracker.MemberType == TrackerTypes.Bound) {
BoundMemberTracker bmt = (BoundMemberTracker)memberTracker;
return new DynamicMetaObject(
Expression.New(
typeof(BoundMemberTracker).GetConstructor(new[] { typeof(MemberTracker), typeof(object) }),
AstUtils.Constant(bmt.BoundTo),
bmt.Instance.Expression
),
BindingRestrictions.Empty
);
}
return new DynamicMetaObject(AstUtils.Constant(memberTracker), BindingRestrictions.Empty, memberTracker);
}
开发者ID:Jaykul,项目名称:IronLangs,代码行数:23,代码来源:ActionBinder.cs
示例5: TryGetValue
public bool TryGetValue(SymbolId name, out MemberTracker value) {
lock (_topPackage.HierarchyLock) {
LoadNamespaces();
if (_dict.TryGetValue(SymbolTable.IdToString(name), out value)) {
return true;
}
MemberTracker existingTypeEntity = null;
string nameString = SymbolTable.IdToString(name);
if (nameString.IndexOf(Type.Delimiter) != -1) {
value = null;
return false;
}
// Look up the type names and load the type if its name exists
foreach (KeyValuePair<Assembly, TypeNames> kvp in _typeNames) {
if (!kvp.Value.Contains(nameString)) {
continue;
}
existingTypeEntity = kvp.Value.UpdateTypeEntity((TypeTracker)existingTypeEntity, nameString);
}
if (existingTypeEntity == null) {
existingTypeEntity = CheckForUnlistedType(nameString);
}
if (existingTypeEntity != null) {
_dict[SymbolTable.IdToString(name)] = existingTypeEntity;
value = existingTypeEntity;
return true;
}
return false;
}
}
开发者ID:BenHall,项目名称:ironruby,代码行数:39,代码来源:NamespaceTracker.cs
示例6: ResolveMember
public override MemberGroup/*!*/ ResolveMember(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name) {
foreach (Type t in binder.GetContributingTypes(type)) {
MemberGroup res = new MemberGroup(ArrayUtils.FindAll(t.GetMember(name, BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy), ProtectedOnly));
for (int i = 0; i < res.Count; i++) {
MethodTracker meth = res[i] as MethodTracker;
if (meth == null) {
continue;
}
if (meth.Name == "Finalize" && meth.Method.GetBaseDefinition() == typeof(object).GetMethod("Finalize", BindingFlags.NonPublic | BindingFlags.Instance)) {
MemberTracker[] retained = new MemberTracker[res.Count - 1];
if (res.Count == 1) {
res = MemberGroup.EmptyGroup;
} else {
for (int j = 0; j < i; j++) {
retained[j] = res[j];
}
for (int j = i + 1; j < res.Count; j++) {
retained[j - 1] = res[j];
}
res = new MemberGroup(retained);
}
break;
}
}
res = FilterSpecialNames(res, name, action);
return GetBaseHelperOverloads(PythonTypeOps.GetFinalSystemType(type), name, res);
}
return MemberGroup.EmptyGroup;
}
开发者ID:m4dc4p,项目名称:ironruby,代码行数:33,代码来源:TypeInfo.cs
示例7: ReturnMemberTracker
private static Expression ReturnMemberTracker(Type type, MemberTracker memberTracker, bool privateBinding) {
switch (memberTracker.MemberType) {
case TrackerTypes.TypeGroup:
return Ast.Constant(memberTracker);
case TrackerTypes.Type:
return ReturnTypeTracker((TypeTracker)memberTracker);
case TrackerTypes.Bound:
return ReturnBoundTracker((BoundMemberTracker)memberTracker, privateBinding);
case TrackerTypes.Property:
return ReturnPropertyTracker((PropertyTracker)memberTracker, privateBinding);
case TrackerTypes.Event:
return Ast.Call(
typeof(PythonOps).GetMethod("MakeBoundEvent"),
Ast.Constant(PythonTypeOps.GetReflectedEvent((EventTracker)memberTracker)),
Ast.Constant(null),
Ast.Constant(type)
);
case TrackerTypes.Field:
return ReturnFieldTracker((FieldTracker)memberTracker);
case TrackerTypes.MethodGroup:
return ReturnMethodGroup((MethodGroup)memberTracker);
case TrackerTypes.Constructor:
MethodBase[] ctors = CompilerHelpers.GetConstructors(type, privateBinding, true);
object val;
if (PythonTypeOps.IsDefaultNew(ctors)) {
if (IsPythonType(type)) {
val = InstanceOps.New;
} else {
val = InstanceOps.NewCls;
}
} else {
val = PythonTypeOps.GetConstructor(type, InstanceOps.NonDefaultNewInst, ctors);
}
return Ast.Constant(val);
case TrackerTypes.Custom:
return Ast.Constant(((PythonCustomTracker)memberTracker).GetSlot(), typeof(PythonTypeSlot));
}
return null;
}
开发者ID:octavioh,项目名称:ironruby,代码行数:40,代码来源:PythonBinder.cs
示例8: MakeStaticAssignFromDerivedTypeError
public override ErrorInfo/*!*/ MakeStaticAssignFromDerivedTypeError(Type accessingType, MemberTracker info, Expression assignedValue, Expression context) {
return MakeMissingMemberError(accessingType, info.Name);
}
开发者ID:octavioh,项目名称:ironruby,代码行数:3,代码来源:PythonBinder.cs
示例9: ReturnMemberTracker
/// <summary>
/// Provides an opportunity for languages to replace all MemberInfo's with their own type.
///
/// Alternatlely a language can expose MemberInfo's directly.
/// </summary>
/// <param name="memberTracker">The member which is being returned to the user.</param>
/// <param name="type">Tthe type which the memberTrack was accessed from</param>
/// <returns></returns>
public virtual Expression ReturnMemberTracker(Type type, MemberTracker memberTracker) {
if (memberTracker.MemberType == TrackerTypes.Bound) {
BoundMemberTracker bmt = (BoundMemberTracker)memberTracker;
return Expression.New(
typeof(BoundMemberTracker).GetConstructor(new Type[] { typeof(MemberTracker), typeof(object) }),
AstUtils.Constant(bmt.BoundTo),
bmt.Instance);
}
return AstUtils.Constant(memberTracker);
}
开发者ID:jcteague,项目名称:ironruby,代码行数:19,代码来源:ActionBinder.cs
示例10: BoundMemberTracker
public BoundMemberTracker(MemberTracker tracker, object instance) {
_tracker = tracker;
_objInst = instance;
}
开发者ID:jschementi,项目名称:iron,代码行数:4,代码来源:BoundMemberTracker.cs
示例11: MakeGenericBody
private void MakeGenericBody(SetOrDeleteMemberInfo memInfo, DynamicMetaObject instance, DynamicMetaObject target, Type type, MemberTracker tracker, DynamicMetaObject errorSuggestion) {
if (instance != null) {
tracker = tracker.BindToInstance(instance);
}
DynamicMetaObject val = tracker.SetValue(memInfo.ResolutionFactory, this, type, target, errorSuggestion);
if (val != null) {
memInfo.Body.FinishCondition(val);
} else {
memInfo.Body.FinishCondition(
MakeError(tracker.GetError(this), typeof(object))
);
}
}
开发者ID:BrianGenisio,项目名称:ironruby,代码行数:15,代码来源:DefaultBinder.SetMember.cs
示例12: IsProtectedSetter
private bool IsProtectedSetter(MemberTracker mt) {
PropertyTracker pt = mt as PropertyTracker;
if (pt != null) {
MethodInfo mi = pt.GetSetMethod(true);
if (mi != null && (mi.IsFamily || mi.IsFamilyOrAssembly)) {
return true;
}
}
FieldTracker ft = mt as FieldTracker;
if (ft != null) {
return ft.Field.IsFamily || ft.Field.IsFamilyOrAssembly;
}
return false;
}
开发者ID:jcteague,项目名称:ironruby,代码行数:16,代码来源:MetaPythonType.Members.cs
示例13: BoundMemberTracker
public BoundMemberTracker(MemberTracker tracker, Expression instance) {
_tracker = tracker;
_instance = instance;
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:4,代码来源:BoundMemberTracker.cs
示例14: MakeGenericBodyWorker
private void MakeGenericBodyWorker(GetMemberInfo getMemInfo, Type type, MemberTracker tracker, DynamicMetaObject instance) {
if (instance != null) {
tracker = tracker.BindToInstance(instance);
}
DynamicMetaObject val = tracker.GetValue(getMemInfo.ResolutionFactory, this, type);
if (val != null) {
getMemInfo.Body.FinishCondition(val);
} else {
ErrorInfo ei = tracker.GetError(this);
if (ei.Kind != ErrorInfoKind.Success && getMemInfo.IsNoThrow) {
getMemInfo.Body.FinishError(MakeOperationFailed());
} else {
getMemInfo.Body.FinishError(MakeError(tracker.GetError(this), typeof(object)));
}
}
}
开发者ID:jschementi,项目名称:iron,代码行数:18,代码来源:DefaultBinder.GetMember.cs
示例15: ResolveMember
public override MemberGroup/*!*/ ResolveMember(MemberBinder/*!*/ binder, MemberRequestKind/*!*/ action, Type/*!*/ type, string/*!*/ name) {
foreach (Type t in binder.GetContributingTypes(type)) {
MemberGroup res = new MemberGroup(
t.GetMember(name, BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)
.Where(ProtectedOnly)
.ToArray());
for (int i = 0; i < res.Count; i++) {
MethodTracker meth = res[i] as MethodTracker;
if (meth == null) {
continue;
}
if (meth.Name == "Finalize" && meth.Method.GetBaseDefinition() == typeof(object).GetMethod("Finalize", BindingFlags.NonPublic | BindingFlags.Instance)) {
MemberTracker[] retained = new MemberTracker[res.Count - 1];
if (res.Count == 1) {
res = MemberGroup.EmptyGroup;
} else {
for (int j = 0; j < i; j++) {
retained[j] = res[j];
}
for (int j = i + 1; j < res.Count; j++) {
retained[j - 1] = res[j];
}
res = new MemberGroup(retained);
}
break;
}
}
return FilterSpecialNames(res, name, action);
}
return MemberGroup.EmptyGroup;
}
开发者ID:Jaykul,项目名称:IronLangs,代码行数:34,代码来源:PythonTypeInfo.cs
示例16: MakeNonPublicMemberGetError
public override ErrorInfo/*!*/ MakeNonPublicMemberGetError(Expression codeContext, MemberTracker member, Type type, Expression instance) {
if (PrivateBinding) {
return base.MakeNonPublicMemberGetError(codeContext, member, type, instance);
}
return ErrorInfo.FromValue(
BindingHelpers.TypeErrorForProtectedMember(type, member.Name)
);
}
开发者ID:octavioh,项目名称:ironruby,代码行数:9,代码来源:PythonBinder.cs
示例17: MakeGenericBodyWorker
private void MakeGenericBodyWorker(GetMemberInfo getMemInfo, Type type, MemberTracker tracker, Expression instance) {
if (instance != null) {
tracker = tracker.BindToInstance(instance);
}
Expression val = tracker.GetValue(getMemInfo.CodeContext, this, type);
getMemInfo.Body.FinishCondition(
val != null ?
val :
MakeError(tracker.GetError(this))
);
}
开发者ID:bclubb,项目名称:ironruby,代码行数:13,代码来源:DefaultBinder.GetMember.cs
示例18: MakeContainsGenericParametersError
public virtual ErrorInfo MakeContainsGenericParametersError(MemberTracker tracker) {
return ErrorInfo.FromException(
Expression.New(
typeof(InvalidOperationException).GetConstructor(new[] { typeof(string) }),
AstUtils.Constant(Strings.InvalidOperation_ContainsGenericParameters(tracker.DeclaringType.Name, tracker.Name))
)
);
}
开发者ID:Jaykul,项目名称:IronLangs,代码行数:8,代码来源:ActionBinder.cs
示例19: MakeGenericAccessError
public virtual ErrorInfo MakeGenericAccessError(MemberTracker info) {
return ErrorInfo.FromException(
Expression.New(
typeof(MemberAccessException).GetConstructor(new[] { typeof(string) }),
AstUtils.Constant(info.Name)
)
);
}
开发者ID:Jaykul,项目名称:IronLangs,代码行数:8,代码来源:ActionBinder.cs
示例20: MakeStaticAssignFromDerivedTypeError
/// <summary>
/// Called when a set is attempting to assign to a field or property from a derived class through the base class.
///
/// The default behavior is to allow the assignment.
/// </summary>
public virtual ErrorInfo MakeStaticAssignFromDerivedTypeError(Type accessingType, DynamicMetaObject self, MemberTracker assigning, DynamicMetaObject assignedValue, OverloadResolverFactory context) {
switch (assigning.MemberType) {
case TrackerTypes.Property:
PropertyTracker pt = (PropertyTracker)assigning;
MethodInfo setter = pt.GetSetMethod() ?? pt.GetSetMethod(true);
return ErrorInfo.FromValueNoError(
AstUtils.SimpleCallHelper(
setter,
ConvertExpression(
assignedValue.Expression,
setter.GetParameters()[0].ParameterType,
ConversionResultKind.ExplicitCast,
context
)
)
);
case TrackerTypes.Field:
FieldTracker ft = (FieldTracker)assigning;
return ErrorInfo.FromValueNoError(
Expression.Assign(
Expression.Field(null, ft.Field),
ConvertExpression(assignedValue.Expression, ft.FieldType, ConversionResultKind.ExplicitCast, context)
)
);
default:
throw new InvalidOperationException();
}
}
开发者ID:Jaykul,项目名称:IronLangs,代码行数:33,代码来源:ActionBinder.cs
注:本文中的Microsoft.Scripting.Actions.MemberTracker类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论