示例#1
0
 public static Dictionary<Association, Association> Gather(Database db)
 {
     var associations = new PairAssociations();
     associations.VisitDatabase(db);
     var dictionary = new Dictionary<Association, Association>();
     foreach (string str in associations.associations.Keys)
     {
         Association[] associationArray = associations.associations[str].ToArray();
         int length = associationArray.Length;
         int num2 = 0;
         while (num2 != length)
         {
             int index = -1;
             int num4 = -1;
             MatchLevel noMatch = MatchLevel.NoMatch;
             for (int i = 0; i < (length - 1); i++)
             {
                 for (int j = i + 1; j < length; j++)
                 {
                     Association thisSide = associationArray[i];
                     Association otherSide = associationArray[j];
                     if ((thisSide != null) && (otherSide != null))
                     {
                         MatchLevel level2 = Compare(associations.associationTypes[thisSide], thisSide,
                                                     associations.associationTypes[otherSide], otherSide);
                         if (level2 > noMatch)
                         {
                             index = i;
                             num4 = j;
                             noMatch = level2;
                         }
                     }
                 }
             }
             if ((noMatch & MatchLevel.MinBar) == MatchLevel.MinBar)
             {
                 Association association3 = associationArray[index];
                 Association association4 = associationArray[num4];
                 dictionary[association3] = association4;
                 dictionary[association4] = association3;
                 associationArray[index] = null;
                 associationArray[num4] = null;
                 num2 += 2;
             }
             else
             {
                 foreach (Association association5 in associationArray)
                 {
                     if (association5 != null)
                     {
                         dictionary[association5] = null;
                         num2++;
                     }
                 }
             }
         }
     }
     return dictionary;
 }
示例#2
0
 public static Dictionary <Association, Association> GetAssociationPairs(Database db)
 {
     return(PairAssociations.Gather(db));
 }
            public static Dictionary <Association, Association> Gather(Database db)
            {
                var associations = new PairAssociations();

                associations.VisitDatabase(db);
                var dictionary = new Dictionary <Association, Association>();

                foreach (string str in associations.associations.Keys)
                {
                    Association[] associationArray = associations.associations[str].ToArray();
                    int           length           = associationArray.Length;
                    int           num2             = 0;
                    while (num2 != length)
                    {
                        int        index   = -1;
                        int        num4    = -1;
                        MatchLevel noMatch = MatchLevel.NoMatch;
                        for (int i = 0; i < (length - 1); i++)
                        {
                            for (int j = i + 1; j < length; j++)
                            {
                                Association thisSide  = associationArray[i];
                                Association otherSide = associationArray[j];
                                if ((thisSide != null) && (otherSide != null))
                                {
                                    MatchLevel level2 = Compare(associations.associationTypes[thisSide], thisSide,
                                                                associations.associationTypes[otherSide], otherSide);
                                    if (level2 > noMatch)
                                    {
                                        index   = i;
                                        num4    = j;
                                        noMatch = level2;
                                    }
                                }
                            }
                        }
                        if ((noMatch & MatchLevel.MinBar) == MatchLevel.MinBar)
                        {
                            Association association3 = associationArray[index];
                            Association association4 = associationArray[num4];
                            dictionary[association3] = association4;
                            dictionary[association4] = association3;
                            associationArray[index]  = null;
                            associationArray[num4]   = null;
                            num2 += 2;
                        }
                        else
                        {
                            foreach (Association association5 in associationArray)
                            {
                                if (association5 != null)
                                {
                                    dictionary[association5] = null;
                                    num2++;
                                }
                            }
                        }
                    }
                }
                return(dictionary);
            }