Skip to content

Commit

Permalink
Merge pull request #49 from bingenito/main
Browse files Browse the repository at this point in the history
Change channel type from string to simple enum
  • Loading branch information
psmulovics authored May 5, 2023
2 parents 958cdb0 + f227f83 commit 934484a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Examples/WpfFdc3/Fdc3/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Channel : IChannel
private readonly Dictionary<string, IContext> _lastContexts = new Dictionary<string, IContext>();
private IContext? _lastContext;

public Channel(string id, string type)
public Channel(string id, ChannelType type)
{
this.Id = id;
this.Type = type;
Expand All @@ -35,7 +35,7 @@ public Channel(string id, string type)

public string Id { get; }

public string Type { get; }
public ChannelType Type { get; }

public IDisplayMetadata? DisplayMetadata => throw new System.NotImplementedException();

Expand Down
4 changes: 2 additions & 2 deletions src/Examples/WpfFdc3/Fdc3/DesktopAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class DesktopAgent : IDesktopAgent

public DesktopAgent()
{
_channels.Add(new Channel("global", "app"));
_channels.Add(new Channel("global", ChannelType.App));
}

public Task<IListener> AddContextListener<T>(string? contextType, ContextHandler<T> handler) where T : IContext
Expand Down Expand Up @@ -99,7 +99,7 @@ public Task<IChannel> GetOrCreateChannel(string channelId)
IChannel channel = _channels.First<IChannel>(channel => channel.Id == channelId);
if (channel == null)
{
channel = new Channel(channelId, "app");
channel = new Channel(channelId, ChannelType.App);
_channels.Add(channel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<RootNamespace>MorganStanley.Fdc3.NewtonsoftJson</RootNamespace>
<AssemblyName>MorganStanley.Fdc3.NewtonsoftJson</AssemblyName>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionSuffix>alpha.3</VersionSuffix>
<VersionSuffix>alpha.4</VersionSuffix>
<Product>.NET FDC3 Newtonsoft JSON</Product>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\keypair.snk</AssemblyOriginatorKeyFile>
Expand Down
23 changes: 23 additions & 0 deletions src/Fdc3/ChannelType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Morgan Stanley makes this available to you under the Apache License,
* Version 2.0 (the "License"). You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. Unless required by applicable law or agreed
* to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

namespace MorganStanley.Fdc3
{
public enum ChannelType
{
User = 1,
App = 2,
Private = 3
}
}
2 changes: 1 addition & 1 deletion src/Fdc3/IChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface IChannel: IIntentResult
/// <summary>
/// Uniquely defines each channel type.
/// </summary>
string Type { get; }
ChannelType Type { get; }

/// <summary>
/// Channels may be visualized and selectable by users. DisplayMetadata may be used to provide hints on how to see them.
Expand Down
2 changes: 1 addition & 1 deletion src/Fdc3/MorganStanley.Fdc3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<RootNamespace>MorganStanley.Fdc3</RootNamespace>
<AssemblyName>MorganStanley.Fdc3</AssemblyName>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionSuffix>alpha.3</VersionSuffix>
<VersionSuffix>alpha.4</VersionSuffix>
<Product>.NET FDC3</Product>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\keypair.snk</AssemblyOriginatorKeyFile>
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/MorganStanley.Fdc3.Tests/IChannelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private class MockChannel : IChannel

public string Id => throw new NotImplementedException();

public string Type => throw new NotImplementedException();
public ChannelType Type => throw new NotImplementedException();

public IDisplayMetadata? DisplayMetadata => throw new NotImplementedException();

Expand Down

0 comments on commit 934484a

Please sign in to comment.