/// <summary> /// Initializes a new instance of the <see cref="ServiceConnectionStringBuilder"/> class. /// </summary> /// <param name="connection">The connection.</param> public ServiceConnectionStringBuilder(string connection) { var settings = connection.Split(new[] { ';' }); var properties = typeof(ServiceConnectionStringBuilder).GetProperties(); foreach (var property in properties) { var propertyName = property.Name; var setting = settings.FirstOrDefault(a => a.StartsWith(propertyName)); if (!string.IsNullOrEmpty(setting)) { var value = setting.Substring(setting.IndexOf('=') + 1); if (!string.IsNullOrEmpty(value)) { try { if (property.PropertyType.Equals(typeof(TimeSpan))) { var propertyValue = TimeSpan.Parse(value); property.SetValue(this, propertyValue, null); } else { var propertyValue = Convert.ChangeType(value, property.PropertyType); property.SetValue(this, propertyValue, null); } } catch (FormatException ex) { FxLog <ServiceConnectionStringBuilder> .WarnFormat("Unable to convert {0} to {1} : {2}", value, property.PropertyType, ex.Message); } catch (InvalidCastException ex) { FxLog <ServiceConnectionStringBuilder> .WarnFormat("Unable to convert {0} to {1} : {2}", value, property.PropertyType, ex.Message); } } } } }
public void Try_WarningLogging() { FxLog <DomainTestFixture> .WarnFormat("This is a Warning message."); }