/// <summary> /// Initializes a new instance of the MobileServiceClient class. /// </summary> /// <param name="mobileAppUri"> /// Absolute URI of the Microsoft Azure Mobile App. /// </param> /// <param name="handlers"> /// Chain of <see cref="HttpMessageHandler" /> instances. /// All but the last should be <see cref="DelegatingHandler"/>s. /// </param> public MobileServiceClient(Uri mobileAppUri, params HttpMessageHandler[] handlers) { if (mobileAppUri == null) { throw new ArgumentNullException("mobileAppUri"); } if (mobileAppUri.IsAbsoluteUri) { // Trailing slash in the MobileAppUri is important. Fix it right here before we pass it on further. this.MobileAppUri = new Uri(MobileServiceUrlBuilder.AddTrailingSlash(mobileAppUri.AbsoluteUri), UriKind.Absolute); } else { throw new ArgumentException( string.Format(CultureInfo.InvariantCulture, Resources.MobileServiceClient_NotAnAbsoluteURI, mobileAppUri), "mobileAppUri"); } this.InstallationId = GetApplicationInstallationId(); handlers = handlers ?? EmptyHttpMessageHandlers; this.HttpClient = new MobileServiceHttpClient(handlers, this.MobileAppUri, this.InstallationId); this.Serializer = new MobileServiceSerializer(); this.EventManager = new MobileServiceEventManager(); this.SyncContext = new MobileServiceSyncContext(this); }
public MobileServiceClient(Uri mobileAppUri, params HttpMessageHandler[] handlers) { Arguments.IsNotNull(mobileAppUri, nameof(mobileAppUri)); if (mobileAppUri.IsAbsoluteUri) { // Trailing slash in the MobileAppUri is important. Fix it right here before we pass it on further. MobileAppUri = new Uri(MobileServiceUrlBuilder.AddTrailingSlash(mobileAppUri.AbsoluteUri), UriKind.Absolute); } else { throw new ArgumentException($"'{mobileAppUri}' is not an absolute Uri", nameof(mobileAppUri)); } this.InstallationId = GetApplicationInstallationId(); handlers ??= EmptyHttpMessageHandlers; this.HttpClient = new MobileServiceHttpClient(handlers, this.MobileAppUri, this.InstallationId, httpRequestTimeout); this.Serializer = new MobileServiceSerializer(); this.EventManager = new MobileServiceEventManager(); this.SyncContext = new MobileServiceSyncContext(this); }