/// <summary> /// Reads the remote Eugene file. /// Needs to be called before a value is asked /// </summary> /// <exception cref="InvalidNetworkPath">If the network path is null or invalid</exception> public async System.Threading.Tasks.Task ReadRemoteFileAsync() { if (RemoteLocation == null) { throw new InvalidNetworkPath("No network URL given"); } if (!RemoteLocation.EndsWith(".eug")) { throw new InvalidNetworkPath("The remote file is not an Eugene file"); } using (var client = new System.Net.Http.HttpClient()) { var response = await client.GetAsync(RemoteLocation); try { response.EnsureSuccessStatusCode(); }catch (System.Exception e) { throw new InvalidNetworkPath(e.Message, e); } var responseContents = await response.Content.ReadAsStringAsync(); if (responseContents == null || responseContents.Length == 0) { return; } Configuration = new Configuration.Configuration(responseContents); } }
public RemoteLocationProvider() { RemoteLocation = new RemoteLocation() { Hosts = UserHostsHelper.UserHosts(HttpContext.Current.Request.ServerVariables) }; }
public override int GetHashCode() { unchecked //Allow overflow result number { // Choose large primes to avoid hashing collisions on large number const int HashingBase = (int)2166136261; const int HashingMultiplier = 16777619; //use XOR for higher performence var hash = HashingBase; hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Domain) ? Domain.GetHashCode() : 0); hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, RemoteLocation) ? RemoteLocation.GetHashCode() : 0); hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, BaseLocation) ? BaseLocation.GetHashCode() : 0); hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Login) ? Login.GetHashCode() : 0); hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Password) ? Password.GetHashCode() : 0); return(hash); } }