/// <summary> /// Returns a value that indicates whether this instance and another <see cref="AnimationNode"/> are equal. /// </summary> /// <param name="other">The other <see cref="AnimationNode"/>.</param> /// <returns><see langword="true"/> if the two animation nodes are equals; otherwise, <see langword="false"/>.</returns> public bool Equals(AnimationNode other) => _hashcode == other._hashcode && PostState == other.PostState && PreState == other.PreState && MemoryExtensions.SequenceEqual(PositionKeys, other.PositionKeys) && MemoryExtensions.SequenceEqual(RotationKeys, other.RotationKeys) && MemoryExtensions.SequenceEqual(ScalingKeys, other.ScalingKeys);
public override bool Equals(object obj) { if (!(obj is HashesMessage other)) { return(false); } if (Hashes.Count != other.Hashes.Count) { return(false); } for (int i = 0; i < Hashes.Count; i++) { if (!MemoryExtensions.SequenceEqual(Hashes[i].Span, other.Hashes[i].Span)) { return(false); } } return(MemoryExtensions.SequenceEqual(PiecesRoot.Span, other.PiecesRoot.Span) && BaseLayer == other.BaseLayer && Index == other.Index && Length == other.Length && ProofLayers == other.ProofLayers); }
public bool Equals(NSymbol255 other) { if (Len != other.Len) { return(false); } return(MemoryExtensions.SequenceEqual(AsSpan(), other.AsSpan())); }
public bool Equals(StorageKey other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Id == other.Id && MemoryExtensions.SequenceEqual <byte>(Key, other.Key)); }
public static bool Equal <T>(ReadOnlyMemorySlice <T>?lhs, ReadOnlyMemorySlice <T>?rhs) where T : IEquatable <T> { if (lhs == null && rhs == null) { return(true); } if (lhs == null || rhs == null) { return(false); } return(MemoryExtensions.SequenceEqual(lhs.Value.Span, rhs.Value.Span)); }
public static void SyncFolder <T>(ref bool?replace, ref bool?delete, string folder, List <T> should, Func <T, string> fileName, Func <T, XDocument> toXML) { if (should.Any() && !Directory.Exists(folder)) { Directory.CreateDirectory(folder); } var deleteLocal = delete; var replaceLocal = replace; SafeConsole.WriteLineColor(ConsoleColor.Gray, "Exporting to " + folder); Synchronizer.Synchronize( newDictionary: should.ToDictionary(fileName), oldDictionary: Directory.GetFiles(folder).ToDictionary(a => Path.GetFileName(a)), createNew: (fileName, entity) => { toXML(entity).Save(Path.Combine(folder, fileName)); SafeConsole.WriteLineColor(ConsoleColor.Green, " Created " + fileName); }, removeOld: (fileName, fullName) => { if (SafeConsole.Ask(ref deleteLocal, "Delete {0}?".FormatWith(fileName))) { File.Delete(fullName); SafeConsole.WriteLineColor(ConsoleColor.Red, " Deleted " + fileName); } }, merge: (fileName, entity, fullName) => { var xml = toXML(entity); var newBytes = new MemoryStream().Do(ms => xml.Save(ms)).ToArray(); var oldBytes = File.ReadAllBytes(fullName); if (!MemoryExtensions.SequenceEqual <byte>(newBytes, oldBytes)) { if (SafeConsole.Ask(ref replaceLocal, " Override {0}?".FormatWith(fileName))) { xml.Save(Path.Combine(folder, fileName)); SafeConsole.WriteLineColor(ConsoleColor.Yellow, " Overriden " + fileName); } } else { SafeConsole.WriteLineColor(ConsoleColor.DarkGray, " Identical " + fileName); } }); delete = deleteLocal; replace = replaceLocal; }
internal static bool MemoryCompare(System.IntPtr buf1, System.IntPtr buf2, int count) { Debug.Assert(buf1 != buf2, "buf1 and buf2 are the same"); Debug.Assert(buf1.ToInt64() < buf2.ToInt64() || buf2.ToInt64() + count <= buf1.ToInt64(), "overlapping region buf1"); Debug.Assert(buf2.ToInt64() < buf1.ToInt64() || buf1.ToInt64() + count <= buf2.ToInt64(), "overlapping region buf2"); Debug.Assert(0 <= count, "negative count"); unsafe { ReadOnlySpan <byte> span1 = new ReadOnlySpan <byte>(buf1.ToPointer(), count); ReadOnlySpan <byte> span2 = new ReadOnlySpan <byte>(buf2.ToPointer(), count); return(!MemoryExtensions.SequenceEqual(span1, span2)); //0 if all count bytes of lhs and rhs are equal. // TODO: confirm condition with tests } }
public bool Equals(Token other) { if (Kind != other.Kind) { return(false); } if (Symbol != other.Symbol) { return(false); } if (!MemoryExtensions.SequenceEqual(Text.Span, other.Text.Span)) { return(false); } return(true); }
public async Task <LoginResponse> MakeAssertion([FromBody][Required] MakeAssertionRequest request) { using (AuthLogic.Disable()) using (Transaction tr = new Transaction()) { var assertionOptions = Database.Retrieve <WebAuthnAssertionOptionsEntity>(request.AssertionOptionsId); var options = AssertionOptions.FromJson(assertionOptions.Json); var cred = Database.Query <WebAuthnCredentialEntity>().SingleEx(cred => cred.CredentialId == request.AssertionRawResponse.Id); var res = await fido2.MakeAssertionAsync(request.AssertionRawResponse, options, cred.PublicKey, (uint)cred.Counter, (args) => { if (!MemoryExtensions.SequenceEqual <byte>(cred.CredentialId, args.CredentialId)) { return(Task.FromResult(false)); } var userId = Encoding.UTF8.GetBytes(cred.User.Id.ToString()); if (!MemoryExtensions.SequenceEqual <byte>(userId, args.UserHandle)) { return(Task.FromResult(false)); } return(Task.FromResult(true)); }); cred.Counter++; cred.Save(); var user = cred.User.RetrieveAndForget(); AuthServer.OnUserPreLogin(ControllerContext, user); AuthServer.AddUserSession(ControllerContext, user); var token = AuthTokenServer.CreateToken(user); return(tr.Commit(new LoginResponse { userEntity = user, token = token, authenticationType = "webauthn" })); } }
private void RLPListEncodeDecodeTest(int items) { RLPList list = new RLPList(); for (int i = 0; i < items; i++) { if (i % 2 == 0) { list.Items.Add(new byte[] { (byte)(i % 256) }); } else { list.Items.Add(new RLPList()); } } byte[] encoded = RLP.Encode(list); RLPList list2 = (RLPList)RLP.Decode(encoded); Assert.Equal(list.Items.Count, list2.Items.Count); for (int i = 0; i < list.Items.Count; i++) { if (i % 2 == 0) { Assert.IsType <RLPByteArray>(list2.Items[i]); RLPByteArray b1 = ((RLPByteArray)list.Items[i]); RLPByteArray b2 = ((RLPByteArray)list2.Items[i]); Assert.True(MemoryExtensions.SequenceEqual(b1.Data.Span, b2.Data.Span)); } else { Assert.IsType <RLPList>(list2.Items[i]); } } }
public static void Equal(ReadOnlySpan <byte> actual, ReadOnlySpan <byte> expected) => Xunit.Assert.True( MemoryExtensions.SequenceEqual(expected, actual), $"Expected does not match actual.\nExpected:\t{SpanToString(expected)}\nActual:\t\t{SpanToString(actual)}" );
public bool Equals(BitVector other) => Length == other.Length && MemoryExtensions.SequenceEqual(new ReadOnlySpan <ulong>(_blocks), new ReadOnlySpan <ulong>(other._blocks));
public bool Equals(Signature64 other) { return(MemoryExtensions.SequenceEqual(AsSpan(), other.AsSpan())); }
public bool Equals(Memory <T> x, Memory <T> y) { return(MemoryExtensions.SequenceEqual(x.Span, y.Span)); }
/// <summary> /// Returns a value that indicates whether this instance and another <see cref="Animation"/> are equal. /// </summary> /// <param name="other">The other <see cref="Animation"/>.</param> /// <returns><see langword="true"/> if the two animations are equals; otherwise, <see langword="false"/>.</returns> public bool Equals(Animation other) => ReferenceEquals(this, other) || (GetHashCode() == other.GetHashCode() && Duration == other.Duration && TicksPerSecond == other.TicksPerSecond && MemoryExtensions.SequenceEqual(Channels, other.Channels));
public bool Equals(Hash16 other) { return(MemoryExtensions.SequenceEqual(AsSpan(), other.AsSpan())); }
public bool Equals(UnicodeSequence other) { return(MemoryExtensions.SequenceEqual <Codepoint>(_codepoints, other._codepoints)); }