public static void PersistRandomVariable(this StatePersister persister, ref RandomVariable value, [CallerArgumentExpression("value")] string name = "") { persister.BeginObject(name); var distributionType = value.DistributionType; persister.PersistEnum(ref distributionType); var low = value.Low; persister.PersistSingle(ref low); var high = value.High; persister.PersistSingle(ref high); persister.EndObject(); if (persister.Mode == StatePersistMode.Read) { value = new RandomVariable(low, high, distributionType); } }