Exemplo n.º 1
0
        private void ExtractFieldsTypes(CrRuntimeLibrary crRuntime)
        {
            var clrType = ClrType.GetReversedType(crRuntime);

            if (clrType.Assembly.GlobalAssemblyCache)
            {
                return;
            }
            if (clrType.IsInterface)
            {
                return;
            }
            var fields = clrType.GetFields(BindingFlags.NonPublic |
                                           BindingFlags.Public | BindingFlags.Instance
                                           | BindingFlags.DeclaredOnly | BindingFlags.Static
                                           ).ToArray();

            if (fields.Length == 0)
            {
                return;
            }
            foreach (var fieldInfo in fields)
            {
                if (fieldInfo.IsLiteral)
                {
                    continue;
                }
                var typeOfField = new TypeDescription(fieldInfo.FieldType);

                var fieldDescription = new FieldDescription
                {
                    Name            = fieldInfo.Name,
                    TypeDescription = typeOfField,
                    IsStatic        = fieldInfo.IsStatic
                };
                var fieldOffsetAttribute = fieldInfo.GetCustomAttribute <FieldOffsetAttribute>();
                if (fieldOffsetAttribute != null)
                {
                    fieldDescription.Offset = fieldOffsetAttribute.Value;
                }
                Layout.Add(fieldDescription);
            }
        }