^{END}
{END}{ENTER}{ENTER}

Namespace Microsoft.AnalysisServices

    Partial Public NotOverridable Class Level
        Inherits NamedComponent

        Private sourceAttributeID As String

        Private hideMemberIf As HideIfValue

        Private translations As TranslationCollection

        Private Sub Initialize() 
        {ESC}{DOWN}{END}

        Public Sub New()
        {ESC}{DOWN}{END}

        Public Sub New(name As String)
            MyBase.New(name) {ESC}{DOWN}{END}

        Public Sub New(name As String, id As String)
            MyBase.New(name, id) {ESC}{DOWN}{END}

        Public Property SourceAttributeID As String
            Get
                Return sourceAttributeID {ESC}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{END}

        Public Property HideMemberIf As HideIfValue
            Get
                Return hideMemberIf {ESC}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{END}

        Public ReadOnly Property Translations As TranslationCollection
                Return translations {ESC}{DOWN}{DOWN}{END}

        Public Property SourceAttribute As DimensionAttribute
            Get
                Return If(Nothing = Me.sourceAttributeID, Nothing, Me.SourceAttributeOrException) {ESC}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{END}

        Friend ReadOnly Property SourceAttributeOrException As DimensionAttribute
                Return Me.ParentDimensionOrException.Attributes(Me.sourceAttributeID) {ESC}{DOWN}{DOWN}{END}

        Friend ReadOnly Property SourceAttributeOrNull As DimensionAttribute
                Dim dimension As Dimension = Me.ParentDimensionOrNull
                Return If(Nothing = dimension, Nothing, dimension.Attributes.Find(Me.sourceAttributeID)) {ESC}{DOWN}{DOWN}{END}

        Public Function CopyTo(obj As Level) As Level
            Return obj {ESC}{DOWN}{END}

        Public Function Clone() As Level
            Return CopyTo(New Level()) {ESC}{DOWN}{END}

        Friend Sub UpdateDependents(index As Integer)
        {ESC}{DOWN}{END}

        Protected Friend Overrides Sub AfterInsert(index As Integer)
        {ESC}{DOWN}{END}

        Protected Friend Overrides Sub BeforeRemove(cleanUp As Boolean)  
        {ESC}{DOWN}{END}

        Protected Friend Overrides Sub AfterMove(fromIndex As Integer, toIndex As Integer)
            Hierarchy hierarchy = Me.ParentOrNull
            Dimension dimension = Me.ParentDimensionOrNull
            Database database = Me.ParentDatabaseOrNull
            If Nothing = database Then
                Return {ESC}{DOWN}{END}

            Dim levelID As String = Me.ID
            Dim hierarchyID As String = hierarchy.ID
            Dim dimensionID As String = dimension.ID {ESC}{DOWN}{END}

        Public Overrides Function Validate(errors As ValidationErrorCollection, includeDetailedErrors As Boolean) As Boolean
            If Not MyBase.Validate(errors, includeDetailedErrors) Then
                Return False {ESC}{DOWN}{END}

            DimensionAttributesourceAttribute = Me.SourceAttributeOrNull
            If Nothing = sourceAttribute Then
                errors.Add(Me, ValidationSR.Level_SourceAttributeIsUnknown)
                Return False
            ElseIf Not sourceAttribute.AttributeHierarchyEnabled Then
                errors.Add(Me, ValidationSR.Level_SourceAttributeDoesntHaveAttributeHierarchyEnabled)
                Return False
            Else
                Return True {ESC}^{END}