本文整理汇总了C#中Mono.CSharp.MemberCache.AddMemberImported方法的典型用法代码示例。如果您正苦于以下问题:C# MemberCache.AddMemberImported方法的具体用法?C# MemberCache.AddMemberImported怎么用?C# MemberCache.AddMemberImported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.MemberCache
的用法示例。
在下文中一共展示了MemberCache.AddMemberImported方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadMembers
public void LoadMembers (TypeSpec declaringType, bool onlyTypes, ref MemberCache cache)
{
//
// Not interested in members of nested private types unless the importer needs them
//
if (declaringType.IsPrivate && importer.IgnorePrivateMembers) {
cache = MemberCache.Empty;
return;
}
var loading_type = (MetaType) provider;
const BindingFlags all_members = BindingFlags.DeclaredOnly |
BindingFlags.Static | BindingFlags.Instance |
BindingFlags.Public | BindingFlags.NonPublic;
const MethodAttributes explicit_impl = MethodAttributes.NewSlot |
MethodAttributes.Virtual | MethodAttributes.HideBySig |
MethodAttributes.Final;
Dictionary<MethodBase, MethodSpec> possible_accessors = null;
List<EventSpec> imported_events = null;
EventSpec event_spec;
MemberSpec imported;
MethodInfo m;
MemberInfo[] all;
try {
all = loading_type.GetMembers (all_members);
} catch (Exception e) {
throw new InternalErrorException (e, "Could not import type `{0}' from `{1}'",
declaringType.GetSignatureForError (), declaringType.MemberDefinition.DeclaringAssembly.FullName);
}
if (cache == null) {
cache = new MemberCache (all.Length);
//
// Do the types first as they can be referenced by the members before
// they are found or inflated
//
foreach (var member in all) {
if (member.MemberType != MemberTypes.NestedType)
continue;
var t = (MetaType) member;
// Ignore compiler generated types, mostly lambda containers
if ((t.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate && importer.IgnorePrivateMembers)
continue;
try {
imported = importer.CreateNestedType (t, declaringType);
} catch (Exception e) {
throw new InternalErrorException (e, "Could not import nested type `{0}' from `{1}'",
t.FullName, declaringType.MemberDefinition.DeclaringAssembly.FullName);
}
cache.AddMemberImported (imported);
}
foreach (var member in all) {
if (member.MemberType != MemberTypes.NestedType)
continue;
var t = (MetaType) member;
if ((t.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate && importer.IgnorePrivateMembers)
continue;
importer.ImportTypeBase (t);
}
}
//
// Load base interfaces first to minic behaviour of compiled members
//
if (declaringType.IsInterface && declaringType.Interfaces != null) {
foreach (var iface in declaringType.Interfaces) {
cache.AddInterface (iface);
}
}
if (!onlyTypes) {
//
// The logic here requires methods to be returned first which seems to work for both Mono and .NET
//
foreach (var member in all) {
switch (member.MemberType) {
case MemberTypes.Constructor:
case MemberTypes.Method:
MethodBase mb = (MethodBase) member;
var attrs = mb.Attributes;
if ((attrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) {
if (importer.IgnorePrivateMembers)
continue;
// Ignore explicitly implemented members
if ((attrs & explicit_impl) == explicit_impl)
continue;
//.........这里部分代码省略.........