protected CodeDocField ToFieldModel(ICodeDocMember member) { if (member == null) return null; if (member is CodeDocField) return (CodeDocField)member; var fieldModel = new CodeDocField(member.CRef.WithTargetType("F")); var simpleMember = member as CodeDocSimpleMember; if (simpleMember != null) CopySimpleMemberAttributes(fieldModel, simpleMember); return fieldModel; }
private CodeDocField ConvertToModel(FieldInfo fieldInfo, CodeDocMemberDetailLevel detailLevel, ICodeDocMemberDataProvider extraMemberDataProvider = null) { Contract.Requires(fieldInfo != null); Contract.Ensures(Contract.Result<CodeDocField>() != null); Contract.Ensures(!String.IsNullOrEmpty(Contract.Result<CodeDocField>().ShortName)); Contract.Ensures(!String.IsNullOrEmpty(Contract.Result<CodeDocField>().FullName)); Contract.Ensures(!String.IsNullOrEmpty(Contract.Result<CodeDocField>().Title)); Contract.Ensures(Contract.Result<CodeDocField>().Title == Contract.Result<CodeDocField>().ShortName); Contract.Ensures(!String.IsNullOrEmpty(Contract.Result<CodeDocField>().SubTitle)); var appendXmlDoc = detailLevel.HasFlag(CodeDocMemberDetailLevel.Summary) || detailLevel.HasFlag(CodeDocMemberDetailLevel.AdditionalContents); var provideXmlDoc = detailLevel != CodeDocMemberDetailLevel.Minimum; var fieldCRef = GetCRefIdentifier(fieldInfo); var model = new CodeDocField(fieldCRef); model.Uri = GetUri(fieldInfo); var memberDataProvider = new CodeDocMemberInfoProvider<FieldInfo>(fieldInfo); if (provideXmlDoc) { var xmlDocs = XmlDocs.GetMember(fieldCRef.FullCRef); if (xmlDocs != null) memberDataProvider.Add(new CodeDocMemberXmlDataProvider(xmlDocs)); } if (extraMemberDataProvider != null) memberDataProvider.Add(extraMemberDataProvider); if (appendXmlDoc) { model.ValueDescriptionContents = memberDataProvider.GeValueDescriptionContents().ToArray(); ApplyContentXmlDocs(model, memberDataProvider); } model.ExternalVisibility = memberDataProvider.ExternalVisibility ?? ExternalVisibilityKind.Public; model.ShortName = RegularTypeDisplayNameOverlay.GetDisplayName(fieldInfo); model.FullName = FullTypeDisplayNameOverlay.GetDisplayName(fieldInfo); model.Title = model.ShortName; Contract.Assume(fieldInfo.DeclaringType != null); model.NamespaceName = fieldInfo.DeclaringType.Namespace; model.SubTitle = fieldInfo.IsLiteral ? "Constant" : "Field"; model.ValueType = GetOrConvert(fieldInfo.FieldType, CodeDocMemberDetailLevel.Minimum); model.IsLiteral = fieldInfo.IsLiteral; model.IsInitOnly = fieldInfo.IsInitOnly; model.IsStatic = memberDataProvider.IsStatic.GetValueOrDefault(); model.IsObsolete = memberDataProvider.IsObsolete.GetValueOrDefault(); Contract.Assume(fieldInfo.DeclaringType != null); model.Namespace = GetOrCreateNamespaceByName(fieldInfo.DeclaringType.Namespace); model.Assembly = GetCodeDocAssembly(fieldInfo.DeclaringType.Assembly); model.DeclaringType = GetOrConvert(fieldInfo.DeclaringType, CodeDocMemberDetailLevel.Minimum); return model; }