fix name as requested
This commit is contained in:
parent
675bb9824f
commit
dad0f9b376
@ -24,7 +24,7 @@ namespace greyn.Deployment
|
|||||||
*/
|
*/
|
||||||
var actualConfig = JsonConvert.DeserializeObject<ExpandoObject>(File.ReadAllText(confpath)) ?? new ExpandoObject();
|
var actualConfig = JsonConvert.DeserializeObject<ExpandoObject>(File.ReadAllText(confpath)) ?? new ExpandoObject();
|
||||||
var toReturn = new T();
|
var toReturn = new T();
|
||||||
populateExpando(toReturn, ref actualConfig);
|
PopulateExpando(toReturn, ref actualConfig);
|
||||||
File.WriteAllText(confpath, JsonConvert.SerializeObject(actualConfig, Formatting.Indented));
|
File.WriteAllText(confpath, JsonConvert.SerializeObject(actualConfig, Formatting.Indented));
|
||||||
|
|
||||||
readFromExpando(ref toReturn, actualConfig);
|
readFromExpando(ref toReturn, actualConfig);
|
||||||
@ -40,7 +40,7 @@ namespace greyn.Deployment
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: make private but get tests to cooperate... I think that's a c# limitation
|
//TODO: make private but get tests to cooperate... I think that's a c# limitation
|
||||||
internal static void populateExpando<T>(T config, ref ExpandoObject fromFile)
|
internal static void PopulateExpando<T>(T config, ref ExpandoObject fromFile)
|
||||||
{
|
{
|
||||||
if (config == null) return;
|
if (config == null) return;
|
||||||
if (fromFile == null)
|
if (fromFile == null)
|
||||||
@ -70,14 +70,14 @@ namespace greyn.Deployment
|
|||||||
var asField = (FieldInfo)memberInfo;
|
var asField = (FieldInfo)memberInfo;
|
||||||
if (dictionaryFromExpandoFromFile[asField.Name] is ExpandoObject childMemberField)
|
if (dictionaryFromExpandoFromFile[asField.Name] is ExpandoObject childMemberField)
|
||||||
{
|
{
|
||||||
populateExpando(asField.GetValue(config), ref childMemberField);
|
PopulateExpando(asField.GetValue(config), ref childMemberField);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MemberTypes.Property:
|
case MemberTypes.Property:
|
||||||
var asProperty = (PropertyInfo)memberInfo;
|
var asProperty = (PropertyInfo)memberInfo;
|
||||||
if (dictionaryFromExpandoFromFile[asProperty.Name] is ExpandoObject childMemberProperty)
|
if (dictionaryFromExpandoFromFile[asProperty.Name] is ExpandoObject childMemberProperty)
|
||||||
{
|
{
|
||||||
populateExpando(asProperty.GetValue(config), ref childMemberProperty);
|
PopulateExpando(asProperty.GetValue(config), ref childMemberProperty);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -108,7 +108,7 @@ public class ConfigTests
|
|||||||
{
|
{
|
||||||
var toReturn = new AConfigurationType();
|
var toReturn = new AConfigurationType();
|
||||||
var actualConfig = parse(PerfectConfiguration);
|
var actualConfig = parse(PerfectConfiguration);
|
||||||
greyn.Deployment.ConfigurationBootstrapper.populateExpando(toReturn, ref actualConfig);
|
greyn.Deployment.ConfigurationBootstrapper.PopulateExpando(toReturn, ref actualConfig);
|
||||||
Assert.Pass();
|
Assert.Pass();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -139,7 +139,7 @@ public class ConfigTests
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}");
|
}");
|
||||||
greyn.Deployment.ConfigurationBootstrapper.populateExpando(new AConfigurationType(), ref actualConfig);
|
greyn.Deployment.ConfigurationBootstrapper.PopulateExpando(new AConfigurationType(), ref actualConfig);
|
||||||
Console.WriteLine("survived populate expando");
|
Console.WriteLine("survived populate expando");
|
||||||
var casted = (IDictionary<string, object?>)actualConfig;
|
var casted = (IDictionary<string, object?>)actualConfig;
|
||||||
Console.WriteLine(casted["aValueTypeButNotAField"]);
|
Console.WriteLine(casted["aValueTypeButNotAField"]);
|
||||||
@ -172,7 +172,7 @@ public class ConfigTests
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}");
|
}");
|
||||||
greyn.Deployment.ConfigurationBootstrapper.populateExpando(new AConfigurationType(), ref actualConfig);
|
greyn.Deployment.ConfigurationBootstrapper.PopulateExpando(new AConfigurationType(), ref actualConfig);
|
||||||
var casted = (IDictionary<string, object?>)actualConfig;
|
var casted = (IDictionary<string, object?>)actualConfig;
|
||||||
Console.WriteLine(casted["aField"]);
|
Console.WriteLine(casted["aField"]);
|
||||||
Assert.Pass();
|
Assert.Pass();
|
||||||
@ -194,7 +194,7 @@ public class ConfigTests
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}");
|
}");
|
||||||
greyn.Deployment.ConfigurationBootstrapper.populateExpando(new AConfigurationType(), ref actualConfig);
|
greyn.Deployment.ConfigurationBootstrapper.PopulateExpando(new AConfigurationType(), ref actualConfig);
|
||||||
var casted = (IDictionary<string, object?>)actualConfig;
|
var casted = (IDictionary<string, object?>)actualConfig;
|
||||||
Console.WriteLine(casted["subtyped"]);
|
Console.WriteLine(casted["subtyped"]);
|
||||||
Assert.Pass();
|
Assert.Pass();
|
||||||
@ -225,7 +225,7 @@ public class ConfigTests
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}");
|
}");
|
||||||
greyn.Deployment.ConfigurationBootstrapper.populateExpando(new AConfigurationType(), ref actualConfig);
|
greyn.Deployment.ConfigurationBootstrapper.PopulateExpando(new AConfigurationType(), ref actualConfig);
|
||||||
var casted = (IDictionary<string, object?>)actualConfig;
|
var casted = (IDictionary<string, object?>)actualConfig;
|
||||||
var subtypeCasted = (IDictionary<string, object?>)casted["subtyped"];
|
var subtypeCasted = (IDictionary<string, object?>)casted["subtyped"];
|
||||||
Console.WriteLine(subtypeCasted["aValueType"]);
|
Console.WriteLine(subtypeCasted["aValueType"]);
|
||||||
@ -257,7 +257,7 @@ public class ConfigTests
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}");
|
}");
|
||||||
greyn.Deployment.ConfigurationBootstrapper.populateExpando(new AConfigurationType(), ref actualConfig);
|
greyn.Deployment.ConfigurationBootstrapper.PopulateExpando(new AConfigurationType(), ref actualConfig);
|
||||||
var casted = (IDictionary<string, object?>)actualConfig;
|
var casted = (IDictionary<string, object?>)actualConfig;
|
||||||
var subtypeCasted = (IDictionary<string, object?>)casted["subtyped"];
|
var subtypeCasted = (IDictionary<string, object?>)casted["subtyped"];
|
||||||
Console.WriteLine(subtypeCasted["aValueTypeButNotAField"]);
|
Console.WriteLine(subtypeCasted["aValueTypeButNotAField"]);
|
||||||
@ -285,7 +285,7 @@ public class ConfigTests
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}");
|
}");
|
||||||
greyn.Deployment.ConfigurationBootstrapper.populateExpando(new AConfigurationType(), ref actualConfig);
|
greyn.Deployment.ConfigurationBootstrapper.PopulateExpando(new AConfigurationType(), ref actualConfig);
|
||||||
var casted = (IDictionary<string, object?>)actualConfig;
|
var casted = (IDictionary<string, object?>)actualConfig;
|
||||||
var subtypeCasted = (IDictionary<string, object?>)casted["subtyped"];
|
var subtypeCasted = (IDictionary<string, object?>)casted["subtyped"];
|
||||||
Console.WriteLine(subtypeCasted["anEnumerableType"]);
|
Console.WriteLine(subtypeCasted["anEnumerableType"]);
|
||||||
@ -309,7 +309,7 @@ public class ConfigTests
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}");
|
}");
|
||||||
greyn.Deployment.ConfigurationBootstrapper.populateExpando(new AConfigurationType(), ref actualConfig);
|
greyn.Deployment.ConfigurationBootstrapper.PopulateExpando(new AConfigurationType(), ref actualConfig);
|
||||||
var casted = (IDictionary<string, object?>)actualConfig;
|
var casted = (IDictionary<string, object?>)actualConfig;
|
||||||
Assert.IsNull(casted["subtyped"]);
|
Assert.IsNull(casted["subtyped"]);
|
||||||
}
|
}
|
||||||
@ -341,7 +341,7 @@ public class ConfigTests
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}");
|
}");
|
||||||
greyn.Deployment.ConfigurationBootstrapper.populateExpando(new AConfigurationType(), ref actualConfig);
|
greyn.Deployment.ConfigurationBootstrapper.PopulateExpando(new AConfigurationType(), ref actualConfig);
|
||||||
var casted = (IDictionary<string, object?>)actualConfig;
|
var casted = (IDictionary<string, object?>)actualConfig;
|
||||||
Assert.IsNotNull(casted["hiImHereToo"]);
|
Assert.IsNotNull(casted["hiImHereToo"]);
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ public class ConfigTests
|
|||||||
public void populateExpando_populatesblank()
|
public void populateExpando_populatesblank()
|
||||||
{
|
{
|
||||||
var actualConfig = parse("{}");
|
var actualConfig = parse("{}");
|
||||||
greyn.Deployment.ConfigurationBootstrapper.populateExpando(new AConfigurationType(), ref actualConfig);
|
greyn.Deployment.ConfigurationBootstrapper.PopulateExpando(new AConfigurationType(), ref actualConfig);
|
||||||
dynamic casted = actualConfig;
|
dynamic casted = actualConfig;
|
||||||
Console.WriteLine(JsonConvert.SerializeObject(casted, Formatting.Indented));
|
Console.WriteLine(JsonConvert.SerializeObject(casted, Formatting.Indented));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user