예제 #1
0
 /// <summary>Sets the api key for further use.</summary>
 /// <param name="apiKey">The api key.</param>
 public void SetApiKey(string apiKey)
 {
     if (KeyUtilities.IsValid(apiKey))
     {
         this.V2Authorized = new FactoryForV2Authorized(this.CreateAuthorizedServiceClient(apiKey));
     }
     else
     {
         throw new ArgumentException("The api key didn't have the required format.", "apiKey");
     }
 }
예제 #2
0
        /// <summary>Initializes a new instance of the <see cref="GW2Bootstrapper"/> class.</summary>
        /// <param name="apiKey">The api key.</param>
        public GW2Bootstrapper(string apiKey)
        {
            // Create instances of the ServiceClients used for the repositories.
            IServiceClient serviceClient          = this.CreateServiceClient();
            IServiceClient renderingServiceClient = this.CreateRenderingServiceClient();

            // Pupulate the repository properties
            this.V1        = new FactoryForV1(serviceClient);
            this.V2        = new FactoryForV2(serviceClient);
            this.Rendering = new FactoryForRendering(renderingServiceClient);
            this.Local     = new FactoryForLocal();

            // Authorisation specific code.
            if (KeyUtilities.IsValid(apiKey))
            {
                IServiceClient authServiceClient = this.CreateAuthorizedServiceClient(apiKey);
                this.V2Authorized = new FactoryForV2Authorized(authServiceClient);
            }
        }