-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
static methods to help get the EngineConfiguration correct depending on the usage.
- Loading branch information
Showing
18 changed files
with
375 additions
and
805 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using OrigoDB.Core; | ||
using ProtoBuf; | ||
|
||
namespace Modules.ProtoBuf.Test.Domain | ||
{ | ||
|
||
[ProtoContract(ImplicitFields=ImplicitFields.AllFields, AsReferenceDefault = true)] | ||
public class SpecialTodoItem : TodoItem | ||
{ | ||
public string SpecialValue { get; set; } | ||
} | ||
|
||
[ProtoContract(ImplicitFields = ImplicitFields.AllFields, AsReferenceDefault = true)] | ||
[ProtoInclude(100, typeof(SpecialTodoItem))] | ||
public class TodoItem | ||
{ | ||
public readonly Guid Id; | ||
public string Title { get; set; } | ||
public DateTime? Due; | ||
public DateTime? Completed; | ||
|
||
public TodoItem() | ||
{ | ||
Id = Guid.NewGuid(); | ||
Title = "No name"; | ||
} | ||
} | ||
|
||
[ProtoContract(ImplicitFields = ImplicitFields.AllFields, AsReferenceDefault = true, SkipConstructor = true)] | ||
public class Category | ||
{ | ||
public string Name { get; set; } | ||
public List<TodoItem> Items { get; set; } | ||
|
||
public Category(string name) | ||
{ | ||
Name = name; | ||
Items = new List<TodoItem>(); | ||
} | ||
} | ||
|
||
[ProtoContract(ImplicitFields = ImplicitFields.AllFields)] | ||
public class TodoModel : Model | ||
{ | ||
public Dictionary<Guid, TodoItem> Items | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
public Dictionary<string, Category> Categories | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
public TodoModel() | ||
{ | ||
Items = new Dictionary<Guid, TodoItem>(); | ||
Categories = new Dictionary<string, Category>(StringComparer.InvariantCultureIgnoreCase); | ||
} | ||
|
||
public Guid AddItem(string title) | ||
{ | ||
var item = new TodoItem{Title = title}; | ||
Items.Add(item.Id, item); | ||
return item.Id; | ||
} | ||
|
||
public Guid AddSpecialItem(string title) | ||
{ | ||
var item = new SpecialTodoItem { Title = title }; | ||
Items.Add(item.Id, item); | ||
return item.Id; | ||
} | ||
|
||
public void SetCategories(Guid itemId, params string[] categoryNames) | ||
{ | ||
TodoItem item; | ||
if (Items.TryGetValue(itemId, out item)) | ||
{ | ||
foreach (var categoryName in categoryNames) | ||
{ | ||
if (!Categories.ContainsKey(categoryName)) | ||
{ | ||
Categories.Add(categoryName, new Category(categoryName)); | ||
} | ||
Categories[categoryName].Items.Add(item); | ||
} | ||
} | ||
} | ||
|
||
[ProtoAfterDeserialization] | ||
private void FixRefsAfterDeserialization() | ||
{ | ||
foreach (var category in Categories.Values) | ||
{ | ||
for (int i = 0; i < category.Items.Count; i++) | ||
{ | ||
category.Items[i] = Items[category.Items[i].Id]; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
OrigoDB.Modules.Protobuf.Test/ProtoBufStreamHeaderTests.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.