/// <summary> /// Gets the request header. /// </summary> /// <returns>The request header.</returns> private RequestHeader GetRequestHeader() { DfaAppConfig config = (DfaAppConfig)base.Config; RequestHeader reqHeader = new RequestHeader(); reqHeader.ApplicationName = config.GetUserAgent(); return(reqHeader); }
/// <summary> /// Create a service object. /// </summary> /// <param name="signature">Signature of the service being created.</param> /// <param name="user">The user for which the service is being created. /// <param name="serverUrl">The server to which the API calls should be /// made.</param> /// </param> /// <returns>An object of the desired service type.</returns> public override AdsClient CreateService(ServiceSignature signature, AdsUser user, Uri serverUrl) { DfaAppConfig config = (DfaAppConfig)base.Config; if (serverUrl == null) { serverUrl = new Uri(config.DfaApiServer); } if (user == null) { throw new ArgumentNullException("user"); } CheckServicePreconditions(signature); DfaServiceSignature dfaapiSignature = signature as DfaServiceSignature; AdsClient service = (AdsClient)Activator.CreateInstance(dfaapiSignature.ServiceType); if (config.Proxy != null) { service.Proxy = config.Proxy; } service.Timeout = config.Timeout; service.Url = string.Format("{0}{1}/api/dfa-api/{2}", serverUrl, dfaapiSignature.Version, dfaapiSignature.ServiceEndpoint); service.UserAgent = config.GetUserAgent(); service.User = user; service.Signature = signature; service.GetType().GetProperty("RequestHeader").SetValue(service, GetRequestHeader(), null); SetRequestHeaderNameSpace(signature as DfaServiceSignature, service); return(service); }