public IEnumerable <string> EnumerateFileSystemEntries(string path, string pattern, SearchOption options) { if (!TryReadNext(nameof(EnumerateFileSystemEntries), ref path, out CapturedStorageQuery query)) { throw new ReplayNotFoundException($"Unable to dequeue next operation for \"{path}\"", path); } if (!(query.Input is CapturedStorageQuery.EnumerateInput input)) { throw new ReplayInputTypeException(typeof(CapturedStorageQuery.EnumerateInput), query.Input?.GetType()); } if (!(query.Output is IEnumerable <string> output)) { throw new ReplayOutputTypeException(typeof(string[]), query.Output?.GetType()); } // Validate inputs are identical if (input.Options != (int)options) { throw new ReplayInputException($"Unexpected `{nameof(options)}`: expected \"{input.Options}\" vs actual \"{(int)options}\"."); } if (!Ordinal.Equals(input.Pattern, pattern)) { throw new ReplayInputException($"Unexpected `{nameof(pattern)}`: expected \"{input.Pattern}\" vs actual \"{pattern}\"."); } return(output); }
public bool Equals(SecureData lhs, SecureData rhs) { if (lhs.Data?.Length != rhs.Data?.Length || !Ordinal.Equals(lhs.Key, rhs.Key) || !Ordinal.Equals(lhs.Name, rhs.Name)) { return(false); } if (lhs.Data is null && rhs.Data is null) { return(true); } if (lhs.Data is null || rhs.Data is null) { return(false); } for (int i = 0; i < lhs.Data.Length; i += 1) { if (lhs.Data[i] != rhs.Data[i]) { return(false); } } return(true); }
public bool ShowViewModel(DialogViewModel viewModel, Func <AuthenticationDialogWindow> windowCreator) { if (!TryGetNext(out CapturedGuiOperation operation)) { throw new ReplayNotFoundException($"Failed to find next `{nameof(CapturedGuiOperation)}`."); } if (!Ordinal.Equals(viewModel?.GetType().FullName, operation.DialogType)) { throw new ReplayInputTypeException($"Expected `{viewModel?.GetType().FullName}` vs. Actual `{operation.DialogType}`."); } _context.Trace.WriteLine($"replay {nameof(ShowViewModel)}."); viewModel.IsValid = operation.Output.IsValid; viewModel.Result = (AuthenticationDialogResult)operation.Output.Result; switch (viewModel) { case CredentialsViewModel cvm: { cvm.Login = operation.Output.Login; cvm.Password = operation.Output.Password; } break; case TwoFactorViewModel tfvm: { tfvm.AuthenticationCode = operation.Output.AuthenticationCode; } break; } return(operation.Output.Success); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CatalogItemVariation other && ((ItemId == null && other.ItemId == null) || (ItemId?.Equals(other.ItemId) == true)) && ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) && ((Sku == null && other.Sku == null) || (Sku?.Equals(other.Sku) == true)) && ((Upc == null && other.Upc == null) || (Upc?.Equals(other.Upc) == true)) && ((Ordinal == null && other.Ordinal == null) || (Ordinal?.Equals(other.Ordinal) == true)) && ((PricingType == null && other.PricingType == null) || (PricingType?.Equals(other.PricingType) == true)) && ((PriceMoney == null && other.PriceMoney == null) || (PriceMoney?.Equals(other.PriceMoney) == true)) && ((LocationOverrides == null && other.LocationOverrides == null) || (LocationOverrides?.Equals(other.LocationOverrides) == true)) && ((TrackInventory == null && other.TrackInventory == null) || (TrackInventory?.Equals(other.TrackInventory) == true)) && ((InventoryAlertType == null && other.InventoryAlertType == null) || (InventoryAlertType?.Equals(other.InventoryAlertType) == true)) && ((InventoryAlertThreshold == null && other.InventoryAlertThreshold == null) || (InventoryAlertThreshold?.Equals(other.InventoryAlertThreshold) == true)) && ((UserData == null && other.UserData == null) || (UserData?.Equals(other.UserData) == true)) && ((ServiceDuration == null && other.ServiceDuration == null) || (ServiceDuration?.Equals(other.ServiceDuration) == true)) && ((AvailableForBooking == null && other.AvailableForBooking == null) || (AvailableForBooking?.Equals(other.AvailableForBooking) == true)) && ((ItemOptionValues == null && other.ItemOptionValues == null) || (ItemOptionValues?.Equals(other.ItemOptionValues) == true)) && ((MeasurementUnitId == null && other.MeasurementUnitId == null) || (MeasurementUnitId?.Equals(other.MeasurementUnitId) == true)) && ((TeamMemberIds == null && other.TeamMemberIds == null) || (TeamMemberIds?.Equals(other.TeamMemberIds) == true))); }
public static void StaticEqualsComparer_SomeSome(NonEmptyString leftSome, NonEmptyString rightSome) { var left = Option.From(leftSome.Get); var right = Option.From(rightSome.Get); Assert.Equal(Ordinal.Equals(leftSome.Get, rightSome.Get), Option.Equals(left, right, Ordinal)); Assert.Equal(Ordinal.Equals(rightSome.Get, leftSome.Get), Option.Equals(right, left, Ordinal)); }
/// <summary>Indicates whether two strings are equal.</summary> /// <param name="x">A string to compare to y.</param> /// <param name="y">A string to compare to x.</param> /// <returns>true if <paramref name="x">x</paramref> and <paramref name="y">y</paramref> refer to the same object, or <paramref name="x">x</paramref> and <paramref name="y">y</paramref> are equal, or <paramref name="x">x</paramref> and <paramref name="y">y</paramref> are null; otherwise, false.</returns> public override bool Equals(string x, string y) { if (!Validate(x)) { throw new ArgumentOutOfRangeException(nameof(x), "The value is not a valid component name."); } if (!Validate(y)) { throw new ArgumentOutOfRangeException(nameof(y), "The value is not a valid component name."); } return(Ordinal.Equals(x, y)); }
/// <summary> /// Compares two credentials for equality. /// <para/> /// Returns `<see langword="true"/>` if equal; otherwise `<see langword="false"/>`. /// </summary> /// <param name="lhs">Credential to compare.</param> /// <param name="rhs">Credential to compare.</param> public static bool operator ==(Credential lhs, Credential rhs) { if (ReferenceEquals(lhs, rhs)) { return(true); } if (lhs is null || rhs is null) { return(false); } return(Ordinal.Equals(lhs.Username, rhs.Username) && Ordinal.Equals(lhs.Password, rhs.Password)); }
public Task <IAdalResult> AcquireTokenAsync(string authorityHostUrl, string resource, string clientId, Uri redirectUri, string extraQueryParameters) { if (!TryGetNextOperation(authorityHostUrl, out CapturedAdalOperation operation)) { throw new ReplayNotFoundException($"Failed to find replay data for \"{authorityHostUrl}\"."); } if (operation.Error.Message is null && operation.Result.Authority is null) { throw new ReplayDataException($"Expected either `{nameof(CapturedAdalOperation.Error)}` or `{nameof(CapturedAdalOperation.Result)}` to be null, but not both."); } _context.Trace.WriteLine($"{nameof(ReplayAdal)}: \"{authorityHostUrl}\"."); // Validate inputs are as expected if (!Ordinal.Equals(operation.Input.Resource, resource)) { throw new ReplayInputException($"Unexpected `{nameof(resource)}`: expected \"{operation.Input.Resource}\" vs actual \"{resource}\"."); } if (!Ordinal.Equals(operation.Input.ClientId, clientId)) { throw new ReplayInputException($"Unexpected `{nameof(clientId)}`: expected \"{operation.Input.ClientId}\" vs actual \"{clientId}\"."); } string redirectUrl = redirectUri?.ToString(); if (!Ordinal.Equals(operation.Input.RedirectUrl, redirectUrl)) { throw new ReplayInputException($"Unexpected `{nameof(redirectUri)}`: expected \"{operation.Input.RedirectUrl}\" vs actual \"{redirectUrl}\"."); } if (!Ordinal.Equals(operation.Input.ExtraQueryParameters, extraQueryParameters)) { throw new ReplayInputException($"Unexpected `{nameof(extraQueryParameters)}`: expected \"{operation.Input.ExtraQueryParameters}\" vs actual \"{extraQueryParameters}\"."); } // Throw the exception if there is one. if (operation.Error.Message != null) { throw new AuthenticationException(operation.Error.Message); } var result = new Adal.Result(operation.Result.AccessToken, operation.Result.Authority, operation.Result.TenantId, operation.Result.TokenType); return(Task.FromResult <IAdalResult>(result)); }
/// <inheritdoc/> public override async Task <bool> SetCredentials(TargetUri targetUri, Credential credentials) { // This is only called from the `Store()` method so only applies to default host entries // calling this from elsewhere may have unintended consequences, use // `SetCredentials(targetUri, credentials, username)` instead. // Only store the credentials as received if they match the uri and user of the existing // default entry. var currentCredentials = await GetCredentials(targetUri); if (currentCredentials != null && currentCredentials.Username != null && !Ordinal.Equals(currentCredentials.Username, credentials.Username)) { // Do nothing as the default is for another username and we don't want to overwrite it. Trace.WriteLine($"skipping for {targetUri.QueryUri} new username {currentCredentials.Username} != {credentials.Username}"); return(false); } await SetCredentials(targetUri, credentials, null); // `Store()` will not call with a username Url. if (targetUri.ContainsUserInfo) { return(false); } // See if there is a matching personal refresh token. var username = credentials.Username; var userSpecificTargetUri = targetUri.GetPerUserTargetUri(username); var userCredentials = await GetCredentials(userSpecificTargetUri, username); if (userCredentials != null && userCredentials.Password.Equals(credentials.Password)) { var userRefreshCredentials = await GetCredentials(GetRefreshTokenTargetUri(userSpecificTargetUri), username); if (userRefreshCredentials != null) { Trace.WriteLine("OAuth RefreshToken"); var hostRefreshCredentials = new Credential(credentials.Username, userRefreshCredentials.Password); await SetCredentials(GetRefreshTokenTargetUri(targetUri), hostRefreshCredentials, null); } } return(true); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CatalogModifierList other && ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) && ((Ordinal == null && other.Ordinal == null) || (Ordinal?.Equals(other.Ordinal) == true)) && ((SelectionType == null && other.SelectionType == null) || (SelectionType?.Equals(other.SelectionType) == true)) && ((Modifiers == null && other.Modifiers == null) || (Modifiers?.Equals(other.Modifiers) == true))); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CatalogModifier other && ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) && ((PriceMoney == null && other.PriceMoney == null) || (PriceMoney?.Equals(other.PriceMoney) == true)) && ((Ordinal == null && other.Ordinal == null) || (Ordinal?.Equals(other.Ordinal) == true)) && ((ModifierListId == null && other.ModifierListId == null) || (ModifierListId?.Equals(other.ModifierListId) == true))); }
public override bool Equals(string x, string y) { if (ReferenceEquals(x, y)) { return(true); } if (x is null || y is null) { return(false); } Split(x, out string xSection, out string xScope, out string xProperty); Split(y, out string ySection, out string yScope, out string yProperty); // Section and property names are not case sensitive, but the inner 'scope' IS case sensitive! return(OrdinalIgnoreCase.Equals(xSection, ySection) && OrdinalIgnoreCase.Equals(xProperty, yProperty) && Ordinal.Equals(xScope, yScope)); }
public void FileWriteAllText(string path, string contents, Encoding encoding) { if (!TryReadNext(nameof(FileWriteAllBytes), ref path, out CapturedStorageQuery query)) { throw new ReplayNotFoundException($"Unable to dequeue next operation for \"{path}\"", path); } if (!(query.Input is CapturedStorageQuery.WriteAllTextInput input)) { throw new ReplayInputTypeException(typeof(CapturedStorageQuery.WriteAllBytesInput), query.Input?.GetType()); } // Validate that inputs are identical if (!OrdinalIgnoreCase.Equals(path, input.Path)) { throw new ReplayInputException($"Unexpected `{nameof(path)}` value. Expected \"{input.Path}\" vs actual \"{path}\"."); } if (!Ordinal.Equals(contents, input.Contents)) { throw new ReplayInputException($"Unexpected `{nameof(contents)}` value. Expected \"{input.Contents}\" vs actual \"{contents}\"."); } }
public bool Equals(TaskState other) => Ordinal.Equals(other.Ordinal);
public override bool Equals(string x, string y) { return(Ordinal.Equals(x, y)); }
public bool Equals(ThreadState other) => Ordinal.Equals(other.Ordinal);