|
|
|
|
|
|
{ |
|
|
|
return new TemplateConfigurationOptions |
|
|
|
{ |
|
|
|
groups = SerializeRandomizers(scenario.randomizers) |
|
|
|
randomizerGroups = SerializeRandomizers(scenario.randomizers) |
|
|
|
static Dictionary<string, Group> SerializeRandomizers(IEnumerable<Randomizer> randomizers) |
|
|
|
static List<Group> SerializeRandomizers(IEnumerable<Randomizer> randomizers) |
|
|
|
var serializedRandomizers = new Dictionary<string, Group>(); |
|
|
|
var serializedRandomizers = new List<Group>(); |
|
|
|
serializedRandomizers.Add(randomizer.GetType().Name, randomizerData); |
|
|
|
|
|
|
|
serializedRandomizers.Add(randomizerData); |
|
|
|
} |
|
|
|
return serializedRandomizers; |
|
|
|
} |
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
var fields = randomizer.GetType().GetFields(); |
|
|
|
randomizerData.randomizerId = randomizer.GetType().Name; |
|
|
|
foreach (var field in fields) |
|
|
|
{ |
|
|
|
if (field.FieldType.IsSubclassOf(typeof(Randomization.Parameters.Parameter))) |
|
|
|
|
|
|
|
|
|
|
static void DeserializeTemplateIntoScenario(ScenarioBase scenario, TemplateConfigurationOptions template) |
|
|
|
{ |
|
|
|
DeserializeRandomizers(scenario.randomizers, template.groups); |
|
|
|
DeserializeRandomizers(scenario.randomizers, template.randomizerGroups); |
|
|
|
static void DeserializeRandomizers(IEnumerable<Randomizer> randomizers, Dictionary<string, Group> groups) |
|
|
|
static void DeserializeRandomizers(IEnumerable<Randomizer> randomizers, List<Group> groups) |
|
|
|
foreach (var randomizerPair in groups) |
|
|
|
foreach (var randomizerData in groups) |
|
|
|
if (!randomizerTypeMap.ContainsKey(randomizerPair.Key)) |
|
|
|
if (!randomizerTypeMap.ContainsKey(randomizerData.randomizerId)) |
|
|
|
var randomizer = randomizerTypeMap[randomizerPair.Key]; |
|
|
|
DeserializeRandomizer(randomizer, randomizerPair.Value); |
|
|
|
var randomizer = randomizerTypeMap[randomizerData.randomizerId]; |
|
|
|
DeserializeRandomizer(randomizer, randomizerData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|