/// <summary> /// Adds the property. /// </summary> /// <param name="parent">The parent.</param> /// <param name="propertyDef">The property def.</param> private void AddProperty(NType parent, PropertyDefinition propertyDef) { var propertyId = DocIdHelper.GetXmlId(propertyDef); var property = (NProperty)_registry.FindById(propertyId); if (property == null) { property = NewInstance <NProperty>(parent.Namespace, propertyDef); _registry.Register(property); property.Namespace = parent.Namespace; property.MemberType = NMemberType.Property; property.PropertyType = GetTypeReference(propertyDef.PropertyType); property.GetMethod = AddMethod(property, propertyDef.GetMethod, true); property.SetMethod = AddMethod(property, propertyDef.SetMethod, true); parent.AddMember(property); parent.HasProperties = true; // Setup visibility based on method var refMethod = property.GetMethod ?? property.SetMethod; property.Visibility = refMethod.Visibility; property.IsStatic = refMethod.IsStatic; property.IsFinal = refMethod.IsFinal; property.IsAbstract = refMethod.IsAbstract; property.SeeAlsos.Add(new NSeeAlso(parent)); property.SeeAlsos.Add(new NSeeAlso(parent.Namespace)); UpdatePageTitle(property); } property.SetApiGroup(CurrentMergeGroup, true); }
/// <summary> /// Adds the event. /// </summary> /// <param name="parent">The parent.</param> /// <param name="eventDef">The event def.</param> private void AddEvent(NType parent, EventDefinition eventDef) { var eventId = DocIdHelper.GetXmlId(eventDef); var @event = (NEvent)_registry.FindById(eventId); if (@event == null) { @event = NewInstance <NEvent>(parent.Namespace, eventDef); _registry.Register(@event); @event.MemberType = NMemberType.Event; @event.EventType = this.GetTypeReference(eventDef.EventType); parent.AddMember(@event); parent.HasEvents = true; var addMethod = AddMethod(@event, eventDef.AddMethod, true); var removeMethod = AddMethod(@event, eventDef.RemoveMethod, true); // Setup visibility based on event add/remove methods var refMethod = addMethod ?? removeMethod; @event.Visibility = refMethod.Visibility; @event.IsStatic = refMethod.IsStatic; @event.IsFinal = refMethod.IsFinal; @event.IsAbstract = refMethod.IsAbstract; // Add SeeAlso @event.SeeAlsos.Add(new NSeeAlso(parent)); @event.SeeAlsos.Add(new NSeeAlso(parent.Namespace)); UpdatePageTitle(@event); } @event.SetApiGroup(CurrentMergeGroup, true); }
/// <summary> /// Adds the field. /// </summary> /// <param name="parent">The parent.</param> /// <param name="fieldDef">The field def.</param> private void AddField(NType parent, FieldDefinition fieldDef) { if (fieldDef.IsSpecialName) { return; } var fieldId = DocIdHelper.GetXmlId(fieldDef); var field = (NField)_registry.FindById(fieldId); if (field == null) { field = NewInstance <NField>(parent.Namespace, fieldDef); _registry.Register(field); field.MemberType = NMemberType.Field; field.FieldType = GetTypeReference(fieldDef.FieldType); // Setup visibility field.IsStatic = fieldDef.IsStatic; if (fieldDef.IsPublic) { field.Visibility = NVisibility.Public; } else if (fieldDef.IsPrivate) { field.Visibility = NVisibility.Private; } else if (fieldDef.IsAssembly) { field.Visibility = NVisibility.Internal; } else if (fieldDef.IsFamily) { field.Visibility = NVisibility.Protected; } else if (fieldDef.IsFamilyOrAssembly) { field.Visibility = NVisibility.ProtectedInternal; } if (fieldDef.Constant != null) { field.ConstantValue = GetTextFromValue(fieldDef.Constant); } parent.AddMember(field); parent.HasFields = true; field.SeeAlsos.Add(new NSeeAlso(parent)); field.SeeAlsos.Add(new NSeeAlso(parent.Namespace)); UpdatePageTitle(field); } field.SetApiGroup(CurrentMergeGroup, true); }