public void ConnectionVersion() { ConnectionVersion oVersion = null; try { oVersion = new ConnectionVersion(1, 2, 3, 4, 5); } catch (Exception ex) { Assert.Fail("Construction of version failed:" + ex); } string strVersion = oVersion.ToString(); Assert.IsTrue(strVersion.Contains("ES"), "Version with ES value does not produce ES in string:" + oVersion); try { oVersion = new ConnectionVersion(1, 2, 3, 4, 0); } catch (Exception ex) { Assert.Fail("Construction of version failed:" + ex); } strVersion = oVersion.ToString(); Assert.IsFalse(strVersion.Contains("ES"), "Version without ES value produce ES in string:" + oVersion); }
public ScribeConnection(IDictionary <string, string> properties, ConnectionVersion version) { this.Version = version; connectionKey = Guid.NewGuid(); var keyName = "AccountId"; Int32 numericResult = 0; if (properties.ContainsKey(keyName)) { AccountId = properties[keyName]; Int32.TryParse(AccountId, out numericResult); if (numericResult == 0) { throw new ApplicationException("Account Id must be numeric."); } } //retrieve and test the EventId EventId = properties["EventId"]; numericResult = 0; Int32.TryParse(EventId, out numericResult); if (numericResult == 0) { throw new ApplicationException("Event Id must be numeric."); } //retrieve the page size if (properties.ContainsKey("TTL")) { var ttl = properties["TTL"]; var intResult = 0; if (Int32.TryParse(ttl, out intResult)) { TTL = intResult; } else { TTL = 20; } } //retrieve the page size if (properties.ContainsKey("PageSize")) { var pageSize = properties["PageSize"]; var intResult = 0; if (Int32.TryParse(pageSize, out intResult)) { PageSize = intResult; } else { PageSize = 1024; } } //retrieve the ApiKey, scribe's UI ensures its not empty if (properties.ContainsKey("ApiKey")) { this.apiKey = properties["ApiKey"]; } //retrieve the SubDomain, this can be empty //this.subDomain = properties["SubDomain"]; //if (string.IsNullOrEmpty(subDomain)) subDomain = "www"; //remove any trailing "." //if (subDomain.EndsWith(".")) subDomain = subDomain.Remove(subDomain.Length - 1); if (version == ConnectionVersion.V1) { if (!String.IsNullOrEmpty(properties["BaseUrl"])) { BaseUrl = properties["BaseUrl"]; } else { //use the default eiseverywhere.com var uri = new UriBuilder(BaseUrl); BaseUrl = uri.ToString(); //set the api URI context we'll be using for this connection (qa, supportqa, etc...) //BaseUrl = String.Format(API_URI_PATTERN, this.subDomain); } } else if (version == ConnectionVersion.V2) { if (properties.ContainsKey("V2Url") && !String.IsNullOrEmpty(properties["V2Url"])) { BaseUrl = properties["V2Url"]; } else { //use the default eiseverywhere.com var uri = new UriBuilder(BaseUrl); BaseUrl = uri.ToString(); //set the api URI context we'll be using for this connection (qa, supportqa, etc...) BaseUrl = String.Format(API_URI_PATTERN, string.Empty); } } history = new List <ConnectionHistory>(); }
public ScribeConnection(IDictionary<string, string> properties, ConnectionVersion version) { this.Version = version; connectionKey = Guid.NewGuid(); var keyName = "AccountId"; Int32 numericResult = 0; if (properties.ContainsKey(keyName)) { AccountId = properties[keyName]; Int32.TryParse(AccountId, out numericResult); if (numericResult == 0) throw new ApplicationException("Account Id must be numeric."); } //retrieve and test the EventId EventId = properties["EventId"]; numericResult = 0; Int32.TryParse(EventId, out numericResult); if (numericResult == 0) throw new ApplicationException("Event Id must be numeric."); //retrieve the page size if (properties.ContainsKey("TTL")) { var ttl = properties["TTL"]; var intResult = 0; if (Int32.TryParse(ttl, out intResult)) TTL = intResult; else TTL = 20; } //retrieve the page size if (properties.ContainsKey("PageSize")) { var pageSize = properties["PageSize"]; var intResult = 0; if (Int32.TryParse(pageSize, out intResult)) PageSize = intResult; else PageSize = 1024; } //retrieve the ApiKey, scribe's UI ensures its not empty if (properties.ContainsKey("ApiKey")) this.apiKey = properties["ApiKey"]; //retrieve the SubDomain, this can be empty //this.subDomain = properties["SubDomain"]; //if (string.IsNullOrEmpty(subDomain)) subDomain = "www"; //remove any trailing "." //if (subDomain.EndsWith(".")) subDomain = subDomain.Remove(subDomain.Length - 1); if (version == ConnectionVersion.V1) { if (!String.IsNullOrEmpty(properties["BaseUrl"])) { BaseUrl = properties["BaseUrl"]; } else { //use the default eiseverywhere.com var uri = new UriBuilder(BaseUrl); BaseUrl = uri.ToString(); //set the api URI context we'll be using for this connection (qa, supportqa, etc...) //BaseUrl = String.Format(API_URI_PATTERN, this.subDomain); } } else if (version == ConnectionVersion.V2) { if (properties.ContainsKey("V2Url") && !String.IsNullOrEmpty(properties["V2Url"])) { BaseUrl = properties["V2Url"]; } else { //use the default eiseverywhere.com var uri = new UriBuilder(BaseUrl); BaseUrl = uri.ToString(); //set the api URI context we'll be using for this connection (qa, supportqa, etc...) BaseUrl = String.Format(API_URI_PATTERN, string.Empty); } } history = new List<ConnectionHistory>(); }