CreateCandidateListFromPSERecords(TLVList directoryEntries) { List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > candidateList = new List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> >(); foreach (TLV tlv in directoryEntries) { TLV adfNameTag = tlv.Children.Get(EMVTagsEnum.APPLICATION_DEDICATED_FILE_ADF_NAME_4F_KRN.Tag); TLV applicationPriorityIndicatorTag = tlv.Children.Get(EMVTagsEnum.APPLICATION_PRIORITY_INDICATOR_87_KRN.Tag); Optional <TLV> extendedSelectionTag = Optional <TLV> .Create(tlv.Children.Get(EMVTagsEnum.EXTENDED_SELECTION_9F29_KRN.Tag)); TLV preferedName = tlv.Children.Get(EMVTagsEnum.APPLICATION_PREFERRED_NAME_9F12_KRN.Tag); TLV appLabel = tlv.Children.Get(EMVTagsEnum.APPLICATION_LABEL_50_KRN.Tag); if (adfNameTag == null) { break; } if (adfNameTag.Value.Length < 5 || adfNameTag.Value.Length > 16) { break; } foreach (TerminalSupportedKernelAidTransactionTypeCombination kc in TerminalSupportedKernelAidTransactionTypeCombinations.SupportedContactCombinations) { string terminalAID = Enum.GetName(typeof(AIDEnum), ((TerminalSupportedContactKernelAidTransactionTypeCombination)kc).AIDEnum); string cardAid = Formatting.ByteArrayToHexString(adfNameTag.Value); if (terminalAID != cardAid && !cardAid.StartsWith(terminalAID)) { continue; } if (terminalAID == cardAid) { //full match } if (cardAid.StartsWith(terminalAID)) { //matching aid, partial match, check if partial match allowed if (!((TerminalSupportedContactKernelAidTransactionTypeCombination)kc).ApplicationSelectionIndicator) { continue; } } candidateList.Add(Tuple.Create(kc, new CardKernelAidCombination() { AdfNameTag = adfNameTag, ApplicationPriorityIndicatorTag = applicationPriorityIndicatorTag, ApplicationPreferredName = preferedName, ApplicationLabel = appLabel, ExtendedSelectionTag = extendedSelectionTag, })); } } return(candidateList); }
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> public static async Task <RestTextChannel> CreateTextChannelAsync(IGuild guild, BaseDiscordClient client, string name, RequestOptions options, Action <TextChannelProperties> func = null) { if (name == null) { throw new ArgumentNullException(paramName: nameof(name)); } TextChannelProperties props = new TextChannelProperties(); func?.Invoke(props); CreateGuildChannelParams args = new CreateGuildChannelParams(name, ChannelType.Text) { CategoryId = props.CategoryId, Topic = props.Topic, IsNsfw = props.IsNsfw, Position = props.Position, SlowModeInterval = props.SlowModeInterval, Overwrites = props.PermissionOverwrites.IsSpecified ? props.PermissionOverwrites.Value.Select(overwrite => new API.OverwriteJson { TargetId = overwrite.TargetId, TargetType = overwrite.TargetType, Allow = overwrite.Permissions.AllowValue, Deny = overwrite.Permissions.DenyValue }).ToArray() : Optional.Create <API.OverwriteJson[]>(), }; ChannelJson model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return(RestTextChannel.Create(client, guild, model)); }
public static async Task AddGuildUserAsync(ulong guildId, BaseDiscordClient client, ulong userId, string accessToken, Action <AddGuildUserProperties> func, RequestOptions options) { AddGuildUserProperties args = new AddGuildUserProperties(); func?.Invoke(args); if (args.Roles.IsSpecified) { IEnumerable <ulong> ids = args.Roles.Value.Select(r => r.Id); if (args.RoleIds.IsSpecified) { args.RoleIds.Value.Concat(ids); } else { args.RoleIds = Optional.Create(ids); } } AddGuildMemberParams apiArgs = new AddGuildMemberParams { AccessToken = accessToken, Nickname = args.Nickname, IsDeafened = args.Deaf, IsMuted = args.Mute, RoleIds = args.RoleIds.IsSpecified ? args.RoleIds.Value.Distinct().ToArray() : Optional.Create <ulong[]>() }; await client.ApiClient.AddGuildMemberAsync(guildId, userId, apiArgs, options); }
public void Close_should_dispose_cursor_only_once([Values(false, true)] bool async) { int testCursorId = 1; var mockChannelHandle = new Mock <IChannelHandle>(); var mockChannelSource = new Mock <IChannelSource>(); SetupChannelMocks(mockChannelSource, mockChannelHandle, async, $"{{ 'ok' : true, 'cursorsNotFound' : [], 'cursorsKilled' : [{testCursorId}] }}"); var subject = CreateSubject(cursorId: 1, channelSource: Optional.Create(mockChannelSource.Object)); if (async) { subject.CloseAsync().Wait(); VerifyHowManyTimesKillCursorsCommandWasCalled(mockChannelHandle, Times.Once(), async); subject.CloseAsync().Wait(); VerifyHowManyTimesKillCursorsCommandWasCalled(mockChannelHandle, Times.Once(), async); } else { subject.Close(); VerifyHowManyTimesKillCursorsCommandWasCalled(mockChannelHandle, Times.Once(), async); subject.Close(); VerifyHowManyTimesKillCursorsCommandWasCalled(mockChannelHandle, Times.Once(), async); } }
public void Close_should_call_supported_kill_cursors(bool async, string version) { bool isKillCursorsCommandSupported = Feature.KillCursorsCommand.IsSupported(SemanticVersion.Parse(version)); var mockChannelHandle = new Mock <IChannelHandle>(); int testCursorId = 1; var mockChannelSource = new Mock <IChannelSource>(); SetupChannelMocks(mockChannelSource, mockChannelHandle, async, $"{{ 'ok' : true, 'cursorsNotFound' : [], 'cursorsKilled' : [{testCursorId}] }}", version); var subject = CreateSubject(cursorId: testCursorId, channelSource: Optional.Create(mockChannelSource.Object)); if (async) { subject.CloseAsync().Wait(); } else { subject.Close(); } VerifyHowManyTimesKillCursorsWasCalled( mockChannelHandle, isKillCursorsCommandSupported ? Times.Never() : Times.Once(), async); VerifyHowManyTimesKillCursorsCommandWasCalled( mockChannelHandle, isKillCursorsCommandSupported ? Times.Once() : Times.Never(), async); }
// methods /// <summary> /// Returns a new ClusterSettings instance with some settings changed. /// </summary> /// <param name="connectionMode">The connection mode.</param> /// <param name="connectionModeSwitch">The connection mode switch.</param> /// <param name="directConnection">The directConnection.</param> /// <param name="endPoints">The end points.</param> /// <param name="kmsProviders">The kms providers.</param> /// <param name="localThreshold">The local threshold.</param> /// <param name="maxServerSelectionWaitQueueSize">Maximum size of the server selection wait queue.</param> /// <param name="replicaSetName">Name of the replica set.</param> /// <param name="serverSelectionTimeout">The server selection timeout.</param> /// <param name="preServerSelector">The pre server selector.</param> /// <param name="postServerSelector">The post server selector.</param> /// <param name="schemaMap">The schema map.</param> /// <param name="scheme">The connection string scheme.</param> /// <returns>A new ClusterSettings instance.</returns> public ClusterSettings With( #pragma warning disable CS0618 // Type or member is obsolete Optional <ClusterConnectionMode> connectionMode = default(Optional <ClusterConnectionMode>), Optional <ConnectionModeSwitch> connectionModeSwitch = default, #pragma warning restore CS0618 // Type or member is obsolete Optional <bool?> directConnection = default, Optional <IEnumerable <EndPoint> > endPoints = default(Optional <IEnumerable <EndPoint> >), Optional <IReadOnlyDictionary <string, IReadOnlyDictionary <string, object> > > kmsProviders = default(Optional <IReadOnlyDictionary <string, IReadOnlyDictionary <string, object> > >), Optional <TimeSpan> localThreshold = default(Optional <TimeSpan>), Optional <int> maxServerSelectionWaitQueueSize = default(Optional <int>), Optional <string> replicaSetName = default(Optional <string>), Optional <TimeSpan> serverSelectionTimeout = default(Optional <TimeSpan>), Optional <IServerSelector> preServerSelector = default(Optional <IServerSelector>), Optional <IServerSelector> postServerSelector = default(Optional <IServerSelector>), Optional <IReadOnlyDictionary <string, BsonDocument> > schemaMap = default(Optional <IReadOnlyDictionary <string, BsonDocument> >), Optional <ConnectionStringScheme> scheme = default(Optional <ConnectionStringScheme>)) { return(new ClusterSettings( connectionMode: connectionMode.WithDefault(_connectionMode), connectionModeSwitch: connectionModeSwitch.WithDefault(_connectionModeSwitch), directConnection: directConnection.WithDefault(_directConnection), endPoints: Optional.Enumerable(endPoints.WithDefault(_endPoints)), kmsProviders: Optional.Create(kmsProviders.WithDefault(_kmsProviders)), localThreshold: localThreshold.WithDefault(_localThreshold), maxServerSelectionWaitQueueSize: maxServerSelectionWaitQueueSize.WithDefault(_maxServerSelectionWaitQueueSize), replicaSetName: replicaSetName.WithDefault(_replicaSetName), serverSelectionTimeout: serverSelectionTimeout.WithDefault(_serverSelectionTimeout), preServerSelector: Optional.Create(preServerSelector.WithDefault(_preServerSelector)), postServerSelector: Optional.Create(postServerSelector.WithDefault(_postServerSelector)), schemaMap: Optional.Create(schemaMap.WithDefault(_schemaMap)), scheme: scheme.WithDefault(_scheme))); }
// methods /// <summary> /// Returns a new ClusterSettings instance with some settings changed. /// </summary> /// <param name="connectionMode">The connection mode.</param> /// <param name="endPoints">The end points.</param> /// <param name="kmsProviders">The kms providers.</param> /// <param name="localThreshold">The local threshold.</param> /// <param name="maxServerSelectionWaitQueueSize">Maximum size of the server selection wait queue.</param> /// <param name="replicaSetName">Name of the replica set.</param> /// <param name="serverSelectionTimeout">The server selection timeout.</param> /// <param name="preServerSelector">The pre server selector.</param> /// <param name="postServerSelector">The post server selector.</param> /// <param name="schemaMap">The schema map.</param> /// <param name="scheme">The connection string scheme.</param> /// <returns>A new ClusterSettings instance.</returns> public ClusterSettings With( Optional <ClusterConnectionMode> connectionMode = default(Optional <ClusterConnectionMode>), Optional <IEnumerable <EndPoint> > endPoints = default(Optional <IEnumerable <EndPoint> >), Optional <IReadOnlyDictionary <string, IReadOnlyDictionary <string, object> > > kmsProviders = default(Optional <IReadOnlyDictionary <string, IReadOnlyDictionary <string, object> > >), Optional <TimeSpan> localThreshold = default(Optional <TimeSpan>), Optional <int> maxServerSelectionWaitQueueSize = default(Optional <int>), Optional <string> replicaSetName = default(Optional <string>), Optional <TimeSpan> serverSelectionTimeout = default(Optional <TimeSpan>), Optional <IServerSelector> preServerSelector = default(Optional <IServerSelector>), Optional <IServerSelector> postServerSelector = default(Optional <IServerSelector>), Optional <IReadOnlyDictionary <string, BsonDocument> > schemaMap = default(Optional <IReadOnlyDictionary <string, BsonDocument> >), Optional <ConnectionStringScheme> scheme = default(Optional <ConnectionStringScheme>)) { return(new ClusterSettings( connectionMode: connectionMode.WithDefault(_connectionMode), endPoints: Optional.Enumerable(endPoints.WithDefault(_endPoints)), kmsProviders: Optional.Create(kmsProviders.WithDefault(_kmsProviders)), localThreshold: localThreshold.WithDefault(_localThreshold), maxServerSelectionWaitQueueSize: maxServerSelectionWaitQueueSize.WithDefault(_maxServerSelectionWaitQueueSize), replicaSetName: replicaSetName.WithDefault(_replicaSetName), serverSelectionTimeout: serverSelectionTimeout.WithDefault(_serverSelectionTimeout), preServerSelector: Optional.Create(preServerSelector.WithDefault(_preServerSelector)), postServerSelector: Optional.Create(postServerSelector.WithDefault(_postServerSelector)), schemaMap: Optional.Create(schemaMap.WithDefault(_schemaMap)), scheme: scheme.WithDefault(_scheme))); }
public static async Task <Model> ModifyAsync(IVoiceChannel channel, BaseDiscordClient client, Action <VoiceChannelProperties> func, RequestOptions options) { var args = new VoiceChannelProperties(); func(args); var apiArgs = new API.Rest.ModifyVoiceChannelParams { Bitrate = args.Bitrate, Name = args.Name, RTCRegion = args.RTCRegion, Position = args.Position, CategoryId = args.CategoryId, UserLimit = args.UserLimit.IsSpecified ? (args.UserLimit.Value ?? 0) : Optional.Create <int>(), Overwrites = args.PermissionOverwrites.IsSpecified ? args.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite { TargetId = overwrite.TargetId, TargetType = overwrite.TargetType, Allow = overwrite.Permissions.AllowValue.ToString(), Deny = overwrite.Permissions.DenyValue.ToString() }).ToArray() : Optional.Create <API.Overwrite[]>(), }; return(await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false)); }
public static async Task <Model> ModifyAsync(IGuildChannel channel, BaseDiscordClient client, Action <GuildChannelProperties> func, RequestOptions options) { GuildChannelProperties args = new GuildChannelProperties(); func(args); ModifyGuildChannelParams apiArgs = new API.Rest.ModifyGuildChannelParams { Name = args.Name, Position = args.Position, CategoryId = args.CategoryId, Overwrites = args.PermissionOverwrites.IsSpecified ? args.PermissionOverwrites.Value.Select(overwrite => new API.OverwriteJson { TargetId = overwrite.TargetId, TargetType = overwrite.TargetType, Allow = overwrite.Permissions.AllowValue, Deny = overwrite.Permissions.DenyValue }).ToArray() : Optional.Create <API.OverwriteJson[]>() }; return(await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false)); }
public async Task <Optional <ExplicitConnection> > Select(DependencyObject nearTo) { if (nearTo == null) { throw new ArgumentNullException(nameof(nearTo)); } ExplicitConnection explicitConnection; if (!_explicitConnectionCache.Any()) { var connectionEditor = new ConnectionEditor(); explicitConnection = await nearTo.ShowDialog(connectionEditor, delegate(object sender, DialogOpenedEventArgs args) { var connectionEditorViewModel = new ConnectionEditorViewModel(vm => SaveHandler(vm, args.Session), args.Session.Close); connectionEditor.DataContext = connectionEditorViewModel; }) as ExplicitConnection; return(Optional <ExplicitConnection> .Create(explicitConnection)); } var connectionsManager = new ConnectionsManager(); explicitConnection = await nearTo.ShowDialog(connectionsManager, delegate(object sender, DialogOpenedEventArgs args) { var connectionsManagerViewModel = new ConnectionsManagerViewModel(_explicitConnectionCache); connectionsManager.DataContext = connectionsManagerViewModel; }) as ExplicitConnection; return(Optional <ExplicitConnection> .Create(explicitConnection)); }
public async Task ModifyAsync(Action <ModifyGuildMemberParams> func) { if (func == null) { throw new NullReferenceException(nameof(func)); } var args = new ModifyGuildMemberParams(); func(args); bool isCurrentUser = (await Discord.GetCurrentUserAsync().ConfigureAwait(false)).Id == Id; if (isCurrentUser && args._nickname.IsSpecified) { var nickArgs = new ModifyCurrentUserNickParams { Nickname = args._nickname.Value ?? "" }; await Discord.ApiClient.ModifyMyNickAsync(Guild.Id, nickArgs).ConfigureAwait(false); args._nickname = Optional.Create <string>(); //Remove } if (!isCurrentUser || args._deaf.IsSpecified || args._mute.IsSpecified || args._roleIds.IsSpecified) { await Discord.ApiClient.ModifyGuildMemberAsync(Guild.Id, Id, args).ConfigureAwait(false); Update(args, UpdateSource.Rest); } }
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> public static async Task <RestCategoryChannel> CreateCategoryChannelAsync(IGuild guild, BaseDiscordClient client, string name, RequestOptions options, Action <GuildChannelProperties> func = null) { if (name == null) { throw new ArgumentNullException(paramName: nameof(name)); } var props = new GuildChannelProperties(); func?.Invoke(props); var args = new CreateGuildChannelParams(name, ChannelType.Category) { Position = props.Position, Overwrites = props.PermissionOverwrites.IsSpecified ? props.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite { TargetId = overwrite.TargetId, TargetType = overwrite.TargetType, Allow = overwrite.Permissions.AllowValue, Deny = overwrite.Permissions.DenyValue }).ToArray() : Optional.Create <API.Overwrite[]>(), }; var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return(RestCategoryChannel.Create(client, guild, model)); }
//Users public static async Task <RestGuildUser> AddGuildUserAsync(IGuild guild, BaseDiscordClient client, ulong userId, string accessToken, Action <AddGuildUserProperties> func, RequestOptions options) { var args = new AddGuildUserProperties(); func?.Invoke(args); if (args.Roles.IsSpecified) { var ids = args.Roles.Value.Select(r => r.Id); if (args.RoleIds.IsSpecified) { args.RoleIds.Value.Concat(ids); } else { args.RoleIds = Optional.Create(ids); } } var apiArgs = new AddGuildMemberParams { AccessToken = accessToken, Nickname = args.Nickname, IsDeafened = args.Deaf, IsMuted = args.Mute, RoleIds = args.RoleIds.IsSpecified ? args.RoleIds.Value.Distinct().ToArray() : Optional.Create <ulong[]>() }; var model = await client.ApiClient.AddGuildMemberAsync(guild.Id, userId, apiArgs, options); return(model is null ? null : RestGuildUser.Create(client, guild, model)); }
public Select(SelectOptions <T> options) : base(false) { _paginator = new Paginator <T>(options.Items, options.PageSize, Optional <T> .Create(options.DefaultValue), options.TextSelector); _options = options; }
public void MatchLeft_correctly_applies_logic_to_left() { var either = new LeftOrRight(new Left("Frodo")); var result = either.MatchLeft(x => x.Name); Assert.Equal(Optional.Create("Frodo"), result); }
public void Close_should_call_supported_kill_cursors([Values(false, true)] bool async) { var mockChannelHandle = new Mock <IChannelHandle>(); int testCursorId = 1; var mockChannelSource = new Mock <IChannelSource>(); SetupChannelMocks(mockChannelSource, mockChannelHandle, async, $"{{ 'ok' : true, 'cursorsNotFound' : [], 'cursorsKilled' : [{testCursorId}] }}", maxWireVersion: WireVersion.Server32); var subject = CreateSubject(cursorId: testCursorId, channelSource: Optional.Create(mockChannelSource.Object)); if (async) { subject.CloseAsync().Wait(); } else { subject.Close(); } VerifyHowManyTimesKillCursorsCommandWasCalled( mockChannelHandle, Times.Once(), async); }
public static async Task <Model> ModifyAsync(IWebhook webhook, BaseDiscordClient client, Action <WebhookProperties> func, RequestOptions options) { var args = new WebhookProperties(); func(args); var apiArgs = new ModifyWebhookParams { Avatar = args.Image.IsSpecified ? args.Image.Value?.ToModel() : Optional.Create <ImageModel?>(), Name = args.Name }; if (!apiArgs.Avatar.IsSpecified && webhook.AvatarId != null) { apiArgs.Avatar = new ImageModel(webhook.AvatarId); } if (args.Channel.IsSpecified) { apiArgs.ChannelId = args.Channel.Value.Id; } else if (args.ChannelId.IsSpecified) { apiArgs.ChannelId = args.ChannelId.Value; } return(await client.ApiClient.ModifyWebhookAsync(webhook.Id, apiArgs, options).ConfigureAwait(false)); }
public static async Task <Model> ModifyAsync(IRole role, BaseDiscordClient client, Action <RoleProperties> func, RequestOptions options) { var args = new RoleProperties(); func(args); var apiArgs = new API.Rest.ModifyGuildRoleParams { Color = args.Color.IsSpecified ? args.Color.Value.RawValue : Optional.Create <uint>(), Hoist = args.Hoist, Mentionable = args.Mentionable, Name = args.Name, Permissions = args.Permissions.IsSpecified ? args.Permissions.Value.RawValue.ToString() : Optional.Create <string>() }; var model = await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, apiArgs, options).ConfigureAwait(false); if (args.Position.IsSpecified) { var bulkArgs = new[] { new BulkParams(role.Id, args.Position.Value) }; await client.ApiClient.ModifyGuildRolesAsync(role.Guild.Id, bulkArgs, options).ConfigureAwait(false); model.Position = args.Position.Value; } return(model); }
public CreateApplicationCommandParams(string name, string description, ApplicationCommandType type, ApplicationCommandOption[] options = null) { Name = name; Description = description; Options = Optional.Create(options); Type = type; }
public Optional <FIDBase> FindFid(FIDMeta meta) { FIDBase fidFound = null; foreach (FIDBase fid in Fids) { if (fid.Children.Count == 0) { if (fid.Id == meta.Id && fid.SubId == meta.SubId) { fidFound = fid; } } else { foreach (FIDBase fidChild in fid.Children) { if (fidChild.Id == meta.Id && fidChild.SubId == meta.SubId) { fidFound = fidChild; } } } } if (fidFound != null) { return(Optional <FIDBase> .Create(fidFound)); } else { return(Optional <FIDBase> .CreateEmpty()); } }
public static async Task <Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client, Action <TextChannelProperties> func, RequestOptions options) { var args = new TextChannelProperties(); func(args); var apiArgs = new API.Rest.ModifyTextChannelParams { Name = args.Name, Position = args.Position, CategoryId = args.CategoryId, Topic = args.Topic, IsNsfw = args.IsNsfw, SlowModeInterval = args.SlowModeInterval, Overwrites = args.PermissionOverwrites.IsSpecified ? args.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite { TargetId = overwrite.TargetId, TargetType = overwrite.TargetType, Allow = overwrite.Permissions.AllowValue.ToString(), Deny = overwrite.Permissions.DenyValue.ToString() }).ToArray() : Optional.Create <API.Overwrite[]>(), }; return(await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false)); }
/// <exception cref="InvalidOperationException">Only the author of a message may modify the message.</exception> /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> public static async Task <Model> ModifyAsync(IMessage msg, BaseDiscordClient client, Action <MessageProperties> func, RequestOptions options) { if (msg.Author.Id != client.CurrentUser.Id) { throw new InvalidOperationException("Only the author of a message may modify the message."); } var args = new MessageProperties(); func(args); bool hasText = args.Content.IsSpecified ? !string.IsNullOrEmpty(args.Content.Value) : !string.IsNullOrEmpty(msg.Content); bool hasEmbed = args.Embed.IsSpecified ? args.Embed.Value != null : msg.Embeds.Any(); if (!hasText && !hasEmbed) { Preconditions.NotNullOrEmpty(args.Content.IsSpecified ? args.Content.Value : string.Empty, nameof(args.Content)); } var apiArgs = new API.Rest.ModifyMessageParams { Content = args.Content, Embed = args.Embed.IsSpecified ? args.Embed.Value.ToModel() : Optional.Create <API.Embed>() }; return(await client.ApiClient.ModifyMessageAsync(msg.Channel.Id, msg.Id, apiArgs, options).ConfigureAwait(false)); }
public void constructor_should_dispose_channel_source_when_cursor_id_is_zero() { var mockChannelSource = new Mock <IChannelSource>(); var subject = CreateSubject(cursorId: 0, channelSource: Optional.Create(mockChannelSource.Object)); mockChannelSource.Verify(s => s.Dispose(), Times.Once); }
public void MatchOptional_correctly_applies_logic_to_right() { var either = new LeftOrRight(new Right(4)); var result = either.MatchRight(x => x.Number * 2); Assert.Equal(Optional.Create <int>(8), result); }
CandidatesPrioritizeAndPromptUser(List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > candidateList, IUICallbackProvider uiProvider) { if (candidateList.Count == 1) { #region 12.3.2 Book1 12.4 Step 2 if ((candidateList.ElementAt(0).Item2.ApplicationPriorityIndicatorTag.Value[0] & 0x80) == 0x00) { return(Optional <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > .Create(new Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination>(candidateList.ElementAt(0).Item1, candidateList.ElementAt(0).Item2))); } #endregion } #region 12.3.2 Book1 12.4 Step 4 List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > filteredNoZero = candidateList.Where(x => { if (x.Item2.ApplicationPriorityIndicatorTag != null) { if ((x.Item2.ApplicationPriorityIndicatorTag.Value[0] & 0x0F) != 0x00) //0 = no priority { return(true); } else { return(false); } } else { return(false); } }).OrderBy(y => y.Item2.ApplicationPriorityIndicatorTag.Value[0] & 0x0F).ToList(); List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > filteredZero = candidateList.Where(x => { if (x.Item2.ApplicationPriorityIndicatorTag == null) { return(true); } else if ((x.Item2.ApplicationPriorityIndicatorTag.Value[0] & 0x0F) == 0x00) { return(true); } else { return(false); } }).ToList(); List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > result = new List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> >(); result.AddRange(filteredNoZero); result.AddRange(filteredZero); #endregion #region 12.3.2 Book1 12.4 Step 3 return(AskCardHolderToSelect(result, uiProvider)); #endregion }
/// <summary> /// [Beta] Returns a new DataKeyOptions instance with some settings changed. /// </summary> /// <param name="alternateKeyNames">The alternate key names.</param> /// <param name="masterKey">The master key.</param> /// <returns>A new DataKeyOptions instance.</returns> public DataKeyOptions With( Optional <IReadOnlyList <string> > alternateKeyNames = default, Optional <BsonDocument> masterKey = default) { return(new DataKeyOptions( alternateKeyNames: Optional.Create(alternateKeyNames.WithDefault(_alternateKeyNames)), masterKey: Optional.Create(masterKey.WithDefault(_masterKey)))); }
protected Optional <sbyte> GetSbyteParameter(Dictionary <string, string> options, string parameter) { if (!options.ContainsKey(parameter)) { return(Optional <sbyte> .CreateEmpty()); } return(Optional <sbyte> .Create(sbyte.Parse(options[parameter]))); }
public static T Select <T>(string message, int?pageSize = null, T?defaultValue = null) where T : struct, Enum { var items = EnumValue <T> .GetValues(); using var form = new Select <EnumValue <T> >(message, items, pageSize, Optional <EnumValue <T> > .Create(defaultValue), x => x.DisplayName); return(form.Start().Value); }
protected Optional <bool> GetBoolParameter(Dictionary <string, string> options, string parameter) { if (!options.ContainsKey(parameter)) { return(Optional <bool> .CreateEmpty()); } return(Optional <bool> .Create(bool.Parse(options[parameter]))); }
public Optional <TObject> Lookup(TKey key) { if (!this._dict.TryGetValue(key, out var val)) { return(Optional <TObject> .None); } return(Optional <TObject> .Create(val)); }