diff --git a/uSync8.Core/Extensions/StringExtensions.cs b/uSync8.Core/Extensions/StringExtensions.cs index cd2868cf..c1faa073 100644 --- a/uSync8.Core/Extensions/StringExtensions.cs +++ b/uSync8.Core/Extensions/StringExtensions.cs @@ -72,5 +72,24 @@ public static string ToShortKeyString(this Guid guid, int length = 26) return new string(chars); } + + public static int GetDeterministicHashCode(this string str) + { + unchecked + { + int hash1 = (5381 << 16) + 5381; + int hash2 = hash1; + + for (int i = 0; i < str.Length; i += 2) + { + hash1 = ((hash1 << 5) + hash1) ^ str[i]; + if (i == str.Length - 1) + break; + hash2 = ((hash2 << 5) + hash2) ^ str[i + 1]; + } + + return hash1 + (hash2 * 1566083941); + } + } } } diff --git a/uSync8.Core/Serialization/Serializers/MemberTypeSerializer.cs b/uSync8.Core/Serialization/Serializers/MemberTypeSerializer.cs index 16d33b3a..5bc1c3d9 100644 --- a/uSync8.Core/Serialization/Serializers/MemberTypeSerializer.cs +++ b/uSync8.Core/Serialization/Serializers/MemberTypeSerializer.cs @@ -77,10 +77,17 @@ protected override void SerializeExtraProperties(XElement node, IMemberType item // get removed when required. // - private static string[] buildInProperties = new string[] { - "umbracoMemberApproved", "umbracoMemberComments", "umbracoMemberFailedPasswordAttempts", - "umbracoMemberLastLockoutDate", "umbracoMemberLastLogin", "umbracoMemberLastPasswordChangeDate", - "umbracoMemberLockedOut", "umbracoMemberPasswordRetrievalAnswer", "umbracoMemberPasswordRetrievalQuestion" + private static Dictionary buildInProperties = new Dictionary() + { + { "umbracoMemberApproved", "e79dccfb-0000-0000-0000-000000000000" }, + { "umbracoMemberComments", "2a280588-0000-0000-0000-000000000000" }, + { "umbracoMemberFailedPasswordAttempts", "0f2ea539-0000-0000-0000-000000000000" }, + { "umbracoMemberLastLockoutDate", "3a7bc3c6-0000-0000-0000-000000000000" }, + { "umbracoMemberLastLogin", "b5e309ba-0000-0000-0000-000000000000" }, + { "umbracoMemberLastPasswordChangeDate", "ded56d3f-0000-0000-0000-000000000000" }, + { "umbracoMemberLockedOut", "c36093d2-0000-0000-0000-000000000000" }, + { "umbracoMemberPasswordRetrievalAnswer", "9700bd39-0000-0000-0000-000000000000" }, + { "umbracoMemberPasswordRetrievalQuestion", "e2d9286a-0000-0000-0000-000000000000" }, }; protected override XElement SerializeProperties(IMemberType item) @@ -89,14 +96,14 @@ protected override XElement SerializeProperties(IMemberType item) foreach (var property in node.Elements("GenericProperty")) { var alias = property.Element("Alias").ValueOrDefault(string.Empty); - if (!string.IsNullOrWhiteSpace(alias) && buildInProperties.InvariantContains(alias)) + if (!string.IsNullOrWhiteSpace(alias) && buildInProperties.ContainsKey(alias)) { - var keyName = alias; + var key = buildInProperties[alias]; if (!item.Alias.InvariantEquals("Member")) { - keyName = $"{item.Alias}{alias}"; + key = $"{item.Alias}{alias}".GetDeterministicHashCode().ToGuid().ToString(); } - property.Element("Key").Value = keyName.GetHashCode().ToGuid().ToString(); + property.Element("Key").Value = key; } } return node;