يقوم GitObjectDB بتبسيط إصدار إدارة التكوين عن طريق دعمه في GIT.
| اسم | شارة |
|---|---|
| GitobjectDB | |
| gitobjectdb.systemtextjson | |
| gitobjectdb.yamldotnet | |
| gitobjectdb.api.odata | |
| gitobjectdb.api.graphql | |
| gitobjectdb.api.protobuf | |
| gitobjectdb.api.protobuf.model |
تم تصميم GitObjectDB لتبسيط إصدار إدارة التكوين. يفعل ذلك عن طريق إزالة الحاجة إلى ترميز اليد بالأوامر اللازمة للتفاعل مع GIT.
يتم استخدام مستودع GIT كقاعدة بيانات خالصة لأن الملفات التي تحتوي على النسخة المسلسل من الكائنات لا يتم جلبها أبدًا في نظام الملفات. يستخدم GitObjectDB فقط تخزين Blob الذي توفره GIT.
هذا مثال بسيط:
[ 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" ,
} :... يتم تخزينها في غيت على النحو التالي:
{
"$type" : " Sample.SomeNode " ,
"id" : " zerzrzrz " ,
"someProperty" : " Value stored as json "
} Value stored many dynamic resources in separate Git blob, next to primary one
يمكنك أيضًا تخزين الموارد كملفات منفصلة:
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 > ( ) ; تسمح مراجع العقدة بربط العقد الموجودة في مستودع:
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" ) ; تخيل سيناريو حيث تحدد في الكود الخاص بك النوع الأول:
[ 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 ; }
} تريد بعد ذلك تقديم تغيير جديد بحيث تحتوي خاصية Flags على معلومات أكثر جدوى ، والاعتماد على التعداد:
[ GitFolder ( FolderName = "Items" , UseNodeFolders = false ) ]
private record SomeNodeV2 : Node
{
public BindingFlags TypedFlags { get ; set ; }
} كل ما عليك فعله هو إضافة #1 إضافة سمة [IsDeprecatedNodeType(typeof(SomeNodeV2))] . سيؤدي ذلك إلى توجيه Deserializer إلى تحويل العقد إلى إصدار جديد ، باستخدام محول. #2 يجب توفير المحول في النموذج. يمكنك استخدام السيارات أو الأدوات الأخرى على راحتك.
[ 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 ,
} ;
}انظر الوثائق.
ترخيص MIT (راجع ملف الترخيص).