public async Task Hash64_StreamAsync_ReturnsExpectedValuesAsync(FnvTestVector data) { using var stream = new MemoryStream(data.Buffer); ulong result = await Fnv1a.Hash64Async(stream); Assert.That(result, Is.EqualTo(data.ExpectedResult64)); }
private void ReadField(SQEX.Luminous.Core.Object.BaseObject obj, Xmb2Element parentElement, uint hashedParentName, BaseObject objOffset) { if (objOffset != null) { obj = objOffset; } foreach (var element in parentElement.GetElements()) { var name = element.Name; var hashedName = Fnv1a.Fnv1a32(name, hashedParentName); var type = obj.GetObjectType(); if (type == null) { continue; } var property = type.PropertyContainer.FindByName(name); if (property == null) { continue; } this.ReadValue(obj, parentElement, element, property, hashedName, objOffset); } }
public void Hash64_Stream_ReturnsExpectedValues(FnvTestVector data) { using var stream = new MemoryStream(data.Buffer); ulong result = Fnv1a.Hash64(stream); Assert.That(result, Is.EqualTo(data.ExpectedResult64)); }
public async Task Hash32_StreamAsync_ReturnsExpectedValuesAsync(FnvTestVector data) { using var stream = new MemoryStream(data.Buffer); uint result = await Fnv1a.Hash32Async(stream); Assert.AreEqual(data.ExpectedResult32, result); }
private static uint GetFnvHashValue(string word) { var encodedWord = Encoding.ASCII.GetBytes(word); uint hashResult = Fnv1a.Hash32(encodedWord); return(hashResult); }
public void Hash32_Stream_ReturnsExpectedValues(FnvTestVector data) { using var stream = new MemoryStream(data.Buffer); uint result = Fnv1a.Hash32(stream); Assert.AreEqual(data.ExpectedResult32, result); }
private void ReadValue(Luminous.Core.Object.BaseObject obj, Xmb2Element parentObject, Xmb2Element element, Property property, uint hashedName, BaseObject objOffset) { object value = null; switch (property.Type) { case Property.PrimitiveType.ClassField: this.ReadField(obj, element, Fnv1a.Fnv1a32(".", hashedName), obj.GetPropertyValue <BaseObject>(property)); break; case Property.PrimitiveType.Int8: case Property.PrimitiveType.Int16: case Property.PrimitiveType.Int32: case Property.PrimitiveType.Int64: case Property.PrimitiveType.UInt8: case Property.PrimitiveType.UInt16: case Property.PrimitiveType.UInt32: case Property.PrimitiveType.UInt64: case Property.PrimitiveType.INVALID2: case Property.PrimitiveType.Bool: case Property.PrimitiveType.Float: case Property.PrimitiveType.Double: case Property.PrimitiveType.String: case Property.PrimitiveType.Fixid: case Property.PrimitiveType.Vector4: case Property.PrimitiveType.Color: case Property.PrimitiveType.Enum: value = this.ReadPrimitiveValue(element, property); break; case Property.PrimitiveType.Pointer: if (this.ResolvePointer(parentObject, element, out value)) { // TODO addPointerListReferedBySequenceIfMatchCondition } break; case Property.PrimitiveType.PointerArray: case Property.PrimitiveType.IntrusivePointerArray: // GOTCHA: We don't want to create a new List, because other objects can reference the list before it's instantiated value = obj.GetPropertyValue <IList>(property); this.ReadPointerArray(obj, element, value as IList); break; default: if (property.Type != Property.PrimitiveType.Array) { throw new ArgumentException($"[EntityPackageXmlLoader]Unknown type {property.Type} for {property.Name}"); } break; } if (value != null) { obj.SetPropertyValue(property, value); } }
public void Hash64_Stream_ReturnsExpectedValues(FnvTestVector data) { using (var stream = new MemoryStream(data.Buffer)) { ulong result = Fnv1a.Hash64(stream); Assert.AreEqual(data.ExpectedResult64, result); } }
public async Task Hash64_StreamAsync_ReturnsExpectedValuesAsync(FnvTestVector data) { using (var stream = new MemoryStream(data.Buffer)) { ulong result = await Fnv1a.Hash64Async(stream); Assert.AreEqual(data.ExpectedResult64, result); } }
public MetaPropertyAttribute(string name, BinPropertyType type, string otherClass, BinPropertyType primaryType, BinPropertyType secondaryType) { this.Name = name; this.NameHash = Fnv1a.HashLower(name); this.OtherClass = otherClass; this.ValueType = type; this.PrimaryType = primaryType; this.SecondaryType = secondaryType; }
private static Dictionary <uint, string> ParseBinHashtable(string filePath) { Dictionary <uint, string> map = new Dictionary <uint, string>(); foreach (string line in File.ReadAllLines(filePath)) { string hashString = line.Split(" ")[1]; uint hash = Fnv1a.HashLower(hashString); if (map.ContainsKey(hash) is false) { map.Add(hash, hashString); } } return(map); }
public void WriteMetaClasses(Stream stream, ICollection <string> classNames, ICollection <string> propertyNames) { // Create dictionaries from collections Dictionary <uint, string> classNameMap = new(classNames.Count); Dictionary <uint, string> propertyNameMap = new(propertyNames.Count); foreach (string className in classNames) { classNameMap.Add(Fnv1a.HashLower(className), className); } foreach (string propertyName in propertyNames) { propertyNameMap.Add(Fnv1a.HashLower(propertyName), propertyName); } WriteMetaClasses(stream, classNameMap, propertyNameMap); }
private void ReadDynamicBaseObjectChildElement(BaseObject parentObject, BaseObject baseObject, Xmb2Element childElement) { foreach (var element in childElement.GetElements()) { var name = element.Name; var hashedName = Fnv1a.Fnv1a32(name, 2166136261); // ??? var type = baseObject.GetObjectType(); if (type == null) { continue; } var property = type.PropertyContainer.FindByName(name); if (property == null) { continue; } this.ReadValue(baseObject, childElement, element, property, hashedName, baseObject); } }
public void Hash64_NullBuffer_ThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => Fnv1a.Hash64(null)); }
public void Hash32_ReturnsExpectedValues(FnvTestVector data) { uint result = Fnv1a.Hash32(data.Buffer); Assert.AreEqual(data.ExpectedResult32, result); }
public uint ComputePicHash() { PictureHash = Fnv1a.Hash32(PictureData); return(PictureHash); }
/// <summary> /// Read the attribute element with a given name. /// </summary> /// <param name="name">The name of the attribute to get.</param> /// <returns>The parsed attribute.</returns> public Xmb2Variant GetAttributeByName(string name) { var nameHash = Fnv1a.Fnv1a32(name); return(this.GetAttributeByName(nameHash)); }
public override int GetHashCode() { return((int)Fnv1a.Hash32(Utils.Latin1Encoding.GetBytes(ToString()))); }
public void Hash64_ReturnsExpectedValues(FnvTestVector data) { ulong result = Fnv1a.Hash64(data.Buffer); Assert.AreEqual(data.ExpectedResult64, result); }
public static BinTreeObject Serialize <T>(MetaEnvironment environment, string path, T metaClass) where T : IMetaClass { return(Serialize(environment, Fnv1a.HashLower(path), metaClass)); }
public void Hash64_ReturnsExpectedValues(FnvTestVector data) { ulong result = Fnv1a.Hash64(data.Buffer); Assert.That(result, Is.EqualTo(data.ExpectedResult64)); }
public MetaPropertyAttribute(string name, BinPropertyType type) { this.Name = name; this.NameHash = Fnv1a.HashLower(name); this.ValueType = type; }
public MetaHash(string value) { this.Hash = Fnv1a.HashLower(value); this.Value = value; }
public void Hash32_ReturnsExpectedValues(FnvTestVector data) { uint result = Fnv1a.Hash32(data.Buffer); Assert.That(result, Is.EqualTo(data.ExpectedResult32)); }