Пример #1
0
        public static string DiffingHash(this object obj, DiffConfig diffConfig = null)
        {
            diffConfig = diffConfig == null ? new DiffConfig() : (DiffConfig)diffConfig.DeepClone();

            // The following is to consider only the PropertiesToInclude specified in the diffConfig.
            // Since the SHA hash algorithm can only consider "exceptions", we need to retrieve all the top level properties,
            // intersect them with the set of PropertiesToInclude, and treat all the properties that remain out as "exceptions" (not to be considered).
            if (diffConfig.PropertiesToConsider.Any())
            {
                IEnumerable <string> exceptions = BH.Engine.Reflection.Query.PropertyNames(obj).Except(diffConfig.PropertiesToConsider);
                diffConfig.PropertiesToIgnore.AddRange(exceptions);
            }

            // The current Hash must not be considered when computing the hash. Remove HashFragment if present.
            IBHoMObject bhomobj = obj as IBHoMObject;

            if (bhomobj != null)
            {
                bhomobj = BH.Engine.Base.Query.DeepClone(obj) as IBHoMObject;
                bhomobj.Fragments.Remove(typeof(HashFragment));
                return(Compute.SHA256Hash(bhomobj, diffConfig.PropertiesToIgnore));
            }

            return(Compute.SHA256Hash(obj, diffConfig.PropertiesToIgnore));
        }
Пример #2
0
        public static string DiffingHash(this IBHoMObject obj, List <string> exceptions = null, bool useDefaultExceptions = true)
        {
            if (exceptions == null || exceptions.Count == 0 && useDefaultExceptions)
            {
                SetDefaultExceptions(ref exceptions);
            }

            return(Compute.SHA256Hash(obj, exceptions));
        }
Пример #3
0
 public static string DiffingHash(this IBHoMObject obj, DiffConfig diffConfig)
 {
     return(Compute.SHA256Hash(obj, diffConfig.PropertiesToIgnore));
 }