internal static PwGroup ReadGroup(Stream msData, PwDatabase pdContext, bool bCopyIcons, bool bNewUuids, bool bSetCreatedNow) { PwDatabase pd = new PwDatabase(); pd.New(new IOConnectionInfo(), new CompositeKey()); KdbxFile f = new KdbxFile(pd); f.Load(msData, KdbxFormat.PlainXml, null); if (bCopyIcons) { PwDatabase.CopyCustomIcons(pd, pdContext, pd.RootGroup, true); } if (bNewUuids) { pd.RootGroup.Uuid = new PwUuid(true); pd.RootGroup.CreateNewItemUuids(true, true, true); } if (bSetCreatedNow) { pd.RootGroup.SetCreatedNow(true); } return(pd.RootGroup); }
internal static void WriteGroup(Stream msOutput, PwDatabase pdContext, PwGroup pg) { if (msOutput == null) { throw new ArgumentNullException("msOutput"); } // pdContext may be null if (pg == null) { throw new ArgumentNullException("pg"); } PwDatabase pd = new PwDatabase(); pd.New(new IOConnectionInfo(), new CompositeKey()); pd.RootGroup = pg.CloneDeep(); pd.RootGroup.ParentGroup = null; PwDatabase.CopyCustomIcons(pdContext, pd, pd.RootGroup, true); KdbxFile f = new KdbxFile(pd); f.Save(msOutput, null, KdbxFormat.PlainXml, null); }