Пример #1
0
 internal int IndexOf(ModelSystemDisplayStructure modelSystemStructure)
 {
     var children = this._Children;
     if ( children == null )
     {
         return -1;
     }
     for ( int i = 0; i < children.Length; i++ )
     {
         if ( children[i] == modelSystemStructure )
         {
             return i;
         }
     }
     return -1;
 }
Пример #2
0
 private bool BuildChildren()
 {
     var anyChanges = false;
     var children = this.Structure.Children;
     if ( children != null )
     {
         var oldChildren = this._Children;
         if ( oldChildren == null || oldChildren.Length != children.Count )
         {
             var newChildren = new ModelSystemDisplayStructure[children.Count];
             if ( oldChildren == null )
             {
                 for ( int i = 0; i < newChildren.Length; i++ )
                 {
                     newChildren[i] = new ModelSystemDisplayStructure( children[i] );
                 }
                 anyChanges = true;
             }
             else
             {
                 int index;
                 for ( int i = 0; i < children.Count; i++ )
                 {
                     var child = children[i];
                     if ( ( index = IndexOf( oldChildren, children[i] ) ) >= 0 )
                     {
                         newChildren[i] = oldChildren[index];
                         if ( index != i )
                         {
                             anyChanges = true;
                         }
                     }
                     else
                     {
                         newChildren[i] = new ModelSystemDisplayStructure( children[i] );
                         anyChanges = true;
                     }
                 }
             }
             this._Children = newChildren;
         }
         else
         {
             int index;
             for ( int i = 0; i < children.Count; i++ )
             {
                 var child = children[i];
                 index = IndexOf( oldChildren, children[i] );
                 if ( index != i )
                 {
                     anyChanges = true;
                     break;
                 }
             }
             if ( anyChanges )
             {
                 var newChildren = new ModelSystemDisplayStructure[children.Count];
                 for ( int i = 0; i < children.Count; i++ )
                 {
                     var child = children[i];
                     if ( ( index = IndexOf( oldChildren, children[i] ) ) >= 0 )
                     {
                         newChildren[i] = oldChildren[index];
                         if ( index != i )
                         {
                             anyChanges = true;
                         }
                     }
                     else
                     {
                         newChildren[i] = new ModelSystemDisplayStructure( children[i] );
                         anyChanges = true;
                     }
                 }
                 this._Children = newChildren;
             }
         }
     }
     return anyChanges;
 }
Пример #3
0
 internal int IndexOf(ModelSystemDisplayStructure[] oldChildren, IModelSystemStructure modelSystemStructure)
 {
     for ( int i = 0; i < oldChildren.Length; i++ )
     {
         if ( oldChildren[i].Structure == modelSystemStructure )
         {
             return i;
         }
     }
     return -1;
 }