Match() private static méthode

private static Match ( ITrackingHandler handler ) : int
handler ITrackingHandler
Résultat int
Exemple #1
0
 public static void RegisterTrackingHandler(ITrackingHandler handler)
 {
     if (handler == null)
     {
         throw new ArgumentNullException("handler");
     }
     lock (TrackingServices.TrackingServicesSyncObject)
     {
         if (-1 == TrackingServices.Match(handler))
         {
             if (TrackingServices._Handlers == null || TrackingServices._Size == TrackingServices._Handlers.Length)
             {
                 ITrackingHandler[] local_2 = new ITrackingHandler[TrackingServices._Size * 2 + 4];
                 if (TrackingServices._Handlers != null)
                 {
                     Array.Copy((Array)TrackingServices._Handlers, (Array)local_2, TrackingServices._Size);
                 }
                 TrackingServices._Handlers = local_2;
             }
             Volatile.Write <ITrackingHandler>(ref TrackingServices._Handlers[TrackingServices._Size++], handler);
         }
         else
         {
             throw new RemotingException(Environment.GetResourceString("Remoting_TrackingHandlerAlreadyRegistered", (object)"handler"));
         }
     }
 }
        public static void RegisterTrackingHandler(ITrackingHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            object trackingServicesSyncObject = TrackingServices.TrackingServicesSyncObject;

            lock (trackingServicesSyncObject)
            {
                if (-1 != TrackingServices.Match(handler))
                {
                    throw new RemotingException(Environment.GetResourceString("Remoting_TrackingHandlerAlreadyRegistered", new object[]
                    {
                        "handler"
                    }));
                }
                if (TrackingServices._Handlers == null || TrackingServices._Size == TrackingServices._Handlers.Length)
                {
                    ITrackingHandler[] array = new ITrackingHandler[TrackingServices._Size * 2 + 4];
                    if (TrackingServices._Handlers != null)
                    {
                        Array.Copy(TrackingServices._Handlers, array, TrackingServices._Size);
                    }
                    TrackingServices._Handlers = array;
                }
                Volatile.Write <ITrackingHandler>(ref TrackingServices._Handlers[TrackingServices._Size++], handler);
            }
        }
Exemple #3
0
 public static void UnregisterTrackingHandler(ITrackingHandler handler)
 {
     if (handler == null)
     {
         throw new ArgumentNullException("handler");
     }
     lock (TrackingServices.TrackingServicesSyncObject)
     {
         int local_2 = TrackingServices.Match(handler);
         if (-1 == local_2)
         {
             throw new RemotingException(Environment.GetResourceString("Remoting_HandlerNotRegistered", (object)handler));
         }
         Array.Copy((Array)TrackingServices._Handlers, local_2 + 1, (Array)TrackingServices._Handlers, local_2, TrackingServices._Size - local_2 - 1);
         --TrackingServices._Size;
     }
 }
        public static void UnregisterTrackingHandler(ITrackingHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            object trackingServicesSyncObject = TrackingServices.TrackingServicesSyncObject;

            lock (trackingServicesSyncObject)
            {
                int num = TrackingServices.Match(handler);
                if (-1 == num)
                {
                    throw new RemotingException(Environment.GetResourceString("Remoting_HandlerNotRegistered", new object[]
                    {
                        handler
                    }));
                }
                Array.Copy(TrackingServices._Handlers, num + 1, TrackingServices._Handlers, num, TrackingServices._Size - num - 1);
                TrackingServices._Size--;
            }
        }