using System.Collections.Generic;
namespace Konis.Testbed
{
///
/// What a def's tunable properties held at one moment, to tell later which have changed.
///
public class TunableSnapshot
{
// Held as source text, which is exact for every kind and needs no equality on the values themselves.
private readonly Dictionary texts = new Dictionary();
///
/// Takes the values of every property of that can be changed.
///
public TunableSnapshot(EmitterDef def)
{
foreach (TunableProperty property in Tunables.Of(def))
{
if (property.HasSource(def))
{
texts[property.Name] = DefText.ValueText(property, def);
}
}
}
///
/// Returns the named property's value as C# source, or null when the snapshot holds no such property.
///
public string TextOf(string name)
{
string returnMe;
return texts.TryGetValue(name, out returnMe) ? returnMe : null;
}
}
}