public static BitmapSource GetIcon(Field field) { if (field.IsPublic) return Field; if (field.IsPrivate) return PrivateField; if (field.IsProtected) return ProtectedField; if (field.IsConstant) return ConstantField; if (field.IsEvent) { if (field.IsPublic) return EventField; if (field.IsPrivate) return PrivateEventField; if (field.IsProtected) return ProtectedEventField; } return Field; }
/// <summary> /// Reads fields and add them to the type. /// </summary> /// <param name="type">A type where fields will be added</param> /// <param name="fields">A collection of fields</param> private void ReadFields(Type type, Collection<FieldDefinition> fields) { foreach (FieldDefinition fieldDefinition in fields) { var field = new Field { Name = fieldDefinition.Name, DeclaringType = type, IsPublic = fieldDefinition.IsPublic, IsPrivate = fieldDefinition.IsPrivate, IsProtected = !fieldDefinition.IsPublic && !fieldDefinition.IsPrivate, IsStatic = fieldDefinition.IsStatic, IsConstant = fieldDefinition.HasConstant, IsReadOnly = fieldDefinition.IsInitOnly }; type.Fields.Add(field); var fieldType = (from n in type.Namespace.Module.Namespaces from t in n.Types where t.FullName == FormatTypeName(fieldDefinition.FieldType, true) select t).SingleOrDefault(); if (fieldDefinition.FieldType.IsGenericInstance) { field.IsGenericInstance = true; field.GenericTypes.UnionWith(ReadGenericArguments(type.Namespace.Module, (GenericInstanceType)fieldDefinition.FieldType)); } field.FieldType = fieldType; } }