-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
258 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Debug NineChronicles.Headless", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/NineChronicles.Headless.Executable/bin/Debug/net6/NineChronicles.Headless.Executable.dll", | ||
"cwd": "${workspaceFolder}/NineChronicles.Headless.Executable", | ||
"stopAtEntry": false, | ||
"console": "integratedTerminal", | ||
"preLaunchTask": "build", | ||
"args": [ | ||
"--config", | ||
"appsettings.local.json" | ||
] | ||
} | ||
] | ||
} |
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,41 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"build", | ||
"${workspaceFolder}/NineChronicles.Headless.Executable/NineChronicles.Headless.Executable.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"publish", | ||
"${workspaceFolder}/NineChronicles.Headless.Executable/NineChronicles.Headless.Executable.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "watch", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"watch", | ||
"run", | ||
"--project", | ||
"${workspaceFolder}/NineChronicles.Headless.Executable/NineChronicles.Headless.Executable.csproj" | ||
], | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
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,12 @@ | ||
using GraphQL.Types; | ||
|
||
namespace NineChronicles.Headless.GraphTypes.Diff; | ||
|
||
public class DiffGraphType : UnionGraphType | ||
{ | ||
public DiffGraphType() | ||
{ | ||
Type<RootStateDiffType>(); | ||
Type<StateDiffType>(); | ||
} | ||
} |
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,6 @@ | ||
namespace NineChronicles.Headless.GraphTypes.Diff; | ||
|
||
public interface IDiffType | ||
{ | ||
string Path { get; } | ||
} |
33 changes: 33 additions & 0 deletions
33
NineChronicles.Headless/GraphTypes/Diff/RootStateDiffType.cs
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,33 @@ | ||
using GraphQL.Types; | ||
|
||
namespace NineChronicles.Headless.GraphTypes.Diff; | ||
|
||
public class RootStateDiffType : ObjectGraphType<RootStateDiffType.Value> | ||
{ | ||
public class Value : IDiffType | ||
{ | ||
public string Path { get; } | ||
public StateDiffType.Value[] Diffs { get; } | ||
|
||
public Value(string path, StateDiffType.Value[] diffs) | ||
{ | ||
Path = path; | ||
Diffs = diffs; | ||
} | ||
} | ||
|
||
public RootStateDiffType() | ||
{ | ||
Name = "RootStateDiff"; | ||
|
||
Field<NonNullGraphType<StringGraphType>>( | ||
"Path", | ||
description: "The path to the root state difference." | ||
); | ||
|
||
Field<NonNullGraphType<ListGraphType<NonNullGraphType<StateDiffType>>>>( | ||
"Diffs", | ||
description: "List of state differences under this root." | ||
); | ||
} | ||
} |
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,48 @@ | ||
using Bencodex; | ||
using Bencodex.Types; | ||
using GraphQL.Types; | ||
using Libplanet.Common; | ||
|
||
namespace NineChronicles.Headless.GraphTypes.Diff; | ||
|
||
public class StateDiffType : ObjectGraphType<StateDiffType.Value> | ||
{ | ||
public class Value : IDiffType | ||
{ | ||
public string Path { get; } | ||
public IValue BaseState { get; } | ||
public IValue? ChangedState { get; } | ||
|
||
public Value(string path, IValue baseState, IValue? changedState) | ||
{ | ||
Path = path; | ||
BaseState = baseState; | ||
ChangedState = changedState; | ||
} | ||
} | ||
|
||
public StateDiffType() | ||
{ | ||
Name = "StateDiff"; | ||
|
||
Field<NonNullGraphType<StringGraphType>>( | ||
"Path", | ||
description: "The path of the state difference." | ||
); | ||
|
||
Field<NonNullGraphType<StringGraphType>>( | ||
"BaseState", | ||
description: "The base state before changes.", | ||
resolve: context => ByteUtil.Hex(new Codec().Encode(context.Source.BaseState)) | ||
); | ||
|
||
Field<StringGraphType>( | ||
"ChangedState", | ||
description: "The state after changes.", | ||
resolve: context => | ||
context.Source.ChangedState is null | ||
? null | ||
: ByteUtil.Hex(new Codec().Encode(context.Source.ChangedState)) | ||
); | ||
} | ||
} |
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