本文整理汇总了C#中IKVM.GetFields方法的典型用法代码示例。如果您正苦于以下问题:C# IKVM.GetFields方法的具体用法?C# IKVM.GetFields怎么用?C# IKVM.GetFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKVM
的用法示例。
在下文中一共展示了IKVM.GetFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitMembers
void InitMembers(IKVM.Reflection.Type typeDefinition, IUnresolvedTypeDefinition td, IList<IUnresolvedMember> members)
{
foreach (var method in typeDefinition.GetMethods (bindingFlags)) {
if (IsVisible(method.Attributes) && !IsAccessor(method)) {
EntityType type = EntityType.Method;
if (method.IsSpecialName) {
if (method.Name.StartsWith("op_", StringComparison.Ordinal))
type = EntityType.Operator;
}
members.Add(ReadMethod(method, td, type));
}
}
foreach (var method in typeDefinition.GetConstructors (bindingFlags)) {
if (IsVisible(method.Attributes)) {
EntityType type = EntityType.Constructor;
members.Add(ReadConstructor(method, td, type));
}
}
foreach (var field in typeDefinition.GetFields (bindingFlags)) {
if (IsVisible(field.Attributes) && !field.IsSpecialName) {
members.Add(ReadField(field, td));
}
}
string defaultMemberName = null;
var defaultMemberAttribute = typeDefinition.CustomAttributes.FirstOrDefault(
a => a.AttributeType.FullName == typeof(System.Reflection.DefaultMemberAttribute).FullName);
if (defaultMemberAttribute != null && defaultMemberAttribute.ConstructorArguments.Count == 1) {
defaultMemberName = defaultMemberAttribute.ConstructorArguments[0].Value as string;
}
foreach (var property in typeDefinition.GetProperties (bindingFlags)) {
bool getterVisible = property.GetMethod != null && IsVisible(property.GetMethod.Attributes);
bool setterVisible = property.SetMethod != null && IsVisible(property.SetMethod.Attributes);
if (getterVisible || setterVisible) {
EntityType type = EntityType.Property;
if (property.GetIndexParameters () != null) {
// Try to detect indexer:
if (property.Name == defaultMemberName) {
type = EntityType.Indexer; // normal indexer
}
// TODO: HasOverrides ?
else if (property.Name.EndsWith(".Item", StringComparison.Ordinal) /*&& (property.GetMethod ?? property.SetMethod).HasOverrides*/) {
// explicit interface implementation of indexer
type = EntityType.Indexer;
// We can't really tell parameterized properties and indexers apart in this case without
// resolving the interface, so we rely on the "Item" naming convention instead.
}
}
members.Add(ReadProperty(property, td, type));
}
}
foreach (var ev in typeDefinition.GetEvents (bindingFlags)) {
if (ev.AddMethod != null && IsVisible(ev.AddMethod.Attributes)) {
members.Add(ReadEvent(ev, td));
}
}
}
示例2: InitBaseTypes
void InitBaseTypes(IKVM.Reflection.Type typeDefinition, ICollection<ITypeReference> baseTypes)
{
// set base classes
if (typeDefinition.IsEnum) {
foreach (var enumField in typeDefinition.GetFields (bindingFlags)) {
if (!enumField.IsStatic) {
baseTypes.Add(ReadTypeReference(enumField.FieldType));
break;
}
}
} else {
if (typeDefinition.BaseType != null) {
baseTypes.Add(ReadTypeReference(typeDefinition.BaseType));
}
foreach (var iface in typeDefinition.GetInterfaces ()) {
baseTypes.Add(ReadTypeReference(iface));
}
}
}