Skip to content

Commit 6397b73

Browse files
condronjoshkempner
authored andcommitted
Add metadata and opt-in user audit
1 parent 82c25e2 commit 6397b73

File tree

84 files changed

+2199
-564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2199
-564
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.4.33205.214
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleMetadata", "SimpleMetadata\SimpleMetadata.csproj", "{5D07F2E4-0E18-45B0-9892-301D0F376674}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PersistedMetadata", "PersistedMetadata\PersistedMetadata.csproj", "{E7948E00-48F4-40EC-AEA7-95D4D980FF3A}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E37482FD-52F2-4C89-80A8-635EC3D17626}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{5D07F2E4-0E18-45B0-9892-301D0F376674}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{5D07F2E4-0E18-45B0-9892-301D0F376674}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{5D07F2E4-0E18-45B0-9892-301D0F376674}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{5D07F2E4-0E18-45B0-9892-301D0F376674}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{E7948E00-48F4-40EC-AEA7-95D4D980FF3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{E7948E00-48F4-40EC-AEA7-95D4D980FF3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{E7948E00-48F4-40EC-AEA7-95D4D980FF3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{E7948E00-48F4-40EC-AEA7-95D4D980FF3A}.Release|Any CPU.Build.0 = Release|Any CPU
26+
EndGlobalSection
27+
GlobalSection(SolutionProperties) = preSolution
28+
HideSolutionNode = FALSE
29+
EndGlobalSection
30+
GlobalSection(ExtensibilityGlobals) = postSolution
31+
SolutionGuid = {2C267E53-266D-4E15-8F57-4014069A253C}
32+
EndGlobalSection
33+
EndGlobal

Samples/Metadata/PersistedMetadata/MessageWindow.Designer.cs

Lines changed: 243 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
//------------------------------------------------------------------------------
3+
4+
// <auto-generated>
5+
// This code was generated by:
6+
// TerminalGuiDesigner v1.0.23.0
7+
// You can make changes to this file and they will not be overwritten when saving.
8+
// </auto-generated>
9+
// -----------------------------------------------------------------------------
10+
namespace Sample1
11+
{
12+
using Metadata_Sample_App;
13+
using ReactiveDomain;
14+
using ReactiveDomain.Messaging;
15+
using ReactiveDomain.Messaging.Bus;
16+
using Terminal.Gui;
17+
18+
19+
public partial class MessageWindow
20+
{
21+
private IBus _bus;
22+
private Messages.Sender _currentUser;
23+
public MessageWindow(InMemoryBus bus)
24+
{
25+
_bus = bus;
26+
InitializeComponent();
27+
quit.Clicked += () => Application.RequestStop();
28+
bus.Subscribe(new AdHocHandler<Messages.Greeting>(msg => RecieveGreetings(msg)));
29+
bus.Subscribe(new AdHocHandler<Messages.Farewell>(msg => RecieveFarewells(msg)));
30+
sendGreeting.Clicked += SendGreetings;
31+
sendFarewell.Clicked += SendFarewell;
32+
editMeMenuItem1.Action = () => { _currentUser = new Messages.Sender() { Name = "Alice" }; senderName.Text = _currentUser.Name; };
33+
editMeMenuItem2.Action = () => { _currentUser = new Messages.Sender() { Name = "Bob" }; senderName.Text = _currentUser.Name; };
34+
}
35+
private bool TryGetCurrentUser(out Messages.Sender user)
36+
{
37+
user = _currentUser;
38+
if (_currentUser == null)
39+
{
40+
MessageBox.Query(55, 7, "Error", "Please login via the login menu at the top ^^^ first.", "Ok");
41+
return false;
42+
}
43+
return true;
44+
}
45+
46+
public void SendGreetings()
47+
{
48+
//get the logged in user
49+
if(!TryGetCurrentUser(out var user)){ return;}
50+
//create message with greeting data
51+
var msg = new Messages.Greeting((string)msgText.Text);
52+
//add sender metadata to the message
53+
msg.WriteMetadatum<Messages.Sender>(user);
54+
_bus.Publish(msg);
55+
}
56+
public void SendFarewell()
57+
{
58+
//get the logged in user
59+
if(!TryGetCurrentUser(out var user)){ return;}
60+
//create message with Frarewell data
61+
var msg = new Messages.Farewell((string)msgText.Text);
62+
//add sender metadat to the message
63+
msg.WriteMetadatum<Messages.Sender>(user);
64+
_bus.Publish(msg);
65+
}
66+
public void RecieveGreetings(Messages.Greeting msg)
67+
{
68+
// message type
69+
msgType.Text = msg.GetType().Name;
70+
71+
//read message data
72+
msgTextRecieved.Text = msg.Text;
73+
74+
//read sender metadata
75+
msgFrom.Text = msg.ReadMetadatum<Messages.Sender>().Name;
76+
}
77+
public void RecieveFarewells(Messages.Farewell msg)
78+
{
79+
//message type
80+
msgType.Text = msg.GetType().Name;
81+
82+
//read message data
83+
msgTextRecieved.Text = msg.Text;
84+
85+
//read sender metadata
86+
msgFrom.Text = msg.ReadMetadatum<Messages.Sender>().Name;
87+
}
88+
}
89+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using ReactiveDomain.Messaging;
2+
3+
namespace Metadata_Sample_App
4+
{
5+
public class Messages
6+
{
7+
public class Greeting : Message
8+
{
9+
public readonly string Text;
10+
public Greeting(string text)
11+
{
12+
Text = text;
13+
}
14+
}
15+
public class Farewell : Message
16+
{
17+
public readonly string Text;
18+
public Farewell(string text)
19+
{
20+
Text = text;
21+
}
22+
}
23+
public class Sender
24+
{
25+
public string Name;
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)