merge Dev
This commit is contained in:
Коммит
cbdee4f72e
|
@ -171,10 +171,30 @@ namespace Steeltoe.CloudFoundry.Connector.Redis
|
|||
/// </summary>
|
||||
/// <param name="optionsType">Expects StackExchange.Redis.ConfigurationOptions</param>
|
||||
/// <returns>This object typed as ConfigurationOptions</returns>
|
||||
/// <remarks>Includes comma in password detection and workaround for https://github.com/SteeltoeOSS/Connectors/issues/10 </remarks>
|
||||
public object ToStackExchangeObject(Type optionsType)
|
||||
{
|
||||
var stackObject = Activator.CreateInstance(optionsType);
|
||||
return stackObject.GetType().GetMethod("Parse", new Type[] { typeof(string) }).Invoke(stackObject, new object[] { ToString() });
|
||||
|
||||
// to remove this comma workaround, follow up on https://github.com/StackExchange/StackExchange.Redis/issues/680
|
||||
var tempPassword = Password;
|
||||
bool resetPassword = false;
|
||||
if (Password.Contains(","))
|
||||
{
|
||||
Password = string.Empty;
|
||||
resetPassword = true;
|
||||
}
|
||||
|
||||
// this return is effectively "StackExchange.Redis.ConfigurationOptions.Parse(this.ToString())"
|
||||
var config = optionsType.GetMethod("Parse", new Type[] { typeof(string) })
|
||||
.Invoke(stackObject, new object[] { ToString() });
|
||||
|
||||
if (resetPassword)
|
||||
{
|
||||
ConnectorHelpers.TrySetProperty(config, "Password", tempPassword);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
// internal void AddEndPoints(EndPointCollection result, string endpoints)
|
||||
|
|
|
@ -156,5 +156,20 @@ namespace Steeltoe.CloudFoundry.Connector
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to set a property on an object
|
||||
/// </summary>
|
||||
/// <param name="obj">Object to set a value on</param>
|
||||
/// <param name="property">Property to set</param>
|
||||
/// <param name="value">Value to use</param>
|
||||
public static void TrySetProperty(object obj, string property, object value)
|
||||
{
|
||||
var prop = obj.GetType().GetProperty(property, BindingFlags.Public | BindingFlags.Instance);
|
||||
if (prop != null && prop.CanWrite)
|
||||
{
|
||||
prop.SetValue(obj, value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,13 +29,8 @@ namespace Steeltoe.CloudFoundry.Connector.MySql
|
|||
|
||||
public MySqlProviderConnectorFactory(MySqlServiceInfo sinfo, MySqlProviderConnectorOptions config, Type type)
|
||||
{
|
||||
if (config == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(config));
|
||||
}
|
||||
|
||||
_info = sinfo;
|
||||
_config = config;
|
||||
_config = config ?? throw new ArgumentNullException(nameof(config));
|
||||
ConnectorType = type;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Steeltoe.CloudFoundry.Connector.Test
|
|||
public class ConnectorIOptionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void Value_Resturns_Excpected()
|
||||
public void Value_Returns_Expected()
|
||||
{
|
||||
var myOpt = new MyOption();
|
||||
var opt = new ConnectorIOptions<MyOption>(myOpt);
|
||||
|
|
|
@ -193,7 +193,7 @@ namespace Steeltoe.CloudFoundry.Connector.Redis.Test
|
|||
{
|
||||
["redis:client:host"] = "127.0.0.1",
|
||||
["redis:client:port"] = "1234",
|
||||
["redis:client:password"] = "password",
|
||||
["redis:client:password"] = "pass,word",
|
||||
["redis:client:abortOnConnectFail"] = "false",
|
||||
["redis:client:connectTimeout"] = "1"
|
||||
};
|
||||
|
@ -215,8 +215,10 @@ namespace Steeltoe.CloudFoundry.Connector.Redis.Test
|
|||
// Assert
|
||||
Assert.NotNull(service);
|
||||
Assert.IsType<ConnectionMultiplexer>(service);
|
||||
Assert.Contains("password=pass,word", (service as ConnectionMultiplexer).Configuration);
|
||||
Assert.NotNull(service2);
|
||||
Assert.IsType<ConnectionMultiplexer>(service2);
|
||||
Assert.Contains("password=pass,word", (service as ConnectionMultiplexer).Configuration);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
Загрузка…
Ссылка в новой задаче