Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
Updated the example with the new functionality
Browse files Browse the repository at this point in the history
references #23
  • Loading branch information
pvandervelde committed May 11, 2014
1 parent e1e0142 commit 09a0f13
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/nuclei.examples.complete/CommunicationInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ private void RegisterTestCommands()
var instance = m_Context.Resolve<TestCommands>();

var map = CommandMapper<ITestCommandSet>.Create();
map.From<string>((command, name) => command.Echo(name))
.To((string n) => instance.Echo(n));
map.From<string, int, int>((command, name, retry, timeout) => command.Echo(name, retry, timeout))
.To((EndpointId e, string n) => instance.Echo(e, n));

map.From<int, int>((command, first, second) => command.Calculate(first, second))
.To((int first, int second) => instance.Calculate(first, second));
Expand Down
4 changes: 2 additions & 2 deletions src/nuclei.examples.complete/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ internal static class DependencyInjection
c =>
{
var ctx = c.Resolve<IComponentContext>();
Action<string> echoAction = text =>
Action<EndpointId, string> echoAction = (id, text) =>
{
var model = ctx.Resolve<ConnectionViewModel>();
model.AddNewMessage(null, text);
model.AddNewMessage(id, text);
};
return new TestCommands(
c.Resolve<DownloadDataFromRemoteEndpoints>(),
Expand Down
6 changes: 5 additions & 1 deletion src/nuclei.examples.complete/ITestCommandSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ public interface ITestCommandSet : ICommandSet
/// Echo's the name.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="retryCount">The maximum number of times the message should be resend if the initial message send fails.</param>
/// <param name="timeoutInMilliseconds">
/// The maximum time allowed to expire between the message send and the reception of the response.
/// </param>
/// <returns>A task that returns when the echo message has been send.</returns>
Task Echo(string name);
Task Echo(string name, [InvocationRetryCount]int retryCount, [InvocationTimeout]int timeoutInMilliseconds);

/// <summary>
/// Calculates a value from two inputs.
Expand Down
10 changes: 6 additions & 4 deletions src/nuclei.examples.complete/TestCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal sealed class TestCommands
/// <summary>
/// The function called when an echo command is received.
/// </summary>
private readonly Action<string> m_OnEcho;
private readonly Action<EndpointId, string> m_OnEcho;

/// <summary>
/// Initializes a new instance of the <see cref="TestCommands"/> class.
Expand All @@ -40,7 +40,7 @@ internal sealed class TestCommands
/// <exception cref="ArgumentNullException">
/// Thrown if <paramref name="onEcho"/> is <see langword="null" />.
/// </exception>
public TestCommands(DownloadDataFromRemoteEndpoints download, Action<string> onEcho)
public TestCommands(DownloadDataFromRemoteEndpoints download, Action<EndpointId, string> onEcho)
{
{
Lokad.Enforce.Argument(() => download);
Expand All @@ -54,10 +54,11 @@ public TestCommands(DownloadDataFromRemoteEndpoints download, Action<string> onE
/// <summary>
/// Echo's the name.
/// </summary>
/// <param name="remoteEndpoint">The endpoint ID of the remote endpoint.</param>
/// <param name="name">The name.</param>
public void Echo(string name)
public void Echo([InvokingEndpoint]EndpointId remoteEndpoint, string name)
{
m_OnEcho(name);
m_OnEcho(remoteEndpoint, name);
}

/// <summary>
Expand Down Expand Up @@ -93,6 +94,7 @@ public void StartDownload([InvokingEndpoint]EndpointId downloadOwningEndpoint, U
}

m_OnEcho(
downloadOwningEndpoint,
string.Format(
CultureInfo.InvariantCulture,
"Downloaded data from: {0}. Data: {1}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void SendEchoMessageTo(EndpointId endpoint, string messageText)
if (m_Commands.HasCommandFor(endpoint, typeof(ITestCommandSet)))
{
var commands = m_Commands.CommandsFor<ITestCommandSet>(endpoint);
commands.Echo(messageText);
commands.Echo(messageText, 10, 15 * 1000);
}
}

Expand Down

7 comments on commit 09a0f13

@pvandervelde
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Nuclei :: Build Build 72 is now running

@pvandervelde
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Nuclei :: Build Build 0.7.2+318 outcome was SUCCESS
Summary: Tests passed: 1065 Build time: 0:2:53

@pvandervelde
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Nuclei :: Build Build 73 is now running

@pvandervelde
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Nuclei :: Build Build 73 outcome was FAILURE
Summary: Error message is logged (new); compilation error: src\solutionlevel\SolutionLevel.csproj (new) Build time: 0:1:21

@pvandervelde
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Nuclei :: Build Build 74 is now running

@pvandervelde
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Nuclei :: Build Build 0.7.2-PullRequest32+319 outcome was SUCCESS
Summary: Tests passed: 1065 Build time: 0:2:49

@pvandervelde
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Nuclei :: Build Build 75 is now running

Please sign in to comment.