GITObjectDB simplifica el versiones de gestión de configuración al respaldarlo en GIT.
| Nombre | Insignia |
|---|---|
| Gitobjectdb | |
| Gitobjectdb.systemtextjson | |
| GitObjectdb.yamDotnet | |
| Gitobjectdb.api.odata | |
| Gitobjectdb.api.graphql | |
| Gitobjectdb.api.protobuf | |
| Gitobjectdb.api.protobuf.model |
GITObjectDB está diseñado para simplificar el Versión de gestión de configuración. Lo hace eliminando la necesidad de codificar a mano los comandos necesarios para interactuar con GIT.
El repositorio GIT se usa como una base de datos pura ya que los archivos que contienen la copia serializada de los objetos nunca se obtienen en el sistema de archivos. GITObjectDB solo usa el almacenamiento BLOB proporcionado por Git.
Aquí hay un ejemplo simple:
[ 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" ,
} :... se almacena en Git de la siguiente manera:
{
"$type" : " Sample.SomeNode " ,
"id" : " zerzrzrz " ,
"someProperty" : " Value stored as json "
} Value stored many dynamic resources in separate Git blob, next to primary one
También puede almacenar recursos como archivos separados:
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 > ( ) ; Las referencias de nodo permiten vincular los nodos existentes en un repositorio:
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" ) ; Imagine un escenario en el que defina en su código un primer tipo:
[ 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 ; }
} Luego desea introducir un nuevo cambio para que la propiedad Flags contenga información más significativa, confiando en enums:
[ GitFolder ( FolderName = "Items" , UseNodeFolders = false ) ]
private record SomeNodeV2 : Node
{
public BindingFlags TypedFlags { get ; set ; }
} Todo lo que necesita hacer es agregar el atributo [IsDeprecatedNodeType(typeof(SomeNodeV2))] . Esto instruirá al deserializador que convierta los nodos a una nueva versión, utilizando un convertidor. Se debe proporcionar un convertidor #2 en el modelo. Puede usar Automapper u otras herramientas a su conveniencia.
[ 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 ,
} ;
}Ver documentación.
La licencia MIT (consulte el archivo de licencia).