当前位置: 首页>>代码示例>>C#>>正文


C# IKVM.GetFields方法代码示例

本文整理汇总了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));
                }
            }
        }
开发者ID:jlyonsmith,项目名称:NRefactory,代码行数:61,代码来源:IkvmLoader.cs

示例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));
         }
     }
 }
开发者ID:jlyonsmith,项目名称:NRefactory,代码行数:19,代码来源:IkvmLoader.cs


注:本文中的IKVM.GetFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。