Skip to content

Commit

Permalink
Change channel type from string to simple enum
Browse files Browse the repository at this point in the history
  • Loading branch information
bingenito committed May 5, 2023
1 parent 958cdb0 commit 5d5c896
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 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
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/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 5d5c896

Please sign in to comment.