public SerialData(bool load) { if (!load) { return; } FestiSpecContext data = new FestiSpecContext(false); Attachments = data.Attachments.ToList(); foreach (Attachment attachment in Attachments) { attachment.FilePath = " "; } ContactPeople = data.ContactPeople.ToList(); CustomerCompanies = data.CustomerCompanies.ToList(); Employees = data.Employees.ToList(); EmployeeAccounts = data.EmployeeAccounts.ToList(); Festivals = data.Festivals.ToList(); Inspections = data.Inspections.ToList(); PermissionNodes = data.PermissionNodes.ToList(); Questions = data.Questions.ToList(); Answers = data.Answers.ToList(); QuestionTypes = data.QuestionTypes.ToList(); Roles = data.Roles.ToList(); QuestionLists = data.QuestionLists.ToList(); EmployeeAbsenceDates = data.EmployeeAbsenceDates.ToList(); }
public FestiSpecContext Deserialize() { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("sync.dat", FileMode.Open, FileAccess.Read); FestiSpecContext newcontext = (FestiSpecContext)formatter.Deserialize(stream); return(newcontext); }
public static void Serialize(FestiSpecContext context) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("sync.dat", FileMode.Create, FileAccess.Write); formatter.Serialize(stream, context); stream.Close(); }