public ServiceBusFactory(string connectionString) { DbConnectionStringBuilder builder = new DbConnectionStringBuilder { ConnectionString = connectionString }; string endpointString; if (!builder.TryGetStringValue("Endpoint", out endpointString)) { throw new ArgumentException("Endpoint is not specified.", "connectionString"); } if (!Uri.TryCreate(endpointString, UriKind.Absolute, out this.endpoint)) { throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, "Endpoint is not valid. {0}", endpointString), "connectionString"); } string managementPortString; if (builder.TryGetStringValue("ManagementPort", out managementPortString)) { if (!int.TryParse(managementPortString, out this.managementPort)) { throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, "Malformed ManagementPort. {0}", managementPortString), "connectionString"); } } else { this.managementPort = -1; } string runtimePortString; if (builder.TryGetStringValue("RuntimePort", out runtimePortString)) { if (!int.TryParse(runtimePortString, out this.runtimePort)) { throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, "Malformed RuntimePort. {0}", runtimePortString), "connectionString"); } } else { this.runtimePort = -1; } TokenProviderFactory factory = CreateTokenProviderFactory(builder); this.tokenProvider = factory.Create(); }
public SharedSecretTokenProviderFactory(DbConnectionStringBuilder builder) { if (!builder.TryGetStringValue("SharedSecretIssuer", out this.issuerName)) { throw new ArgumentException("SharedSecretIssuer is required.", "builder"); } if (!builder.TryGetStringValue("SharedSecretValue", out this.issuerKey)) { throw new ArgumentException("SharedSecretValue is required.", "builder"); } string stsUriAddress; if (builder.TryGetStringValue("StsEndpoint", out stsUriAddress)) { if (!Uri.TryCreate(stsUriAddress, UriKind.Absolute, out stsUri)) { throw new ArgumentException("StsEndpoint is not a valid address.", "builder"); } } }