Example #1
0
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = (OldIndex != null ? OldIndex.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (NewIndex != null ? NewIndex.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Alias != null ? Alias.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DeleteOld.GetHashCode();
         hashCode = (hashCode * 397) ^ (TimestampField != null ? TimestampField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (StartUtc != null ? StartUtc.GetHashCode() : 0);
         return(hashCode);
     }
 }
Example #2
0
        /// <summary>
        /// Adds a timestamp field and sets the format of the timestamp
        /// (default: "u", conversion to UTC and output using the format yyyy-MM-dd HH:mm:ssZ)
        /// </summary>
        /// <param name="format">
        /// The timestamp format (see https://msdn.microsoft.com/en-us/library/bb351892(v=vs.110).aspx" for details).
        /// </param>
        /// <param name="jsonKey">Key of the field in the JSON document (null to use the default key).</param>
        public void AddTimestampField(string format = "u", string jsonKey = null)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }
            if (jsonKey == null)
            {
                jsonKey = JsonMessageFieldNames.Default.Timestamp;
            }

            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            DateTimeOffset.MinValue.ToString(format);             // throws FormatException, if format is invalid

            var field = new TimestampField(this, jsonKey, format);

            AppendField(field);
        }