public static PresetGroupRow FromContext(NotifyingDataContext dataContext) { var process = dataContext["Process"] as NotifyingDataContext; var previousProcess = dataContext["PreviousProcess"] as NotifyingDataContext; var presetGroupRow = new PresetGroupRow { PreviousProcess = new ProcessInfo { Id = 0 }, Process = new ProcessInfo { Id = 0 } }; if (process != null) { presetGroupRow.Process.Id = Convert.ToInt32(process["Id"]); } if (previousProcess != null) { presetGroupRow.PreviousProcess.Id = Convert.ToInt32(previousProcess["Id"]); } presetGroupRow.Left = Convert.ToInt32(dataContext["Left"]); presetGroupRow.Top = Convert.ToInt32(dataContext["Top"]); presetGroupRow.AccountName = Convert.ToString(dataContext["AccountName"]); presetGroupRow.Password = Convert.ToString(dataContext["Password"]); return(presetGroupRow); }
public static PresetGroup FromContext(NotifyingDataContext dataContext) { if (dataContext == null) { return(new PresetGroup { Rows = new List <PresetGroupRow>() }); } var presetGroup = new PresetGroup { Name = dataContext["Name"] as string, Rows = new List <PresetGroupRow>() }; var rows = dataContext["Rows"] as ObservableCollection <NotifyingDataContext>; if (rows == null) { return(presetGroup); } foreach (var rowContext in rows) { presetGroup.Rows.Add(PresetGroupRow.FromContext(rowContext)); } return(presetGroup); }