本文整理汇总了C#中MemberGroup类的典型用法代码示例。如果您正苦于以下问题:C# MemberGroup类的具体用法?C# MemberGroup怎么用?C# MemberGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberGroup类属于命名空间,在下文中一共展示了MemberGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ResolvedMember
public ResolvedMember(string/*!*/ name, MemberGroup/*!*/ member) {
Debug.Assert(name != null);
Debug.Assert(member != null);
Name = name;
Member = member;
}
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:7,代码来源:ResolvedMember.cs
示例2: GetDeclaringMemberType
private static Type GetDeclaringMemberType(MemberGroup group) {
Type t = typeof(object);
foreach (MemberTracker mt in group) {
if (t.IsAssignableFrom(mt.DeclaringType)) {
t = mt.DeclaringType;
}
}
return t;
}
开发者ID:apboyle,项目名称:ironruby,代码行数:9,代码来源:DefaultBinder.DeleteMember.cs
示例3: GetMethodGroup
public static MethodGroup GetMethodGroup(string name, MemberGroup mems)
{
MethodTracker[] trackers = new MethodTracker[mems.Count];
for (int i = 0; i < trackers.Length; i++) {
trackers[i] = (MethodTracker)mems[i];
}
return new MethodGroup(trackers);
}
开发者ID:TerabyteX,项目名称:main,代码行数:9,代码来源:ReflectionCache.cs
示例4: GetMethodGroup
public static MethodGroup GetMethodGroup(string name, MemberGroup mems) {
MethodGroup res = null;
MethodBase[] bases = new MethodBase[mems.Count];
MethodTracker[] trackers = new MethodTracker[mems.Count];
for (int i = 0; i < bases.Length; i++) {
trackers[i] = (MethodTracker)mems[i];
bases[i] = trackers[i].Method;
}
if (mems.Count != 0) {
MethodBaseCache cache = new MethodBaseCache(name, bases);
lock (_functions) {
if (!_functions.TryGetValue(cache, out res)) {
_functions[cache] = res = new MethodGroup(trackers);
}
}
}
return res;
}
开发者ID:apboyle,项目名称:ironruby,代码行数:21,代码来源:ReflectionCache.cs
示例5: MakePropertyRule
private void MakePropertyRule(SetOrDeleteMemberInfo memInfo, Expression instance, DynamicMetaObject target, Type targetType, MemberGroup properties) {
PropertyTracker info = (PropertyTracker)properties[0];
MethodInfo setter = info.GetSetMethod(true);
// Allow access to protected getters TODO: this should go, it supports IronPython semantics.
if (setter != null && !setter.IsPublic && !setter.IsProtected()) {
if (!PrivateBinding) {
setter = null;
}
}
if (setter != null) {
setter = CompilerHelpers.GetCallableMethod(setter, PrivateBinding);
if (info.IsStatic != (instance == null)) {
memInfo.Body.FinishCondition(
MakeError(
MakeStaticPropertyInstanceAccessError(
info,
true,
instance,
target.Expression
),
typeof(object)
)
);
} else if (info.IsStatic && info.DeclaringType != targetType) {
memInfo.Body.FinishCondition(
MakeError(
MakeStaticAssignFromDerivedTypeError(targetType, info, target.Expression, memInfo.CodeContext),
typeof(object)
)
);
} else if (setter.ContainsGenericParameters) {
memInfo.Body.FinishCondition(
MakeGenericPropertyExpression(memInfo)
);
} else if (setter.IsPublic && !setter.DeclaringType.IsValueType) {
if (instance == null) {
memInfo.Body.FinishCondition(
Ast.Block(
AstUtils.SimpleCallHelper(
setter,
ConvertExpression(
target.Expression,
setter.GetParameters()[0].ParameterType,
ConversionResultKind.ExplicitCast,
memInfo.CodeContext
)
),
Ast.Constant(null)
)
);
} else {
memInfo.Body.FinishCondition(
MakeReturnValue(
MakeCallExpression(memInfo.CodeContext, setter, instance, target.Expression),
target
)
);
}
} else {
// TODO: Should be able to do better w/ value types.
memInfo.Body.FinishCondition(
MakeReturnValue(
Ast.Call(
AstUtils.Constant(((ReflectedPropertyTracker)info).Property), // TODO: Private binding on extension properties
typeof(PropertyInfo).GetMethod("SetValue", new Type[] { typeof(object), typeof(object), typeof(object[]) }),
instance == null ? AstUtils.Constant(null) : AstUtils.Convert(instance, typeof(object)),
AstUtils.Convert(
ConvertExpression(
target.Expression,
setter.GetParameters()[0].ParameterType,
ConversionResultKind.ExplicitCast,
memInfo.CodeContext
),
typeof(object)
),
Ast.NewArrayInit(typeof(object))
),
target
)
);
}
} else {
memInfo.Body.FinishCondition(
MakeError(
MakeMissingMemberError(targetType, memInfo.Name), typeof(object)
)
);
}
}
开发者ID:Hank923,项目名称:ironruby,代码行数:93,代码来源:DefaultBinder.SetMember.cs
示例6: ResolveMember
public override MemberGroup/*!*/ ResolveMember(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name) {
if (binder.DomainManager.Configuration.PrivateBinding) {
// in private binding mode Python exposes private members under a mangled name.
string header = "_" + type.Name + "__";
if (name.StartsWith(header)) {
string memberName = name.Substring(header.Length);
MemberGroup res = new MemberGroup(type.GetMember(memberName, _privateFlags));
if (res.Count > 0) {
return FilterFieldAndEvent(res);
}
res = new MemberGroup(type.GetMember(memberName, BindingFlags.FlattenHierarchy | _privateFlags));
if (res.Count > 0) {
return FilterFieldAndEvent(res);
}
}
}
return MemberGroup.EmptyGroup;
}
开发者ID:m4dc4p,项目名称:ironruby,代码行数:21,代码来源:TypeInfo.cs
示例7: GetBaseHelperOverloads
/// <summary>
/// Gets the base helper methods generated by NewTypeMaker for the specified method name in the given type.
///
/// These base helper methods just do a return base.Whatever(*args) so that we can issue super calls from
/// users subclasses.
/// </summary>
private static MemberGroup/*!*/ GetBaseHelperOverloads(Type/*!*/ type, string/*!*/ name, MemberGroup/*!*/ res) {
// we only get base methods when we're looking for a type from a normal .NET type. If it's a NewTypeMaker
// type then we don't want them as we'll bind to the NewTypeMaker methods which override the base helper
// methods.
if (res.Count > 0 && PythonTypeOps.GetFinalSystemType(type) == type) {
List<MemberTracker> newMembers = null;
IList<MethodInfo> overriddenMethods = NewTypeMaker.GetOverriddenMethods(type, name);
if (overriddenMethods.Count > 0) {
if (newMembers == null) {
newMembers = new List<MemberTracker>();
}
foreach (MethodInfo mi in overriddenMethods) {
newMembers.Add(MemberTracker.FromMemberInfo(mi));
}
}
IList<ExtensionPropertyTracker> overriddenProperties = NewTypeMaker.GetOverriddenProperties(type, name);
if (overriddenProperties.Count > 0) {
if (newMembers == null) {
newMembers = new List<MemberTracker>();
}
foreach (ExtensionPropertyTracker tracker in overriddenProperties) {
newMembers.Add(tracker);
}
}
if (newMembers != null) {
newMembers.InsertRange(0, res);
res = new MemberGroup(newMembers.ToArray());
}
}
return res;
}
开发者ID:m4dc4p,项目名称:ironruby,代码行数:43,代码来源:TypeInfo.cs
示例8: FilterSpecialNames
private static MemberGroup/*!*/ FilterSpecialNames(MemberGroup/*!*/ group, string/*!*/ name, OldDynamicAction/*!*/ action) {
Assert.NotNull(group, name, action);
bool filter = true;
if (action.Kind == DynamicActionKind.Call ||
action.Kind == DynamicActionKind.ConvertTo ||
action.Kind == DynamicActionKind.DoOperation) {
filter = false;
}
if (!IsPythonRecognizedOperator(name)) {
filter = false;
}
List<MemberTracker> mts = null;
for (int i = 0; i < group.Count; i++) {
MemberTracker mt = group[i];
bool skip = false;
if (mt.MemberType == TrackerTypes.Method) {
MethodTracker meth = (MethodTracker)mt;
if (meth.Method.IsSpecialName && mt.Name != "op_Implicit" && mt.Name != "op_Explicit") {
if (!IsPropertyWithParameters(meth)) {
skip = true;
}
}
if (meth.Method.IsDefined(typeof(ClassMethodAttribute), true)) {
return new MemberGroup(new ClassMethodTracker(group));
}
} else if (mt.MemberType == TrackerTypes.Property) {
PropertyTracker pt = (PropertyTracker)mt;
if (name == pt.Name && pt.GetIndexParameters().Length > 0 && IsPropertyDefaultMember(pt)) {
// exposed via __*item__, not the property name
skip = true;
}
} else if (mt.MemberType == TrackerTypes.Field) {
FieldInfo fi = ((FieldTracker)mt).Field;
if (fi.IsDefined(typeof(SlotFieldAttribute), false)) {
if (mts == null) {
mts = MakeListWithPreviousMembers(group, mts, i);
mt = new CustomAttributeTracker(mt.DeclaringType, mt.Name, (PythonTypeSlot)fi.GetValue(null));
}
}
}
if (skip && filter) {
if (mts == null) {
// add any ones we skipped...
mts = MakeListWithPreviousMembers(group, mts, i);
}
} else if (mts != null) {
mts.Add(mt);
}
}
if (mts != null) {
if (mts.Count == 0) {
return MemberGroup.EmptyGroup;
}
return new MemberGroup(mts.ToArray());
}
return group;
}
开发者ID:m4dc4p,项目名称:ironruby,代码行数:65,代码来源:TypeInfo.cs
示例9: FilterFieldAndEvent
/// <summary>
/// When private binding is enabled we can have a collision between the private Event
/// and private field backing the event. We filter this out and favor the event.
///
/// This matches the v1.0 behavior of private binding.
/// </summary>
private static MemberGroup/*!*/ FilterFieldAndEvent(MemberGroup/*!*/ members) {
Debug.Assert(members != null);
TrackerTypes mt = TrackerTypes.None;
foreach (MemberTracker mi in members) {
mt |= mi.MemberType;
}
if (mt == (TrackerTypes.Event | TrackerTypes.Field)) {
List<MemberTracker> res = new List<MemberTracker>();
foreach (MemberTracker mi in members) {
if (mi.MemberType == TrackerTypes.Event) {
res.Add(mi);
}
}
return new MemberGroup(res.ToArray());
}
return members;
}
开发者ID:m4dc4p,项目名称:ironruby,代码行数:25,代码来源:TypeInfo.cs
示例10: MakeAmbiguousMatchError
private static Expression MakeAmbiguousMatchError(MemberGroup members) {
StringBuilder sb = new StringBuilder();
foreach (MemberTracker mi in members) {
if (sb.Length != 0) sb.Append(", ");
sb.Append(mi.MemberType);
sb.Append(" : ");
sb.Append(mi.ToString());
}
return Ast.Throw(
Ast.New(
typeof(AmbiguousMatchException).GetConstructor(new Type[] { typeof(string) }),
AstUtils.Constant(sb.ToString())
)
);
}
开发者ID:jcteague,项目名称:ironruby,代码行数:16,代码来源:DefaultBinder.cs
示例11: MakeEventValidation
public override ErrorInfo/*!*/ MakeEventValidation(MemberGroup/*!*/ members, Expression eventObject, Expression/*!*/ value, Expression/*!*/ codeContext) {
EventTracker ev = (EventTracker)members[0];
return ErrorInfo.FromValueNoError(
Ast.Call(
typeof(PythonOps).GetMethod("SlotTrySetValue"),
codeContext,
Ast.Constant(PythonTypeOps.GetReflectedEvent(ev)),
eventObject != null ? AstUtils.Convert(eventObject, typeof(object)) : Ast.Constant(null),
Ast.Constant(null, typeof(PythonType)),
AstUtils.Convert(value, typeof(object))
)
);
}
开发者ID:octavioh,项目名称:ironruby,代码行数:14,代码来源:PythonBinder.cs
示例12: FilterNonMethods
private static MethodInfo[] FilterNonMethods(Type t, MemberGroup members) {
Assert.NotNull(t, members);
List<MethodInfo> methods = new List<MethodInfo>(members.Count);
foreach (MemberTracker mi in members) {
if (mi.MemberType == TrackerTypes.Method) {
MethodInfo method = ((MethodTracker)mi).Method;
// don't call object methods for DynamicNull type, but if someone added
// methods to null we'd call those.
if (method.DeclaringType != typeof(object) || t != typeof(DynamicNull)) {
methods.Add(method);
}
}
}
return methods.ToArray();
}
开发者ID:apboyle,项目名称:ironruby,代码行数:18,代码来源:DefaultBinder.Operations.cs
示例13: 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
示例14: FilterAlternateMethods
/// <summary>
/// Filters alternative methods out that don't match the expected signature and therefore
/// are just sharing a common method name.
/// </summary>
private static MemberGroup FilterAlternateMethods(OperatorMapping opInfo, MemberGroup res) {
if (res.Count > 0 && opInfo.AlternateExpectedType != null) {
List<MemberTracker> matchingMethods = new List<MemberTracker>();
for (int i = 0; i < res.Count; i++) {
MemberTracker mt = res[i];
if (mt.MemberType == TrackerTypes.Method &&
((MethodTracker)mt).Method.ReturnType == opInfo.AlternateExpectedType) {
matchingMethods.Add(mt);
}
}
if (matchingMethods.Count == 0) {
res = MemberGroup.EmptyGroup;
} else {
res = new MemberGroup(matchingMethods.ToArray());
}
}
return res;
}
开发者ID:Jaykul,项目名称:IronLangs,代码行数:23,代码来源:PythonTypeInfo.cs
示例15: GetMember
protected MemberGroup/*!*/ GetMember(Type/*!*/ type, string/*!*/ name, BindingFlags flags) {
Assert.NotNull(type, name);
IEnumerable<MemberInfo> foundMembers = type.GetMember(name, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | flags);
if (!Binder.DomainManager.Configuration.PrivateBinding) {
foundMembers = CompilerHelpers.FilterNonVisibleMembers(type, foundMembers);
}
MemberInfo[] foundMembersArray = foundMembers.ToArray();
List<MemberInfo> filteredMembers = null;
for (int i = 0; i < foundMembersArray.Length; i++) {
var member = foundMembersArray[i];
if (member.DeclaringType.GetTypeInfo().IsDefined(typeof(PythonHiddenBaseClassAttribute), false)) {
if (filteredMembers == null) {
filteredMembers = new List<MemberInfo>();
for (int j = 0; j < i; j++) {
filteredMembers.Add(foundMembersArray[j]);
}
}
} else if (filteredMembers != null) {
filteredMembers.Add(foundMembersArray[i]);
}
}
if (filteredMembers != null) {
foundMembers = filteredMembers.ToArray();
}
MemberGroup members = new MemberGroup(foundMembersArray);
// check for generic types w/ arity...
Type[] types = type.GetNestedTypes(BindingFlags.Public | flags);
string genName = name + ReflectionUtils.GenericArityDelimiter;
List<Type> genTypes = null;
foreach (Type t in types) {
if (t.Name.StartsWith(genName)) {
if (genTypes == null) genTypes = new List<Type>();
genTypes.Add(t);
}
}
if (genTypes != null) {
List<MemberTracker> mt = new List<MemberTracker>(members);
foreach (Type t in genTypes) {
mt.Add(MemberTracker.FromMemberInfo(t.GetTypeInfo()));
}
return new MemberGroup(mt.ToArray());
}
if (members.Count == 0) {
if ((flags & BindingFlags.DeclaredOnly) == 0) {
members = Binder.GetAllExtensionMembers(type, name);
} else {
members = Binder.GetExtensionMembers(type, name);
}
}
return members;
}
开发者ID:Jaykul,项目名称:IronLangs,代码行数:61,代码来源:PythonTypeInfo.cs
示例16: MakeEventValidation
public virtual ErrorInfo MakeEventValidation(MemberGroup members, Expression eventObject, Expression value, Expression codeContext) {
EventTracker ev = (EventTracker)members[0];
// handles in place addition of events - this validates the user did the right thing.
return ErrorInfo.FromValueNoError(
Expression.Call(
typeof(BinderOps).GetMethod("SetEvent"),
AstUtils.Constant(ev),
value
)
);
}
开发者ID:jcteague,项目名称:ironruby,代码行数:12,代码来源:DefaultBinder.cs
示例17: GetMemberType
protected TrackerTypes GetMemberType(MemberGroup members, out Expression error) {
error = null;
TrackerTypes memberType = TrackerTypes.All;
for (int i = 0; i < members.Count; i++) {
MemberTracker mi = members[i];
if (mi.MemberType != memberType) {
if (memberType != TrackerTypes.All) {
error = MakeAmbiguousMatchError(members);
return TrackerTypes.All;
}
memberType = mi.MemberType;
}
}
return memberType;
}
开发者ID:jcteague,项目名称:ironruby,代码行数:15,代码来源:DefaultBinder.cs
示例18: GetMember
protected MemberGroup/*!*/ GetMember(Type/*!*/ type, string/*!*/ name, BindingFlags flags) {
Assert.NotNull(type, name);
MemberInfo[] foundMembers = type.GetMember(name, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | flags);
if (!Binder.DomainManager.Configuration.PrivateBinding) {
foundMembers = CompilerHelpers.FilterNonVisibleMembers(type, foundMembers);
}
MemberGroup members = new MemberGroup(foundMembers);
// check for generic types w/ arity...
Type[] types = type.GetNestedTypes(BindingFlags.Public | flags);
string genName = name + ReflectionUtils.GenericArityDelimiter;
List<Type> genTypes = null;
foreach (Type t in types) {
if (t.Name.StartsWith(genName)) {
if (genTypes == null) genTypes = new List<Type>();
genTypes.Add(t);
}
}
if (genTypes != null) {
List<MemberTracker> mt = new List<MemberTracker>(members);
foreach (Type t in genTypes) {
mt.Add(MemberTracker.FromMemberInfo(t));
}
return new MemberGroup(mt.ToArray());
}
if (members.Count == 0) {
if ((flags & BindingFlags.DeclaredOnly) == 0) {
members = Binder.GetAllExtensionMembers(type, name);
} else {
members = Binder.GetExtensionMembers(type, name);
}
}
return members;
}
开发者ID:m4dc4p,项目名称:ironruby,代码行数:41,代码来源:TypeInfo.cs
示例19: CacheSlot
/// <summary>
/// Writes to a cache the result of a type lookup. Null values are allowed for the slots and they indicate that
/// the value does not exist.
/// </summary>
public void CacheSlot(Type/*!*/ type, string/*!*/ name, PythonTypeSlot slot, MemberGroup/*!*/ memberGroup) {
Debug.Assert(type != null); Debug.Assert(name != null);
EnsureInfo();
lock (_cachedInfos) {
SlotCacheInfo slots = GetSlotForType(type);
if (slots.ResolvedAll && slot == null && memberGroup.Count == 0) {
// nothing to cache, and we know we don't need to cache non-hits.
return;
}
slots.Members[name] = new KeyValuePair<PythonTypeSlot, MemberGroup>(slot, memberGroup);
}
}
开发者ID:octavioh,项目名称:ironruby,代码行数:20,代码来源:PythonBinder.cs
示例20: FilterForwardReverseMethods
/// <summary>
/// If an operator is a reverisble operator (e.g. addition) then we need to filter down to just the forward/reverse
/// versions of the .NET method. For example consider:
///
/// String.op_Multiplication(int, string)
/// String.op_Multiplication(string, int)
///
/// If this method were defined on string it defines that you can do:
/// 2 * 'abc'
/// or:
/// 'abc' * 2
///
/// either of which will produce 'abcabc'. The 1st form is considered the reverse form because it is declared on string
/// but takes a non-string for the 1st argument. The 2nd is considered the forward form because it takes a string as the
/// 1st argument.
///
/// When dynamically dispatching for 2 * 'abc' we'll first try __mul__ on int, which will fail with a string argument. Then we'll try
/// __rmul__ on a string which will succeed and dispatch to the (int, string) overload.
///
/// For multiplication in this case it's not too interesting because it's commutative. For addition this might be more interesting
/// if, for example, we had unicode and ASCII strings. In that case Unicode strings would define addition taking both unicode and
/// ASCII strings in both forms.
/// </summary>
private static MemberGroup/*!*/ FilterForwardReverseMethods(string name, MemberGroup/*!*/ group, Type/*!*/ type, PythonOperationKind oper) {
List<MethodTracker> res = new List<MethodTracker>(group.Count);
PythonOperationKind reversed = Symbols.OperatorToReverseOperator(oper);
foreach (MemberTracker mt in group) {
if (mt.MemberType != TrackerTypes.Method) {
continue;
}
MethodTracker mTracker = (MethodTracker)mt;
if (reversed == PythonOperationKind.None) {
res.Add(mTracker);
continue;
}
MethodInfo method = mTracker.Method;
if (!method.IsStatic) {
if (!IsReverseOperator(oper)) {
res.Add(mTracker);
}
continue;
}
ParameterInfo[] parms = method.GetParameters();
int ctxOffset = (parms.Length > 0 && parms[0].ParameterType == typeof(CodeContext)) ? 1 : 0;
bool regular;
bool reverse;
if ((parms.Length - ctxOffset) == 2) {
Type param1Type = parms[0 + ctxOffset].ParameterType;
Type param2Type = parms[1 + ctxOffset].ParameterType;
// both parameters could be typed to object in which case we want to add
// the method as whatever we're being requested for here. One example of this
// is EnumOps which can't be typed to Enum.
if (param1Type == typeof(object) && param2Type == typeof(object)) {
regular = !IsReverseOperator(oper);
reverse = IsReverseOperator(oper);
} else {
regular = parms.Length > 0 && AreTypesCompatible(param1Type, type);
reverse = ((oper & PythonOperationKind.Comparison) == 0) && parms.Length > 1 && AreTypesCompatible(param2Type, type);
}
if (IsReverseOperator(oper)) {
if (reverse) {
res.Add(mTracker);
}
} else {
if (regular) {
res.Add(mTracker);
}
}
} else {
res.Add(mTracker);
}
}
if (res.Count == 0) {
return MemberGroup.EmptyGroup;
}
return new MemberGroup(new OperatorTracker(type, name, IsReverseOperator(oper), res.ToArray()));
}
开发者ID:m4dc4p,项目名称:ironruby,代码行数:88,代码来源:TypeInfo.cs
注:本文中的MemberGroup类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论