public ResourceRequestFactory(GoogleServiceCredentials creds, string[] resourceServiceScopes, string[] calendarServiceScopes, int resourceServicePoolSize, int calendarServicePoolSize)
        {
            this.directoryServicePool = new BaseClientServicePool <DirectoryService>(resourceServicePoolSize, () =>
            {
                DirectoryService x = new DirectoryService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer           = new ServiceAccountCredential(creds.GetInitializer(resourceServiceScopes)),
                    ApplicationName                 = "LithnetGoogleAppsLibrary",
                    GZipEnabled                     = !Settings.DisableGzip,
                    Serializer                      = new GoogleJsonSerializer(),
                    DefaultExponentialBackOffPolicy = ExponentialBackOffPolicy.None,
                });

                x.HttpClient.Timeout = Timeout.InfiniteTimeSpan;
                return(x);
            });

            this.calendarServicePool = new BaseClientServicePool <CalendarService>(calendarServicePoolSize, () =>
            {
                CalendarService x = new CalendarService(
                    new BaseClientService.Initializer()
                {
                    HttpClientInitializer           = new ServiceAccountCredential(creds.GetInitializer(calendarServiceScopes)),
                    ApplicationName                 = "LithnetGoogleAppsLibrary",
                    GZipEnabled                     = !Settings.DisableGzip,
                    Serializer                      = new GoogleJsonSerializer(),
                    DefaultExponentialBackOffPolicy = ExponentialBackOffPolicy.None,
                });

                x.HttpClient.Timeout = Timeout.InfiniteTimeSpan;
                return(x);
            });
        }
        public ContactRequestFactory(GoogleServiceCredentials creds, string[] scopes, int poolSize = 30)
        {
            ServiceAccountCredential credentials = new ServiceAccountCredential(creds.GetInitializer(scopes));

            this.contactsServicePool = new Pool <ContactsService>(poolSize, () =>
            {
                ContactsService service = new ContactsService("Lithnet.GoogleApps");
                OAuthGDataRequestFactory requestFactory = new OAuthGDataRequestFactory("Lithnet.GoogleApps", credentials);
                requestFactory.CustomHeaders.Add("GData-Version: 3.0");
                requestFactory.UseGZip = !Settings.DisableGzip;
                service.RequestFactory = requestFactory;
                return(service);
            });
        }
        public UserRequestFactory(GoogleServiceCredentials creds, string[] scopes, int poolSize)
        {
            this.directoryServicePool = new BaseClientServicePool <DirectoryService>(poolSize, () =>
            {
                DirectoryService x = new DirectoryService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer           = new ServiceAccountCredential(creds.GetInitializer(scopes)),
                    ApplicationName                 = "LithnetGoogleAppsLibrary",
                    GZipEnabled                     = !Settings.DisableGzip,
                    Serializer                      = new GoogleJsonSerializer(),
                    DefaultExponentialBackOffPolicy = ExponentialBackOffPolicy.None,
                });

                x.HttpClient.Timeout = Settings.DefaultTimeout;
                return(x);
            });
        }