GitObjectDB vereinfacht die Konfigurationsverwaltungsversioning, indem sie sie in Git unterstützt.
| Name | Abzeichen |
|---|---|
| GitObjectdb | |
| GitObjectdb.Systemtextjson | |
| GitObjectdb.yamldotnet | |
| GitObjectdb.api.odata | |
| GitObjectdb.api.graphql | |
| GitObjectdb.api.protobuf | |
| GitObjectdb.api.protobuf.model |
GitObjectDB wurde entwickelt, um die Konfigurationsverwaltungsversioning zu vereinfachen. Dies geschieht, indem es die Notwendigkeit der Handkodierung der für die Interaktion mit Git benötigten Befehle beseitigt.
Das Git -Repository wird als reine Datenbank verwendet, da die Dateien, die die serialisierte Kopie der Objekte enthalten, im Dateisystem niemals abgerufen werden. GitObjectDB verwendet nur den von Git bereitgestellten Blob -Speicher.
Hier ist ein einfaches Beispiel:
[ GitFolder ( "Applications" ) ]
public record Application : Node
{
public string Name { get ; init ; }
public string Description { get ; init ; }
}
[ GitFolder ( "Pages" ) ]
public record Table : Node
{
public string Name { get ; init ; }
public string Description { get ; init ; }
[ StoreAsSeparateFile ( Extension = "txt" ) ]
public string ? RichContent { get ; init ; }
} var existingApplication = connection . Lookup < Application > ( "main" , "applications" , new UniqueId ( id ) ) ;
var newTable = new Table { .. . } ;
connection
. Update ( "main" , c => c . CreateOrUpdate ( newTable , parent : existingApplication ) )
. Commit ( new ( "Added new table." , author , committer ) ) ; var node = new SomeNode
{
SomeProperty = "Value stored as json" ,
RichContent = "Value stored as raw text in separate Git blob, next to primary one" ,
} :... wird wie folgt in Git aufbewahrt:
{
"$type" : " Sample.SomeNode " ,
"id" : " zerzrzrz " ,
"someProperty" : " Value stored as json "
} Value stored many dynamic resources in separate Git blob, next to primary one
Sie können auch Ressourcen als separate Dateien speichern:
new Resource ( node , "Some/Folder" , "File.txt" , new Resource . Data ( "Value stored in a separate file in <node path>/Resources/Some/Folder/File.txt" ) ) ; connection
. Update ( "main" , c => c . CreateOrUpdate ( table with { Description = newDescription } ) )
. Commit ( new ( "Some message" , signature , signature ) ) ;
connection . Checkout ( "newBranch" , "main~1" ) ;
connection
. Update ( "main" , c => c . CreateOrUpdate ( table with { Name = newName } ) )
. Commit ( new ( "Another message" , signature , signature ) ) ; var comparison = connection . Compare ( "main~5" , "main" ) ;
var nodeChanges = comparison . Modified . OfType < Change . NodeChange > ( ) ; Knotenreferenzen ermöglichen das Verknüpfen vorhandener Knoten in einem Repository:
public record Order : Node
{
public Client Client { get ; set ; }
// ...
}
public record Client : Node
{
// ...
}
// Nodes get loaded with their references (using a shared )
var cache = new Dictionary < DataPath , ITreeItem > ( ) ;
var order = connection . GetNodes < Order > ( "main" , referenceCache : cache ) . First ( ) ;
Console . WriteLine ( order . Client . Id ) ; // main: A---B A---B
// ->
// newBranch: C C---x
connection
. Update ( "main" , c => c . CreateOrUpdate ( table with { Description = newDescription } ) )
. Commit ( new ( "B" , signature , signature ) ) ;
connection . Repository . Branches . Add ( "newBranch" , "main~1" ) ;
connection
. Update ( "newBranch" , c => c . CreateOrUpdate ( table with { Name = newName } ) )
. Commit ( new ( "C" , signature , signature ) ) ;
sut . Merge ( upstreamCommittish : "main" ) ; Stellen Sie sich ein Szenario vor, in dem Sie in Ihrem Code einen ersten Typ definieren:
[ GitFolder ( FolderName = "Items" , UseNodeFolders = false ) ]
[ IsDeprecatedNodeType ( typeof ( SomeNodeV2 ) ) ]
private record SomeNodeV1 : Node
{
public int Flags { get ; set ; }
}
[ GitFolder ( FolderName = "Items" , UseNodeFolders = false ) ]
private record SomeNodeV2 : Node
{
public BindingFlags TypedFlags { get ; set ; }
} Anschließend möchten Sie eine neue Änderung einführen, damit die Flags -Eigenschaft aussagekräftigere Informationen enthält und sich auf Enums verlassen:
[ GitFolder ( FolderName = "Items" , UseNodeFolders = false ) ]
private record SomeNodeV2 : Node
{
public BindingFlags TypedFlags { get ; set ; }
} Sie müssen lediglich das Attribut [IsDeprecatedNodeType(typeof(SomeNodeV2))] hinzufügen. Dadurch wird der Deserializer angewiesen, Knoten mit einem Konverter in eine neue Version umzuwandeln. #2 Konverter muss im Modell bereitgestellt werden. Sie können Automapper oder andere Tools nach Belieben verwenden.
[ GitFolder ( FolderName = "Items" , UseNodeFolders = false ) ]
[ IsDeprecatedNodeType ( typeof ( SomeNodeV2 ) ) ]
private record SomeNodeV1 : Node
{
// ...
}
var model = new ConventionBaseModelBuilder ( )
. RegisterType < SomeNodeV1 > ( )
. RegisterType < SomeNodeV2 > ( )
. AddDeprecatedNodeUpdater ( UpdateDeprecatedNode )
. Build ( ) ;
Node UpdateDeprecatedNode ( Node old , Type targetType )
{
var nodeV1 = ( SomeNodeV1 ) old ;
return new SomeNodeV2
{
Id = old . Id ,
TypedFlags = ( BindingFlags ) nodeV1 . Flags ,
} ;
}Siehe Dokumentation.
Die MIT -Lizenz (siehe Lizenzdatei).