internal Personality(VM vm, string name, string id) { VM = vm; // These variables MUST always be set: variables["name"] = name_var = new Variable(name); variables["id"] = id_var = new Variable(id) { Readonly = true }; variables["enabled_user"] = enabledUser_var = new Variable(true); variables["birthday"] = new Variable(new VType.Date(DateTime.MinValue)); // readonly age, returns DateTime.Now - BirthDay variables["age"] = new VariableFunc(() => { try { var span = DateTime.Now - ((VType.Date)variables["birthday"].Value).Value; return (float)(new DateTime(1, 1, 1) + span).Year - 1f; } catch (ArgumentOutOfRangeException) { return -1f; } }, null); // ToDo 5: Add mood variables. }
internal Personality(VM vm, string name, string id) { VM = vm; // These variables MUST always be set: variables["name"] = name_var = new Variable(name); variables["id"] = id_var = new Variable(id) { Readonly = true }; variables["enabled_user"] = enabledUser_var = new Variable(true); variables["birthday"] = new Variable(new VType.Date(DateTime.MinValue)); // readonly age, returns DateTime.Now - BirthDay variables["age"] = new VariableFunc(() => { try { var span = DateTime.Now - ((VType.Date)variables["birthday"].Value).Value; return((float)(new DateTime(1, 1, 1) + span).Year - 1f); } catch (ArgumentOutOfRangeException) { return(-1f); } }, null); // ToDo 5: Add mood variables. }