private void AddTestHashedEntityToDb() { _binder = new Binder { Hash = "BinderEntity01", Label = "Binder entity", Type = "Nejaky binder type" }; _content = new Content { Hash = TestContentElementHash, Label = "Content 01", Type = "jakysi content type" }; _dirBinder = new Binder { Hash = "directoryBinder01", Label = @"c:\temp", Type = "Directory" }; _binderToContent = new BinderToContent { Binder = _binder, Content = _content }; _binder.Contents = new List <BinderToContent> { _binderToContent }; _content.Binders = new List <BinderToContent> { _binderToContent }; _dirBinderToContent = new AttributedBinderToContent { Binder = _dirBinder, Content = _content, Attribute = "asdf.txt" }; _dirBinder.AttributedContents = new List <AttributedBinderToContent> { _dirBinderToContent }; _content.AttributedBinders = new List <AttributedBinderToContent> { _dirBinderToContent }; using var serviceProvider = InfrastructureTestsUtils.ServiceProvider; var database = serviceProvider.GetService <IGaleryDatabase>(); database.Contents.Add(_content); database.SaveChanges(); database.DetachAllEntities(); }
private Content ToContentEntity(PhysicalFile physicalFile) { Binder directoryBinder = _binderFactory.GetOrBuildDirectoryBinderForPath(physicalFile.FullPath); Content retVal = new() { Hash = physicalFile.Hash, Label = Path.GetFileName(physicalFile.FullPath), Type = physicalFile.Type.ToString(), AttributedBinders = new List <AttributedBinderToContent>() }; var attToContent = new AttributedBinderToContent { Attribute = physicalFile.SubPath, Binder = directoryBinder, BinderHash = directoryBinder.Hash, Content = retVal, ContentHash = retVal.Hash }; retVal.AttributedBinders.Add(attToContent); directoryBinder.AttributedContents.Add(attToContent); return(retVal); } //private void CreateFileContentElement(string path, BinderElement directoryBinder) //{ // var hash = _hasher.ComputeFileContentHash(path); // var theElement = _elementsMemoryStorage.Get(hash); // if (theElement == null) // { // theElement = new ContentElement(hash, directoryBinder, path); // _elementsMemoryStorage.Add(theElement); // } // else // { // theElement.AddLastSeenFilePosition(path, directoryBinder); // } //} //private Binder CreateDirectoryBinder(string path) //{ // string subpath = pathOptimizer.CreateValidSubpathAccordingToCurrentConfiguration(path); // return new Binder(pathOptimizer.Rack, hasher.ComputeStringHash(subpath), BinderTypeEnum.DirectoryType, subpath); //} }