Example #1
0
        /// <summary>
        /// Handles the signaling of this <see cref="DataWatcher"/>.
        /// </summary>
        protected override void HandleSignaling()
        {
            lock (_locker)
            {
                DateTime        utcLastModified = DateTime.UtcNow;
                List <object[]> values          = new List <object[]>();
                DataManager     manager         = Manager.Clone();
                using (DbDataReader reader = manager.ExecuteReader(Command, Parameters))
                {
                    while (reader.Read())
                    {
                        object[] readerValues = new object[reader.FieldCount];
                        reader.GetValues(readerValues);
                        values.Add(readerValues);
                    }
                }
                long currentSignature = StructUtility.GetHashCode64(EnumerableConverter.Parse(values, o => o.GetHashCode()));
                values.Clear();

                if (Signature == 0)
                {
                    Signature = currentSignature;
                }
                if (!Signature.Equals(currentSignature))
                {
                    SetUtcLastModified(utcLastModified);
                    OnChangedRaised();
                }
                Signature = currentSignature;
            }
        }
Example #2
0
        /// <summary>
        /// Combines a sequence of objects into one object, and computes a hash value of the specified <paramref name="values"/>.
        /// </summary>
        /// <param name="values">The objects to compute a hash code for.</param>
        /// <param name="setup">The <see cref="HashOptions"/> which need to be configured.</param>
        /// <returns>A <see cref="HashResult"/> containing the computed hash value of the specified object sequence <paramref name="values"/>.</returns>
        public static HashResult ComputeHash(object[] values, Action <HashOptions> setup = null)
        {
            Validator.ThrowIfNull(values, nameof(values));
            var  options   = setup.ConfigureOptions();
            long signature = StructUtility.GetHashCode64(EnumerableConverter.Parse(values, o => o.GetHashCode()));

            return(ComputeHash(BitConverter.GetBytes(signature), o => o.AlgorithmType = options.AlgorithmType));
        }
Example #3
0
 /// <summary>
 /// Combines the specified form-data <paramref name="values"/> into one <see cref="NameValueCollection"/> equivalent.
 /// </summary>
 /// <param name="values">A variable number of form-data <paramref name="values"/>.</param>
 /// <returns>A <see cref="NameValueCollection"/> equivalent to the combined form-data <paramref name="values"/>.</returns>
 public static NameValueCollection Combine(params string[] values)
 {
     Validator.ThrowIfNull(values, nameof(values));
     return(Combine(EnumerableConverter.Parse(values, FormConverter.FromString).ToArray()));
 }