diff --git a/ln.bson.sln b/ln.bson.sln index 489120c..c4227b6 100644 --- a/ln.bson.sln +++ b/ln.bson.sln @@ -6,8 +6,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.bson.tests", "ln.bson.te EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.bson.storage", "ln.bson.storage\ln.bson.storage.csproj", "{FEB2C12B-7A0F-468C-9063-980FC4A4B8BE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.collections", "..\ln.collections\ln.collections\ln.collections.csproj", "{168FA1B8-0C0D-4AAE-B026-F1A736027C03}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,9 +24,5 @@ Global {FEB2C12B-7A0F-468C-9063-980FC4A4B8BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {FEB2C12B-7A0F-468C-9063-980FC4A4B8BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {FEB2C12B-7A0F-468C-9063-980FC4A4B8BE}.Release|Any CPU.Build.0 = Release|Any CPU - {168FA1B8-0C0D-4AAE-B026-F1A736027C03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {168FA1B8-0C0D-4AAE-B026-F1A736027C03}.Debug|Any CPU.Build.0 = Debug|Any CPU - {168FA1B8-0C0D-4AAE-B026-F1A736027C03}.Release|Any CPU.ActiveCfg = Release|Any CPU - {168FA1B8-0C0D-4AAE-B026-F1A736027C03}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/ln.bson.sln.DotSettings.user b/ln.bson.sln.DotSettings.user index 7f9cf57..fc8ae5f 100644 --- a/ln.bson.sln.DotSettings.user +++ b/ln.bson.sln.DotSettings.user @@ -1,6 +1,8 @@  + <AssemblyExplorer /> <SessionState ContinuousTestingMode="0" IsActive="True" Name="Test_Indeces" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <TestAncestor> <TestId>NUnit3x::D8C856D0-BA32-47A4-A334-71C9A1C66B07::net5.0::ln.bson.tests.Tests.Test_Indeces</TestId> </TestAncestor> -</SessionState> \ No newline at end of file +</SessionState> + \ No newline at end of file diff --git a/ln.bson.storage/BsonFileMapper.cs b/ln.bson.storage/BsonFileMapper.cs index 1b515ff..5f51e28 100644 --- a/ln.bson.storage/BsonFileMapper.cs +++ b/ln.bson.storage/BsonFileMapper.cs @@ -2,9 +2,57 @@ using System; using System.Collections; using System.Collections.Generic; using ln.bson.mapper; +using ln.bson.mapper.mappings; namespace ln.bson.storage { + public class BsonFileMapper : IEnumerable, IDisposable + { + private BsonDocumentStorage _bsonDocumentStorage; + private ClassStructMapping _mapping; + + public BsonFileMapper() + :this(null) + { } + + public BsonFileMapper(BsonDocumentStorageConfiguration documentStorageConfiguration) + { + if (!BsonMapper.DefaultInstance.TryGetMapping(typeof(T), out BsonMapping bsonMapping)) + throw new ApplicationException(); + + _mapping = bsonMapping as ClassStructMapping; + + documentStorageConfiguration ??= + new BsonDocumentStorageConfiguration(String.Format("{0}.bson", typeof(T).Name)); + + _bsonDocumentStorage = new BsonDocumentStorage(documentStorageConfiguration); + + } + + + + + + + + + + + public IEnumerator GetEnumerator() + { + throw new NotImplementedException(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Dispose() + { + throw new NotImplementedException(); + } + } /* public class BsonFileMapper : IEnumerable,IDisposable { diff --git a/ln.bson.storage/ln.bson.storage.csproj b/ln.bson.storage/ln.bson.storage.csproj index f934237..edfcc41 100644 --- a/ln.bson.storage/ln.bson.storage.csproj +++ b/ln.bson.storage/ln.bson.storage.csproj @@ -1,18 +1,18 @@ - net5.0 true - 1.0.1 + 1.0.2 + net5.0;net6.0 - - + + diff --git a/ln.bson/BsonDocument.cs b/ln.bson/BsonDocument.cs index e078da3..37dc10b 100644 --- a/ln.bson/BsonDocument.cs +++ b/ln.bson/BsonDocument.cs @@ -98,6 +98,14 @@ namespace ln.bson return false; } + public BsonValue GetProperty(string propertyName) => GetProperty(propertyName, null); + public BsonValue GetProperty(string propertyName, BsonValue defaultValue) + { + if (_values.TryGetValue(propertyName, out BsonValue bsonValue)) + return bsonValue; + return defaultValue; + } + public override bool TryGetMember(GetMemberBinder binder, out object? result) { if (_values.TryGetValue(binder.Name, out BsonValue bsonValue)) diff --git a/ln.bson/ln.bson.csproj b/ln.bson/ln.bson.csproj index 6ce0568..5d9fe9c 100644 --- a/ln.bson/ln.bson.csproj +++ b/ln.bson/ln.bson.csproj @@ -1,9 +1,9 @@ - net5.0 true - 1.0.1 + 1.0.2 + net5.0;net6.0