private static void SetEntityPath(ServiceBusConnectionStringProperties properties, string entityPath) { const BindingFlags internalScope = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty; Type propertiesType = properties.GetType(); PropertyInfo entityPathProperty = propertiesType.GetProperty(nameof(properties.EntityPath)); Guard.NotNull(entityPathProperty, nameof(entityPathProperty), $"Requires a '{nameof(properties)}' property on the '{nameof(ServiceBusConnectionStringProperties)}' type"); entityPathProperty?.SetValue(properties, entityPath, internalScope, binder: null, index: null, culture: null); }
private static string GetConnectionString(ServiceBusConnectionStringProperties properties) { const BindingFlags internalScope = BindingFlags.NonPublic | BindingFlags.Instance; Type propertiesType = properties.GetType(); const string connectionStringMethodName = "ToConnectionString"; MethodInfo connectionStringMethod = propertiesType.GetMethod(connectionStringMethodName, internalScope); Guard.NotNull(connectionStringMethod, nameof(properties), $"Requires a '{connectionStringMethodName}' method on the '{nameof(ServiceBusConnectionStringProperties)}'"); var connectionString = connectionStringMethod?.Invoke(properties, new object[0]) as string; if (string.IsNullOrWhiteSpace(connectionStringMethodName)) { throw new InvalidOperationException( "Could not determine the Azure Service Bus namespace-scoped connection string from the given connection string properties"); } return(connectionString); }