/// <summary> /// Adds a Model to the MemoryDC /// </summary> /// <param name="model"></param> /// <param name="isSensibleData"></param> public void AddOneToMemoryDC(ModelBase model, bool isSensibleData = false, SensibleModelBase sensibleModel = null) { if (!isSensibleData) { _xmlDatacache.AddToUnsecureMemoryDC(model); } else { _xmlDatacache.AddToSecureMemoryDC(sensibleModel.ForeignId, ByteHelper.ObjectToByteArray(sensibleModel)); } }
/// <summary> /// Builds a new fortress. /// </summary> /// <param name="fortess"></param> public void CreateNewFortress(Fortress fortess) { _xmlDatacache = new XmlDataCache(fortess.FullPath); // Store the example data: var rootBranch = new Branch { Name = "Example: Projects", ParentBranchId = Guid.Empty }; var rootBranch2 = new Branch { Name = "Example: Projects2", ParentBranchId = Guid.Empty }; var subBranch = new Branch { Name = "Example: Passwords", ParentBranchId = rootBranch.Id }; var examplePw = ByteHelper.StringToByteArray("thisIsAnExamplePassword"); var leaf = new Leaf { Name = "Password1", Description = "Here you can describe this entry.", BranchId = subBranch.Id }; var leafPw = new LeafPassword { ForeignId = leaf.Id, Value = examplePw }; examplePw = null; _xmlDatacache.AddToUnsecureMemoryDC(fortess); _xmlDatacache.AddToUnsecureMemoryDC(rootBranch); _xmlDatacache.AddToUnsecureMemoryDC(rootBranch2); _xmlDatacache.AddToUnsecureMemoryDC(subBranch); _xmlDatacache.AddToUnsecureMemoryDC(leaf); var leafPwAsBytes = ByteHelper.ObjectToByteArray(leafPw); _xmlDatacache.AddToSecureMemoryDC(leafPw.ForeignId, leafPwAsBytes); leafPw = null; // end exampel data _xmlDatacache.WriteFortress(fortess); }