Exemple #1
0
 private static Instamojo getInstamojo(String clientId, String clientSecret, String apiEndpoint, String authEndpoint)
 {
     if (uniqueInstance == null)
     {
         lock (_locker)
         {
             if (uniqueInstance == null)
             {
                 uniqueInstance = new InstamojoImplementation(clientId, clientSecret, apiEndpoint, authEndpoint);
                 accessToken    = getAccessToken(clientId, clientSecret, authEndpoint);
             }
         }
     }
     else
     {
         if (isTokenExpired())
         {
             lock (_locker)
             {
                 if (isTokenExpired())
                 {
                     accessToken = getAccessToken(clientId, clientSecret, authEndpoint);
                 }
             }
         }
     }
     return(uniqueInstance);
 }
        private static Instamojo getInstamojo(String clientId, String clientSecret, String apiEndpoint, String authEndpoint)
        {
            #region Previous code with singleton approach
            //if (uniqueInstance == null)
            //{
            //    lock (_locker)
            //    {
            //        if (uniqueInstance == null)
            //        {
            //            uniqueInstance = new InstamojoImplementation(clientId, clientSecret, apiEndpoint, authEndpoint);
            //            accessToken = getAccessToken(clientId, clientSecret, authEndpoint);

            //        }
            //    }
            //}
            //else
            //{
            //    if (isTokenExpired())
            //    {
            //        lock (_locker)
            //        {
            //            if (isTokenExpired())
            //            {
            //                accessToken = getAccessToken(clientId, clientSecret, authEndpoint);
            //            }
            //        }
            //    }
            //}
            //return uniqueInstance;
            #endregion

            var instaMojoInstance = new InstamojoImplementation(clientId, clientSecret, apiEndpoint, authEndpoint);
            accessToken = getAccessToken(clientId, clientSecret, authEndpoint);

            return(instaMojoInstance);
        }