private static ICollection[] GetConnectionPoints(Type type)
 {
     if (ConnectionPointsCache == null)
     {
         ConnectionPointsCache = Hashtable.Synchronized(new Hashtable());
     }
     ConnectionPointKey key = new ConnectionPointKey(type, CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture);
     ICollection[] isArray = (ICollection[]) ConnectionPointsCache[key];
     if (isArray == null)
     {
         isArray = CreateConnectionPoints(type);
         ConnectionPointsCache[key] = isArray;
     }
     return isArray;
 }
예제 #2
0
        private static ICollection[] GetConnectionPoints(Type type) {
            if (ConnectionPointsCache == null) {
                // I don't think there is a race condition here.  Even if multiple threads enter this block
                // at the same time, the worst thing that can happen is that the ConnectionPointsCache gets
                // replaced by a new Hashtable(), and existing entries will need to be recomputed.
                // There is no way for the ConnectionPointsCache to become null.
                ConnectionPointsCache = Hashtable.Synchronized(new Hashtable());
            }

            // DevDiv Bugs 38677: Cache by culture and type as it may vary by culture within this app
            ConnectionPointKey connectionPointKey = new ConnectionPointKey(type, CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture);

            ICollection[] connectionPoints = (ICollection[])ConnectionPointsCache[connectionPointKey];
            if (connectionPoints == null) {
                connectionPoints = CreateConnectionPoints(type);
                ConnectionPointsCache[connectionPointKey] = connectionPoints;
            }

            return connectionPoints;
        }