Пример #1
0
 /// <summary>default constructor</summary>
 internal GDataRequest(GDataRequestType type, Uri uriTarget, GDataRequestFactory factory)
 {
     this.type      = type;
     this.targetUri = uriTarget;
     this.factory   = factory;
     this.useGZip   = this.factory.UseGZip; // use gzip setting from factory
 }
Пример #2
0
        /// <summary>
        /// prepares the passed in service by setting the authentication credentials and the timeout settings
        /// </summary>
        /// <param name="s"></param>
        protected void PrepareService(Service s)
        {
            System.Net.ServicePointManager.Expect100Continue = false;
            if (settings.Credentials != null)
            {
                s.Credentials = settings.Credentials;
            }

            if (settings.AuthSubToken != null)
            {
                GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory(s.ServiceIdentifier, settings.Application);
                authFactory.UserAgent  = authFactory.UserAgent + "--IEnumerable";
                authFactory.Token      = settings.AuthSubToken;
                authFactory.PrivateKey = settings.PrivateKey;
                s.RequestFactory       = authFactory;
            }
            else if (settings.ConsumerKey != null)
            {
                // let's create an OAuth factory
                GOAuthRequestFactory authFactory = new GOAuthRequestFactory(s.ServiceIdentifier, settings.Application);
                authFactory.ConsumerKey    = settings.ConsumerKey;
                authFactory.ConsumerSecret = settings.ConsumerSecret;
                authFactory.Token          = settings.Token;
                authFactory.TokenSecret    = settings.TokenSecret;
                s.RequestFactory           = authFactory;
            }
            else if (settings.OAuth2Parameters != null)
            {
                s.RequestFactory = new GOAuth2RequestFactory(s.ServiceIdentifier, settings.Application, settings.OAuth2Parameters);
            }
            else
            {
                GDataGAuthRequestFactory authFactory = s.RequestFactory as GDataGAuthRequestFactory;
                if (authFactory != null)
                {
                    authFactory.UserAgent = authFactory.UserAgent + "--IEnumerable";
                }
            }

            if (settings.Timeout != -1)
            {
                GDataRequestFactory f = s.RequestFactory as GDataRequestFactory;
                if (f != null)
                {
                    f.Timeout = settings.Timeout;
                }
            }

            s.RequestFactory.UseSSL = settings.UseSSL;
        }