/// <summary>
    /// Read all settings from App.config.
    /// </summary>
    /// <param name="settings">The parsed App.config settings.</param>
    protected override void ReadSettings(Hashtable settings) {
      base.ReadSettings(settings);

      clientCustomerId = ReadSetting(settings, CLIENT_CUSTOMER_ID, clientCustomerId);
      developerToken = ReadSetting(settings, DEVELOPER_TOKEN, developerToken);

      // Configuration keys where AdWords API integrates with other products
      // that have their own settings.
      long.TryParse(ReadSetting(settings, MERCHANT_CENTER_ID, merchantCenterId.ToString()),
          out merchantCenterId);
      placesLoginEmail = ReadSetting(settings, PLACES_LOGIN_EMAIL, placesLoginEmail);
      placesOAuth2RefreshToken = ReadSetting(settings, PLACES_OAUTH2_REFRESH_TOKEN,
          placesOAuth2RefreshToken);

      userAgent = ReadSetting(settings, USER_AGENT, userAgent);
      adWordsApiServer = ReadSetting(settings, ADWORDSAPI_SERVER, adWordsApiServer);
      try {
        authorizationMethod = (AdWordsAuthorizationMethod) Enum.Parse(
            typeof(AdWordsAuthorizationMethod),
            ReadSetting(settings, AUTHORIZATION_METHOD, authorizationMethod.ToString()));
      } catch {
        authorizationMethod = DEFAULT_AUTHORIZATION_METHOD;
      }

      // If there is an OAuth2 scope mentioned in App.config, this will be
      // loaded by the above call. If there isn't one, we will initialize it
      // with a library-specific default value.
      if (string.IsNullOrEmpty(this.OAuth2Scope)) {
        this.OAuth2Scope = GetDefaultOAuth2Scope();
      }
    }
    /// <summary>
    /// Public constructor.
    /// </summary>
    public AdWordsAppConfig() : base() {
      clientCustomerId = "";
      developerToken = "";
      merchantCenterId = -1;
      placesOAuth2RefreshToken = "";
      placesLoginEmail = "";
      userAgent = "";
      adWordsApiServer = DEFAULT_ADWORDSAPI_SERVER;
      authorizationMethod = DEFAULT_AUTHORIZATION_METHOD;

      ReadSettings((Hashtable) ConfigurationManager.GetSection("AdWordsApi"));
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Read all settings from App.config.
    /// </summary>
    /// <param name="settings">The parsed App.config settings.</param>
    protected override void ReadSettings(Hashtable settings) {
      base.ReadSettings(settings);

      email = ReadSetting(settings, EMAIL, email);
      password = ReadSetting(settings, PASSWORD, password);
      clientEmail = ReadSetting(settings, CLIENT_EMAIL, clientEmail);
      clientCustomerId = ReadSetting(settings, CLIENT_CUSTOMER_ID, clientCustomerId);
      developerToken = ReadSetting(settings, DEVELOPER_TOKEN, developerToken);
      applicationToken = ReadSetting(settings, APPLICATION_TOKEN, applicationToken);
      authToken = ReadSetting(settings, AUTHTOKEN, authToken);
      userAgent = ReadSetting(settings, USER_AGENT, userAgent);
      bool.TryParse(ReadSetting(settings, ENABLE_GZIP_COMPRESSION,
          enableGzipCompression.ToString()), out enableGzipCompression);
      legacyAdWordsApiServer = ReadSetting(settings, LEGACY_ADWORDSAPI_SERVER,
          legacyAdWordsApiServer);
      adWordsApiServer = ReadSetting(settings, ADWORDSAPI_SERVER, adWordsApiServer);
      oAuthConsumerKey = ReadSetting(settings, OAUTH_CONSUMER_KEY, oAuthConsumerKey);
      oAuthConsumerSecret = ReadSetting(settings, OAUTH_CONSUMER_SECRET, oAuthConsumerSecret);
      try {
        authorizationMethod = (AdWordsAuthorizationMethod) Enum.Parse(
            typeof(AdWordsAuthorizationMethod),
            ReadSetting(settings, AUTHORIZATION_METHOD, authorizationMethod.ToString()));
      } catch {
        authorizationMethod = DEFAULT_AUTHORIZATION_METHOD;
      }
    }
        /// <summary>
        /// Read all settings from App.config.
        /// </summary>
        /// <param name="settings">The parsed App.config settings.</param>
        protected override void ReadSettings(Hashtable settings)
        {
            base.ReadSettings(settings);

              clientCustomerId = ReadSetting(settings, CLIENT_CUSTOMER_ID, clientCustomerId);
              developerToken = ReadSetting(settings, DEVELOPER_TOKEN, developerToken);
              userAgent = ReadSetting(settings, USER_AGENT, userAgent);
              adWordsApiServer = ReadSetting(settings, ADWORDSAPI_SERVER, adWordsApiServer);
              try {
            authorizationMethod = (AdWordsAuthorizationMethod) Enum.Parse(
            typeof(AdWordsAuthorizationMethod),
            ReadSetting(settings, AUTHORIZATION_METHOD, authorizationMethod.ToString()));
              } catch {
            authorizationMethod = DEFAULT_AUTHORIZATION_METHOD;
              }

              // If there is an OAuth2 scope mentioned in App.config, this will be
              // loaded by the above call. If there isn't one, we will initialize it
              // with a library-specific default value.
              if (string.IsNullOrEmpty(this.OAuth2Scope)) {
            this.OAuth2Scope = GetDefaultOAuth2Scope();
              }
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Public constructor.
    /// </summary>
    public AdWordsAppConfig() : base() {
      authToken = "";
      email = "";
      password = "";
      clientEmail = "";
      clientCustomerId = "";
      developerToken = "";
      applicationToken = "";
      userAgent = "";
      enableGzipCompression = true;
      shortNameField = "AwApi-DotNet";
      legacyAdWordsApiServer = DEFAULT_LEGACY_ADWORDSAPI_SERVER;
      adWordsApiServer = DEFAULT_ADWORDSAPI_SERVER;
      oAuthConsumerKey = "";
      oAuthConsumerSecret = "";
      authorizationMethod = DEFAULT_AUTHORIZATION_METHOD;

      ReadSettings((Hashtable) ConfigurationManager.GetSection("AdWordsApi"));
    }