-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
5 changed files
with
224 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
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
57 changes: 57 additions & 0 deletions
57
Skclusive.Blazor.FlightFinder/FlightFinder.App.State/Models/Branch.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,57 @@ | ||
using Skclusive.Mobx.Observable; | ||
using Skclusive.Mobx.StateTree; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Skclusive.FlightFinder.App.State | ||
{ | ||
public interface IBranchSnapshot | ||
{ | ||
string Name { set; get; } | ||
} | ||
|
||
public interface IBranchActions | ||
{ | ||
void EditName(string name); | ||
} | ||
|
||
public interface IBranch : IBranchSnapshot, IBranchActions | ||
{ | ||
} | ||
|
||
internal class BranchSnapshot : IBranchSnapshot | ||
{ | ||
public string Name { set; get; } | ||
} | ||
|
||
internal class BranchProxy : ObservableProxy<IBranch, INode>, IBranch | ||
{ | ||
public override IBranch Proxy => this; | ||
|
||
public BranchProxy(IObservableObject<IBranch, INode> target) : base(target) | ||
{ | ||
} | ||
|
||
public new string Name | ||
{ | ||
get => Read<string>(nameof(Name)); | ||
set => Write(nameof(Name), value); | ||
} | ||
|
||
public void EditName(string name) | ||
{ | ||
(Target as dynamic).EditName(name); | ||
} | ||
} | ||
|
||
|
||
public partial class AppTypes | ||
{ | ||
public readonly static IObjectType<IBranchSnapshot, IBranch> BranchType = Types | ||
.Object<IBranchSnapshot, IBranch>("IBranch") | ||
.Proxy(x => new BranchProxy(x)) | ||
.Snapshot(() => new BranchSnapshot()) | ||
.Mutable(o => o.Name, Types.String) | ||
.Action<string>(o => o.EditName(default), (o, name) => o.Name = name); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
Skclusive.Blazor.FlightFinder/FlightFinder.App.State/Models/Root.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,56 @@ | ||
using Skclusive.Core.Collection; | ||
using Skclusive.Mobx.Observable; | ||
using Skclusive.Mobx.StateTree; | ||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
|
||
namespace Skclusive.FlightFinder.App.State | ||
{ | ||
#region IRoot | ||
|
||
public interface IRootSnapshot | ||
{ | ||
ITreeSnapshot Tree { set; get; } | ||
} | ||
|
||
public interface IRootActions | ||
{ | ||
} | ||
|
||
public interface IRoot : IRootActions | ||
{ | ||
ITree Tree { set; get; } | ||
} | ||
|
||
internal class RootSnapshot : IRootSnapshot | ||
{ | ||
public ITreeSnapshot Tree { set; get; } | ||
} | ||
|
||
internal class RootProxy : ObservableProxy<IRoot, INode>, IRoot | ||
{ | ||
public override IRoot Proxy => this; | ||
|
||
public RootProxy(IObservableObject<IRoot, INode> target) : base(target) | ||
{ | ||
} | ||
|
||
public ITree Tree | ||
{ | ||
get => Read<ITree>(nameof(Tree)); | ||
set => Write(nameof(Tree), value); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
public partial class AppTypes | ||
{ | ||
public readonly static IObjectType<IRootSnapshot, IRoot> RootType = Types. | ||
Object<IRootSnapshot, IRoot>("Root") | ||
.Proxy(x => new RootProxy(x)) | ||
.Snapshot(() => new RootSnapshot()) | ||
.Mutable(o => o.Tree, Types.Late("LateTree", () => TreeType)); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
Skclusive.Blazor.FlightFinder/FlightFinder.App.State/Models/Tree.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,63 @@ | ||
using Skclusive.Core.Collection; | ||
using Skclusive.Mobx.Observable; | ||
using Skclusive.Mobx.StateTree; | ||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
|
||
namespace Skclusive.FlightFinder.App.State | ||
{ | ||
#region ITree | ||
|
||
public interface ITreeSnapshot | ||
{ | ||
IBranchSnapshot[] Branches { set; get; } | ||
} | ||
|
||
public interface ITreeActions | ||
{ | ||
void AddBranch(IBranchSnapshot branch); | ||
} | ||
|
||
public interface ITree : ITreeActions | ||
{ | ||
IList<IBranch> Branches { set; get; } | ||
} | ||
|
||
internal class TreeSnapshot : ITreeSnapshot | ||
{ | ||
public IBranchSnapshot[] Branches { set; get; } | ||
} | ||
|
||
internal class TreeProxy : ObservableProxy<ITree, INode>, ITree | ||
{ | ||
public override ITree Proxy => this; | ||
|
||
public TreeProxy(IObservableObject<ITree, INode> target) : base(target) | ||
{ | ||
} | ||
|
||
public IList<IBranch> Branches | ||
{ | ||
get => Read<IList<IBranch>>(nameof(Branches)); | ||
set => Write(nameof(Branches), value); | ||
} | ||
|
||
public void AddBranch(IBranchSnapshot branch) | ||
{ | ||
(Target as dynamic).AddBranch(branch); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
public partial class AppTypes | ||
{ | ||
public readonly static IObjectType<ITreeSnapshot, ITree> TreeType = Types. | ||
Object<ITreeSnapshot, ITree>("Tree") | ||
.Proxy(x => new TreeProxy(x)) | ||
.Snapshot(() => new TreeSnapshot()) | ||
.Mutable(o => o.Branches, Types.List(Types.Late("LateBranch", () => BranchType))) | ||
.Action<IBranchSnapshot>(o => o.AddBranch(default), (o, branch) => o.Branches.Add(BranchType.Create(branch))); | ||
} | ||
} |