private static ArrayList GetCommonProperties(object[] objs, bool presort, PropertyTab tab, GridEntry parentEntry)
 {
     PropertyDescriptorCollection[] descriptorsArray = new PropertyDescriptorCollection[objs.Length];
     Attribute[] array = new Attribute[parentEntry.BrowsableAttributes.Count];
     parentEntry.BrowsableAttributes.CopyTo(array, 0);
     for (int i = 0; i < objs.Length; i++)
     {
         PropertyDescriptorCollection descriptors = tab.GetProperties(parentEntry, objs[i], array);
         if (presort)
         {
             descriptors = descriptors.Sort(MultiSelectRootGridEntry.PropertyComparer);
         }
         descriptorsArray[i] = descriptors;
     }
     ArrayList list = new ArrayList();
     PropertyDescriptor[] descriptorArray = new PropertyDescriptor[objs.Length];
     int[] numArray = new int[descriptorsArray.Length];
     for (int j = 0; j < descriptorsArray[0].Count; j++)
     {
         PropertyDescriptor descriptor = descriptorsArray[0][j];
         bool flag = descriptor.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute();
         for (int k = 1; flag && (k < descriptorsArray.Length); k++)
         {
             if (numArray[k] >= descriptorsArray[k].Count)
             {
                 flag = false;
                 break;
             }
             PropertyDescriptor descriptor2 = descriptorsArray[k][numArray[k]];
             if (descriptor.Equals(descriptor2))
             {
                 numArray[k]++;
                 if (!descriptor2.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute())
                 {
                     flag = false;
                     break;
                 }
                 descriptorArray[k] = descriptor2;
                 continue;
             }
             int num4 = numArray[k];
             descriptor2 = descriptorsArray[k][num4];
             flag = false;
             while (MultiSelectRootGridEntry.PropertyComparer.Compare(descriptor2, descriptor) <= 0)
             {
                 if (descriptor.Equals(descriptor2))
                 {
                     if (!descriptor2.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute())
                     {
                         flag = false;
                         num4++;
                     }
                     else
                     {
                         flag = true;
                         descriptorArray[k] = descriptor2;
                         numArray[k] = num4 + 1;
                     }
                     break;
                 }
                 num4++;
                 if (num4 >= descriptorsArray[k].Count)
                 {
                     break;
                 }
                 descriptor2 = descriptorsArray[k][num4];
             }
             if (!flag)
             {
                 numArray[k] = num4;
                 break;
             }
         }
         if (flag)
         {
             descriptorArray[0] = descriptor;
             list.Add(descriptorArray.Clone());
         }
     }
     return list;
 }
         // this returns an array list of the propertydescriptor arrays, one for each
         // component
         //
         private static ArrayList GetCommonProperties(object[] objs, bool presort, PropertyTab tab, GridEntry parentEntry) {
             PropertyDescriptorCollection[] propCollections = new PropertyDescriptorCollection[objs.Length];
 
             Attribute[] attrs = new Attribute[parentEntry.BrowsableAttributes.Count];
             parentEntry.BrowsableAttributes.CopyTo(attrs, 0);
             
             for (int i = 0; i < objs.Length; i++) {
                 PropertyDescriptorCollection pdc = tab.GetProperties(parentEntry, objs[i], attrs);
                 if (presort) {
                     pdc = pdc.Sort(PropertyComparer);
                 }
                 propCollections[i] = pdc;
             }
             
             ArrayList mergedList = new ArrayList();
             PropertyDescriptor[] matchArray = new PropertyDescriptor[objs.Length];
 
            // 
            // Merge the property descriptors
            //
            int[] posArray = new int[propCollections.Length];
            for (int i = 0; i < propCollections[0].Count; i++) {
                PropertyDescriptor pivotDesc = propCollections[0][i];
                
                bool match = pivotDesc.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute();
                     
                for (int j = 1; match && j < propCollections.Length; j++) {
     
                    if (posArray[j] >= propCollections[j].Count) {
                        match = false;
                        break;
                    }
     
                    // check to see if we're on a match
                    //
                    PropertyDescriptor jProp = propCollections[j][posArray[j]];
                    if (pivotDesc.Equals(jProp)) {
                        posArray[j] += 1;
                        
                        if (!jProp.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) {
                             match = false;
                             break;
                        }
                        matchArray[j] = jProp;
                        continue;
                    }
                    
                    int jPos = posArray[j];
                    jProp = propCollections[j][jPos];
 
                    match = false;
     
                    // if we aren't on a match, check all the items until we're past
                    // where the matching item would be
                    while (PropertyComparer.Compare(jProp, pivotDesc) <= 0) {
     
                        // got a match!
                        if (pivotDesc.Equals(jProp)) {
 
                            if (!jProp.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) {
                               match = false;
                               jPos++;
                            }
                            else {
                               match = true;
                               matchArray[j] = jProp;
                               posArray[j] = jPos + 1;
                            }
                            break;
                        }
     
                        // try again
                        jPos++;
                        if (jPos < propCollections[j].Count) {
                            jProp = propCollections[j][jPos];
                        }
                        else {
                            break;
                        }
                    }
     
                    // if we got here, there is no match, quit for this guy
                    if (!match) {
                         posArray[j] = jPos;
                         break;
                    }
                }
     
                // do we have a match?
                if (match) {
                    matchArray[0] = pivotDesc;
                    mergedList.Add(matchArray.Clone());
                }
            }
 
            return mergedList;
         }