Пример #1
0
        public static string Hash(IEnumerable <TypeModel> typeModels)
        {
            var hash = new HashCombiner();

            // see Umbraco.ModelsBuilder.Umbraco.Application for what's important to hash
            // ie what comes from Umbraco (not computed by ModelsBuilder) and makes a difference

            foreach (var typeModel in typeModels.OrderBy(x => x.Alias))
            {
                hash.Add("--- CONTENT TYPE MODEL ---");
                hash.Add(typeModel.Id);
                hash.Add(typeModel.Alias);
                hash.Add(typeModel.ClrName);
                hash.Add(typeModel.ParentId);
                hash.Add(typeModel.Name);
                hash.Add(typeModel.Description);
                hash.Add(typeModel.ItemType.ToString());
                hash.Add("MIXINS:" + string.Join(",", typeModel.MixinTypes.OrderBy(x => x.Id).Select(x => x.Id)));

                foreach (var prop in typeModel.Properties.OrderBy(x => x.Alias))
                {
                    hash.Add("--- PROPERTY ---");
                    hash.Add(prop.Alias);
                    hash.Add(prop.ClrName);
                    hash.Add(prop.Name);
                    hash.Add(prop.Description);
                    hash.Add(prop.ModelClrType.ToString()); // see ModelType tests, want ToString() not FullName
                }
            }

            // Include the MB version in the hash so that if the MB version changes, models are rebuilt
            hash.Add(ApiVersion.Current.Version.ToString());

            return(hash.GetCombinedHashCode());
        }
Пример #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(HashCombiner.CombineInline(Url?.GetHashCode() ?? EmptyStringHash, Database?.GetHashCode() ?? EmptyStringHash));
     }
 }
Пример #3
0
        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing
        /// algorithms and data structures like a hash table.
        /// </returns>
        public override int GetHashCode()
        {
            int hash = HashCombiner.Initialize();

            hash = HashCombiner.Hash(hash, First);
            hash = HashCombiner.Hash(hash, Second);

            return(hash);
        }
Пример #4
0
        public override int GetHashCode()
        {
            HashCombiner hash = HashCombiner.Initialize();

            hash.Add(base.GetHashCode());
            hash.Add(target);

            return(hash.Value);
        }
Пример #5
0
        public override int GetHashCode()
        {
            HashCombiner hash = new HashCombiner();

            hash.Add(id);
            hash.Add(version);

            return(hash.Value);
        }
Пример #6
0
        public override int GetHashCode()
        {
            HashCombiner hash = new HashCombiner();

            hash.Add(Owner);
            hash.Add(Namespace);
            hash.Add(Name);

            return(hash.Value);
        }
Пример #7
0
        public void CombineHash1()
        {
            //arrange
            var someValues = new object[] { new int[] { }, new object(), new List <string>() };
            //act

            var result = HashCombiner.CombineHashCodes(someValues);

            //assert
            Assert.NotEqual(0, result);
        }
Пример #8
0
        public int GetHashCode(TaskPin obj)
        {
            HashCombiner combiner = HashCombiner.Initialize();

            combiner.Add(obj.DataType);

            if (obj is FlaggedPin)
            {
                combiner.Add((obj as FlaggedPin).Flags);
            }

            return(combiner.Value);
        }
Пример #9
0
 public void Test_Hash_WithNumericOverflow()
 {
     Assert.DoesNotThrow(
         () => _hash = HashCombiner.Hash(_hash, int.MaxValue)
         );
 }
Пример #10
0
 public void Setup()
 {
     _hash = HashCombiner.Initialize();
 }