By default an end-user will not be able to remove the assembly outputs of a Custom Assembly without removing the parent business object. To allow independent removal of an output, you must set the property CanDeleteIndependently to True. By setting this property to True, within your EvaluateAssembly method, an end-user will be able to delete your assembly output independently of the parent business object. By allowing this behavior, the object construction is slightly complicated because a check now will be necessary to determine whether the user has deleted your output. The object construction checks would now appear as:
' Construct the pier (if not generated yet).
Dim oPierComponent As FoundationComponent = Nothing
If m_oPierAssemblyOutput.Output Is Nothing Then
If Not m_oPierAssemblyOutput.HasBeenDeletedByUser Then
m_oPierAssemblyOutput.CanDeleteIndependently = True
oPierComponent = CreateComponent("Pier")
m_oPierAssemblyOutput.Output = oPierComponent
End If
Else
oPierComponent = DirectCast(m_oPierAssemblyOutput.Output, FoundationComponent)
End If
Notice the additional check as to whether the output was deleted by the user with the HasBeenDeletedByUser property. This property will be true when the output existed at one time and was explicitly removed by the user. Also, notice the line of code that set the CanDeleteIndependently property to True, which allowed the end-user to delete the assembly output in the first place.