Пример #1
0
    // <Snippet9>
    private static void CompareForEquality1()
    {
        DateTimeOffset firstTime = new DateTimeOffset(2007, 9, 1, 6, 45, 0,
                                                      new TimeSpan(-7, 0, 0));

        DateTimeOffset secondTime = firstTime;

        Console.WriteLine("{0} = {1}: {2}",
                          firstTime, secondTime,
                          firstTime.Equals(secondTime));

        secondTime = new DateTimeOffset(2007, 9, 1, 6, 45, 0,
                                        new TimeSpan(-6, 0, 0));
        Console.WriteLine("{0} = {1}: {2}",
                          firstTime, secondTime,
                          firstTime.Equals(secondTime));

        secondTime = new DateTimeOffset(2007, 9, 1, 8, 45, 0,
                                        new TimeSpan(-5, 0, 0));
        Console.WriteLine("{0} = {1}: {2}",
                          firstTime, secondTime,
                          firstTime.Equals(secondTime));
        // The example displays the following output to the console:
        //      9/1/2007 6:45:00 AM -07:00 = 9/1/2007 6:45:00 AM -07:00: True
        //      9/1/2007 6:45:00 AM -07:00 = 9/1/2007 6:45:00 AM -06:00: False
        //      9/1/2007 6:45:00 AM -07:00 = 9/1/2007 8:45:00 AM -05:00: True
        // </Snippet9>
    }
Пример #2
0
 public static string ToSQL(object value, bool allowDBNull = false)
 {
     if (value == null)
     {
         if (!allowDBNull)
         {
             throw new ORMException("Convert Value Error In [" + value + "]");
         }
         return("null");
     }
     if (value.GetType() == typeof(string))
     {
         string str = (string)value;
         return(Escape(str));
     }
     if (value.GetType() == typeof(Guid))
     {
         return(value.ToString());
     }
     if (value.GetType() == typeof(DateTime))
     {
         DateTime time = (DateTime)value;
         if (time.Equals(DateTime.MinValue) || time.Equals(DateTime.MaxValue))
         {
             return("null");
         }
         return(GetDateString((DateTime)value));
     }
     if (value.GetType() == typeof(DateTimeOffset))
     {
         DateTimeOffset date = (DateTimeOffset)value;
         if (date.Equals(DateTimeOffset.MinValue) || date.Equals(DateTimeOffset.MaxValue))
         {
             return("null");
         }
         return(GetDateTimeOffsetString(date));
     }
     if (value.GetType() == typeof(TimeSpan))
     {
         return(value.ToString());
     }
     if (value.GetType() == typeof(bool))
     {
         if ((bool)value)
         {
             return("1");
         }
         return("0");
     }
     if (value.GetType().IsEnum)
     {
         return(Convert.ToInt32(value).ToString());
     }
     if (value is byte[])
     {
         return(ToHexString(value as byte[]));
     }
     return("");
 }
Пример #3
0
 public bool Equals(object obj)
 {
     if (obj is DateTimeValue)
     {
         return(value.Equals(((DateTimeValue)obj).value));
     }
     else
     {
         return(value.Equals(obj));
     }
 }
Пример #4
0
        public void EqualsObject()
        {
            DateTimeOffset offset1 = new DateTimeOffset();

            Assert.IsFalse(offset1.Equals(null), "null");               // found using Gendarme :)
            Assert.IsTrue(offset1.Equals(offset1), "self");
            DateTimeOffset offset2 = new DateTimeOffset(DateTime.Today);

            Assert.IsFalse(offset1.Equals(offset2), "1!=2");
            Assert.IsFalse(offset2.Equals(offset1), "2!=1");
        }
 public override bool Equals(object obj)
 {
     if (obj == null)
     {
         return(false);
     }
     if (!(obj is Rfc3339DateTime))
     {
         return(false);
     }
     return(_value.Equals(((Rfc3339DateTime)obj)._value));
 }
Пример #6
0
        public override bool Equals(FluidValue other)
        {
            if (other.IsNil())
            {
                return(false);
            }

            if (other.Type != FluidValues.DateTime)
            {
                return(false);
            }

            return(_value.Equals(((DateTimeValue)other)._value));
        }
Пример #7
0
 /// <summary>
 /// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
 /// </summary>
 /// <param name="other">The <see cref="System.Object" /> to compare with this instance.</param>
 /// <returns>
 ///   <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
 /// </returns>
 public override bool Equals(object other)
 {
     if (other is Timestamp)
     {
         return(value.Equals(((Timestamp)other).value));
     }
     else if (other is DateTimeOffset)
     {
         return(value.Equals((DateTimeOffset)other));
     }
     else
     {
         return(false);
     }
 }
Пример #8
0
        /// <summary>
        /// Returns URL used to track Ecommerce Orders
        /// Calling this function will reinitializes the property ecommerceItems to empty array
        /// so items will have to be added again via addEcommerceItem()
        /// </summary>
        public string getUrlTrackEcommerceOrder(string orderId, double grandTotal, double subTotal = Double.MinValue, double tax = Double.MinValue, double shipping = Double.MinValue, double discount = Double.MinValue)
        {
            if (String.IsNullOrEmpty(orderId))
            {
                throw new Exception("You must specifiy an orderId for the Ecommerce order");
            }

            string url = getUrlTrackEcommerce(grandTotal, subTotal, tax, shipping, discount);

            url += "&ec_id=" + urlEncode(orderId);

            ecommerceLastOrderTimestamp = forcedDatetime.Equals(DateTimeOffset.MinValue) ? DateTimeOffset.Now : forcedDatetime;

            return(url);
        }
 public override bool Equals(object o)
 {
     if (o is Iso8601SerializableDateTimeOffset)
     {
         return(value.Equals(((Iso8601SerializableDateTimeOffset)o).value));
     }
     else if (o is DateTimeOffset)
     {
         return(value.Equals((DateTimeOffset)o));
     }
     else
     {
         return(false);
     }
 }
Пример #10
0
        public override bool IsEqual(object x, object y)
        {
            if (x == y)
            {
                return(true);
            }

            if (x is IOptional optionalX)
            {
                x = optionalX.MatchUntypedUnsafe(a => a, () => null);
            }

            if (y is IOptional optionalY)
            {
                y = optionalY.MatchUntypedUnsafe(a => a, () => null);
            }

            if (x == null || y == null)
            {
                return(false);
            }

            DateTimeOffset date1 = (DateTimeOffset)x;
            DateTimeOffset date2 = (DateTimeOffset)y;

            return(date1.Equals(date2));
        }
Пример #11
0
 public override bool Equals(object obj)
 {
     return(obj is ResponseTime other &&
            EqualityComparer <HttpResponseMessage> .Default.Equals(response, other.response) &&
            start.Equals(other.start) &&
            end.Equals(other.end));
 }
            public bool Equals(BulkDateTimeSearchParamTableTypeV2Row x, BulkDateTimeSearchParamTableTypeV2Row y)
            {
                if (x.SearchParamId != y.SearchParamId)
                {
                    return(false);
                }

                if (!DateTimeOffset.Equals(x.StartDateTime, y.StartDateTime))
                {
                    return(false);
                }

                if (!DateTimeOffset.Equals(x.EndDateTime, y.EndDateTime))
                {
                    return(false);
                }

                if (x.IsLongerThanADay != y.IsLongerThanADay)
                {
                    return(false);
                }

                if (x.IsMax != y.IsMax)
                {
                    return(false);
                }

                if (x.IsMin != y.IsMin)
                {
                    return(false);
                }

                return(true);
            }
Пример #13
0
 protected bool Equals(AllTypes <T> other)
 {
     return(Id == other.Id && NullableId == other.NullableId &&
            Byte == other.Byte &&
            Short == other.Short &&
            Int == other.Int &&
            Long == other.Long &&
            UShort == other.UShort &&
            UInt == other.UInt &&
            ULong == other.ULong &&
            Float.Equals(other.Float) &&
            Double.Equals(other.Double) &&
            Decimal == other.Decimal &&
            string.Equals(String, other.String) &&
            DateTime.Equals(other.DateTime) &&
            TimeSpan.Equals(other.TimeSpan) &&
            DateTimeOffset.Equals(other.DateTimeOffset) &&
            Guid.Equals(other.Guid) &&
            Char == other.Char &&
            NullableDateTime.Equals(other.NullableDateTime) &&
            NullableTimeSpan.Equals(other.NullableTimeSpan) &&
            StringList.EquivalentTo(other.StringList) &&
            StringArray.EquivalentTo(other.StringArray) &&
            StringMap.EquivalentTo(other.StringMap) &&
            IntStringMap.EquivalentTo(other.IntStringMap) &&
            Equals(SubType, other.SubType) &&
            Equals(GenericType, other.GenericType));
 }
Пример #14
0
            public bool Equals(BulkTokenDateTimeCompositeSearchParamTableTypeV1Row x, BulkTokenDateTimeCompositeSearchParamTableTypeV1Row y)
            {
                if (x.SearchParamId != y.SearchParamId)
                {
                    return(false);
                }

                if (!string.Equals(x.Code1, y.Code1, StringComparison.Ordinal))
                {
                    return(false);
                }

                if (!EqualityComparer <int?> .Default.Equals(x.SystemId1, y.SystemId1))
                {
                    return(false);
                }

                if (!DateTimeOffset.Equals(x.StartDateTime2, y.StartDateTime2))
                {
                    return(false);
                }

                if (!DateTimeOffset.Equals(x.EndDateTime2, y.EndDateTime2))
                {
                    return(false);
                }

                if (x.IsLongerThanADay2 != y.IsLongerThanADay2)
                {
                    return(false);
                }

                return(true);
            }
Пример #15
0
        /*
         * GYROSCOPE METHODS
         */
        void gyroscope_CurrentValueChanged(object sender, SensorReadingEventArgs <GyroscopeReading> e)
        {
            if (lastUpdateTime.Equals(DateTimeOffset.MinValue))
            {
                // If this is the first time CurrentValueChanged was raised,
                // only update the lastUpdateTime variable.
                lastUpdateTime = e.SensorReading.Timestamp;
            }
            else
            {
                // Get the current rotation rate. This value is in
                // radians per second.
                currentRotationRate = e.SensorReading.RotationRate;

                // Subtract the previous timestamp from the current one
                // to determine the time between readings
                TimeSpan timeSinceLastUpdate = e.SensorReading.Timestamp - lastUpdateTime;

                // Obtain the amount the device rotated since the last update
                // by multiplying by the rotation rate by the time since the last update.
                // (radians/second) * secondsSinceLastReading = radiansSinceLastReading
                cumulativeRotation += currentRotationRate * (float)(timeSinceLastUpdate.TotalSeconds);

                lastUpdateTime = e.SensorReading.Timestamp;
            }
        }
Пример #16
0
        internal static void Refresh()
        {
            reader = XmlReader.Create("https://osu.ppy.sh/feed/ranked/");
            var feed = SyndicationFeed.Load(reader);

            if (feed.Items.Count() == 0)
            {
                Program.PrintError("SyndicationFeed item count is zero.");
                return;
            }

            var latestItem   = feed.Items.First();
            var latestOffset = latestItem.PublishDate;

            if (_lastOffset != DateTimeOffset.MinValue &&
                !_lastOffset.Equals(latestOffset))
            {
                var link = latestItem.Links.First().Uri.AbsoluteUri;
                Program.PrintSuccess("New feed found.");
                Program.FlashWindow();
                Process.Start(link);
                PlayAudio();
            }
            _lastOffset = latestOffset;
        }
Пример #17
0
 public void ComapreDatetimes()
 {
     var dt1  = new DateTimeOffset(2010, 1, 1, 1, 1, 1, TimeSpan.FromHours(8));
     var dt2  = new DateTimeOffset(2010, 1, 1, 2, 1, 1, TimeSpan.FromHours(9));
     var res1 = (dt1 == dt2); // True
     var res2 = (dt1.Equals(dt2));
 }
 public void It_should_treat_Unspecified_and_Utc_as_equivalent_even_though_the_string_representations_are_not_equal()
 {
     // The BCL treats Unspecified the same as local.
     unspecified.Equals(utc).Should().BeTrue();
     unspecified.Should().Be(utc);
     unspecified.ToRoundtripString().Should().NotBe(utc.ToRoundtripString());
 }
Пример #19
0
    private static void CompareForEquality3()
    {
        // <Snippet11>
        DateTimeOffset firstTime = new DateTimeOffset(2007, 11, 15, 11, 35, 00,
                                                      DateTimeOffset.Now.Offset);
        DateTimeOffset secondTime = firstTime;

        Console.WriteLine("{0} = {1}: {2}",
                          firstTime, secondTime,
                          DateTimeOffset.Equals(firstTime, secondTime));

        // The value of firstTime remains unchanged
        secondTime = new DateTimeOffset(firstTime.DateTime,
                                        TimeSpan.FromHours(firstTime.Offset.Hours + 1));
        Console.WriteLine("{0} = {1}: {2}",
                          firstTime, secondTime,
                          DateTimeOffset.Equals(firstTime, secondTime));

        // value of firstTime remains unchanged
        secondTime = new DateTimeOffset(firstTime.DateTime + TimeSpan.FromHours(1),
                                        TimeSpan.FromHours(firstTime.Offset.Hours + 1));
        Console.WriteLine("{0} = {1}: {2}",
                          firstTime, secondTime,
                          DateTimeOffset.Equals(firstTime, secondTime));
        // The example produces the following output:
        //       11/15/2007 11:35:00 AM -07:00 = 11/15/2007 11:35:00 AM -07:00: True
        //       11/15/2007 11:35:00 AM -07:00 = 11/15/2007 11:35:00 AM -06:00: False
        //       11/15/2007 11:35:00 AM -07:00 = 11/15/2007 12:35:00 PM -06:00: True
        // </Snippet11>
    }
Пример #20
0
            public bool CanTrigger()
            {
                bool @return;

                // Check if it's the default value.
                if (LastTrigger.Equals(DateTimeOffset.MinValue) || CooldownMilliseconds == 0)
                {   // Default value meaning we can trigger the bot.
                    @return = true;
                }
                else
                {   // It's something else, so let's check if we can trigger it.
                    DateTimeOffset dtoNow          = DateTimeOffset.Now;
                    DateTimeOffset dtoCooldownTime = LastTrigger.AddMilliseconds(CooldownMilliseconds);

                    // Check if we've gone beyond the cooldown time.
                    if (dtoNow.ToUnixTimeMilliseconds() >= dtoCooldownTime.ToUnixTimeMilliseconds())
                    {
                        @return = true;

                        LastTrigger = DateTimeOffset.MinValue;
                    }
                    else
                    {
                        @return = false;
                    }
                }

                return(@return);
            }
Пример #21
0
        private void TestWithDecryptedKey()
        {
            byte[]         keyCipherText  = { 0, 1 };
            DateTimeOffset now            = DateTimeOffset.UtcNow;
            const bool     revoked        = false;
            const string   expectedResult = "success";

            string ActionWithDecryptedKey(CryptoKey key, DateTimeOffset datetimeOffset)
            {
                if (cryptoKeyMock.Object.Equals(key) && now.Equals(datetimeOffset))
                {
                    return(expectedResult);
                }

                return("failure");
            }

            keyManagementServiceMock.Setup(x => x.DecryptKey(keyCipherText, now, revoked))
            .Returns(cryptoKeyMock.Object);
            keyManagementServiceMock.Setup(x =>
                                           x.WithDecryptedKey(It.IsAny <byte[]>(), It.IsAny <DateTimeOffset>(), It.IsAny <bool>(), It.IsAny <Func <CryptoKey, DateTimeOffset, string> >()))
            .CallBase();

            string actualResult = keyManagementServiceMock.Object.WithDecryptedKey(keyCipherText, now, revoked, ActionWithDecryptedKey);

            Assert.Equal(expectedResult, actualResult);
        }
Пример #22
0
 protected bool Equals(UserTokenLog other)
 {
     return(string.Equals(TokenId, other.TokenId) &&
            string.Equals(UserId, other.UserId) &&
            string.Equals(Channel, other.Channel) &&
            DateTimeOffset.Equals(StartTime, other.StartTime) &&
            DateTimeOffset.Equals(EndTime, other.EndTime));
 }
Пример #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MostRecentlyUsed"/> class.
        /// </summary>
        /// <param name="filePath">The full file path for the file.</param>
        /// <param name="lastOpened">The last time the file was opened by the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="filePath"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     Thrown if <paramref name="filePath"/> is an empty string.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     Thrown if <paramref name="lastOpened"/> is <see langword="DateTimeOffset.MinValue" /> or <see cref="DateTimeOffset.MaxValue"/>.
        /// </exception>
        public MostRecentlyUsed(string filePath, DateTimeOffset lastOpened)
        {
            {
                Lokad.Enforce.Argument(() => filePath);
                Lokad.Enforce.Argument(() => filePath, Lokad.Rules.StringIs.NotEmpty);

                Lokad.Enforce.With <ArgumentException>(
                    !lastOpened.Equals(DateTimeOffset.MinValue),
                    Resources.Exceptions_Messages_ArgumentException);
                Lokad.Enforce.With <ArgumentException>(
                    !lastOpened.Equals(DateTimeOffset.MaxValue),
                    Resources.Exceptions_Messages_ArgumentException);
            }

            m_FilePath   = filePath;
            m_LastOpened = lastOpened;
        }
Пример #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MostRecentlyUsed"/> class.
        /// </summary>
        /// <param name="filePath">The full file path for the file.</param>
        /// <param name="lastOpened">The last time the file was opened by the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="filePath"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     Thrown if <paramref name="filePath"/> is an empty string.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     Thrown if <paramref name="lastOpened"/> is <see langword="DateTimeOffset.MinValue" /> or <see cref="DateTimeOffset.MaxValue"/>.
        /// </exception>
        public MostRecentlyUsed(string filePath, DateTimeOffset lastOpened)
        {
            {
                Lokad.Enforce.Argument(() => filePath);
                Lokad.Enforce.Argument(() => filePath, Lokad.Rules.StringIs.NotEmpty);

                Lokad.Enforce.With<ArgumentException>(
                    !lastOpened.Equals(DateTimeOffset.MinValue),
                    Resources.Exceptions_Messages_ArgumentException);
                Lokad.Enforce.With<ArgumentException>(
                    !lastOpened.Equals(DateTimeOffset.MaxValue),
                    Resources.Exceptions_Messages_ArgumentException);
            }

            m_FilePath = filePath;
            m_LastOpened = lastOpened;
        }
 private static void ShowDateAndTimeInfo(DateTimeOffset newTime)
 {
     Console.WriteLine("{0} converts to {1}", sourceTime, newTime);
     Console.WriteLine("{0} and {1} are equal: {2}",
                       sourceTime, newTime, sourceTime.Equals(newTime));
     Console.WriteLine("{0} and {1} are identical: {2}",
                       sourceTime, newTime,
                       sourceTime.EqualsExact(newTime));
     Console.WriteLine();
 }
Пример #26
0
 public bool Equals(HybridTime other)
 {
     if (SystemTime.Equals(other.SystemTime))
     {
         return(VectorTime.Equals(other.VectorTime));
     }
     else
     {
         return(false);
     }
 }
Пример #27
0
 protected bool IsDifferent(DateTimeOffset a, DateTimeOffset b, PropertyPath path)
 {
     if (!DateTimeOffset.Equals(a, b))
     {
         Report(path, $"different values '{a}' != '{b}'"); return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #28
0
        /// <summary>
        /// Checks whether the current resource has changed since we got it.
        /// </summary>
        /// <param name="request">The HTTP request message which led to this response message.</param>
        /// <param name="lastModified">The last update time.</param>
        /// <returns>
        ///   <c>true</c> if [is modified since] [the specified request]; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsModifiedSince(this HttpRequestMessage request, DateTime lastModified)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            // Recode the time value without millisecs (JavaScript workaround).
            lastModified = new DateTime(lastModified.Year, lastModified.Month, lastModified.Day, lastModified.Hour, lastModified.Minute, lastModified.Second, 0).ToUniversalTime();
            return(!(request.Headers.IfModifiedSince != null && DateTimeOffset.Equals(request.Headers.IfModifiedSince.Value, lastModified)));
        }
Пример #29
0
 public bool Equals(LeaveMessage other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(string.Equals(this.VisitorName, other.VisitorName) && DateTimeOffset.Equals(this.LeaveTime, other.LeaveTime));
 }
Пример #30
0
        private static string GetGoodsString(ClientData client)
        {
            var contractNumber = string.IsNullOrWhiteSpace(client.ContractNumber) ? "___" : client.ContractNumber;
            var contractDate   = DateTimeOffset.Equals(client.ContractDate, DateTimeOffset.MinValue)
                                ? "______________"
                                : client.ContractDate.ToString("dd MMMM yyyy");

            return(string.Format(
                       "Оплата по договору {0} от {1}. За одежду, обувь и другие непродовольственные заказы.",
                       contractNumber,
                       contractDate));
        }
Пример #31
0
        private string getRequest(int idSite)
        {
            var url = this.getBaseUrl() +
                      "?idsite=" + idSite +
                      "&rec=1" +
                      "&apiv=" + VERSION +
                      "&r=" + new Random().Next(0, 1000000).ToString("000000") +

                      // Only allowed for Super User, token_auth required,
                      (!String.IsNullOrEmpty(ip) ? "&cip=" + ip : "") +
                      (!String.IsNullOrEmpty(forcedVisitorId) ? "&cid=" + forcedVisitorId : "&_id=" + visitorId) +
                      (!forcedDatetime.Equals(DateTimeOffset.MinValue) ? "&cdt=" + formatDateValue(forcedDatetime) : "") +
                      (!String.IsNullOrEmpty(token_auth) && !this.doBulkRequests ? "&token_auth=" + urlEncode(token_auth) : "") +

                      // These parameters are set by the JS, but optional when using API
                      (!String.IsNullOrEmpty(plugins) ? plugins : "") +
                      (!localTime.Equals(DateTimeOffset.MinValue) ? "&h=" + localTime.Hour + "&m=" + localTime.Minute + "&s=" + localTime.Second : "") +
                      ((width != 0 && height != 0) ? "&res=" + width + "x" + height : "") +
                      (hasCookies ? "&cookie=1" : "") +
                      (!ecommerceLastOrderTimestamp.Equals(DateTimeOffset.MinValue) ? "&_ects=" + formatTimestamp(ecommerceLastOrderTimestamp) : "") +

                      // Various important attributes
                      (!String.IsNullOrEmpty(customData) ? "&data=" + customData : "") +
                      (visitorCustomVar.Count() > 0 ? "&_cvar=" + urlEncode(new JavaScriptSerializer().Serialize(visitorCustomVar)) : "") +
                      (pageCustomVar.Count() > 0 ? "&cvar=" + urlEncode(new JavaScriptSerializer().Serialize(pageCustomVar)) : "") +

                      // URL parameters
                      (!String.IsNullOrEmpty(pageUrl) ? "&url=" + urlEncode(pageUrl) : "") +
                      (!String.IsNullOrEmpty(urlReferrer) ? "&urlref=" + urlEncode(urlReferrer) : "") +

                      // Attribution information, so that Goal conversions are attributed to the right referrer or campaign
                      // Campaign name
                      ((attributionInfo != null && !String.IsNullOrEmpty(attributionInfo.campaignName)) ? "&_rcn=" + urlEncode(attributionInfo.campaignName) : "") +
                      // Campaign keyword
                      ((attributionInfo != null && !String.IsNullOrEmpty(attributionInfo.campaignKeyword)) ? "&_rck=" + urlEncode(attributionInfo.campaignKeyword) : "") +
                      // Timestamp at which the referrer was set
                      ((attributionInfo != null && !attributionInfo.referrerTimestamp.Equals(DateTimeOffset.MinValue)) ? "&_refts=" + formatTimestamp(attributionInfo.referrerTimestamp) : "") +
                      // Referrer URL
                      ((attributionInfo != null && !String.IsNullOrEmpty(attributionInfo.referrerUrl)) ? "&_ref=" + urlEncode(attributionInfo.referrerUrl) : "") +

                      // DEBUG
                      DEBUG_APPEND_URL;

            // Reset page level custom variables after this page view
            pageCustomVar = new Dictionary <string, string[]>();

            return(url);
        }
Пример #32
0
 public static void ValidateDateNotDefault(DateTimeOffset date, string fieldName)
 {
     if(date.Equals(DateTimeOffset.MinValue) || date.Equals(DateTimeOffset.MaxValue))
         throw new OrderFieldBadFormatException(string.Format("{0} date value must have a valid logical date (not default value).", fieldName));
 }
Пример #33
0
        /// <summary>
        /// Initializes the builder. This resets all the
        /// internal data structures and prepares them for
        /// the reception of data for a new <see cref="TestSection"/>.
        /// </summary>
        /// <param name="name">The name of the test section.</param>
        /// <param name="startTime">The start time.</param>
        /// <exception cref="ArgumentNullException">
        ///   Thrown when <paramref name="name"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///   Thrown when <paramref name="name"/> is an empty string.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   Thrown when <paramref name="startTime"/> is equal to <see cref="DateTimeOffset.MinValue"/>.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   Thrown when <paramref name="startTime"/> is equal to <see cref="DateTimeOffset.MaxValue"/>.
        /// </exception>
        public void Initialize(string name, DateTimeOffset startTime)
        {
            {
             Lokad.Enforce.Argument(() => name);
             Lokad.Enforce.Argument(() => name, Lokad.Rules.StringIs.NotEmpty);

             Lokad.Enforce.With<ArgumentOutOfRangeException>(
               !startTime.Equals(DateTimeOffset.MinValue),
               Resources.Exceptions_Messages_ArgumentOutOfRange,
               startTime);
             Lokad.Enforce.With<ArgumentOutOfRangeException>(
               !startTime.Equals(DateTimeOffset.MaxValue),
               Resources.Exceptions_Messages_ArgumentOutOfRange,
               startTime);
             }

             Clear();
             m_Name = name;
             m_StartTime = startTime;
        }
Пример #34
0
		public void EqualsObject ()
		{
			DateTimeOffset offset1 = new DateTimeOffset ();
			Assert.IsFalse (offset1.Equals (null), "null"); // found using Gendarme :)
			Assert.IsTrue (offset1.Equals (offset1), "self");
			DateTimeOffset offset2 = new DateTimeOffset (DateTime.Today);
			Assert.IsFalse (offset1.Equals (offset2), "1!=2");
			Assert.IsFalse (offset2.Equals (offset1), "2!=1");
		}
Пример #35
0
        public static void Equals(DateTimeOffset dateTimeOffset1, object obj, bool expectedEquals, bool expectedEqualsExact)
        {
            Assert.Equal(expectedEquals, dateTimeOffset1.Equals(obj));
            if (obj is DateTimeOffset)
            {
                DateTimeOffset dateTimeOffset2 = (DateTimeOffset)obj;
                Assert.Equal(expectedEquals, dateTimeOffset1.Equals(dateTimeOffset2));
                Assert.Equal(expectedEquals, DateTimeOffset.Equals(dateTimeOffset1, dateTimeOffset2));

                Assert.Equal(expectedEquals, dateTimeOffset1.GetHashCode().Equals(dateTimeOffset2.GetHashCode()));
                Assert.Equal(expectedEqualsExact, dateTimeOffset1.EqualsExact(dateTimeOffset2));

                Assert.Equal(expectedEquals, dateTimeOffset1 == dateTimeOffset2);
                Assert.Equal(!expectedEquals, dateTimeOffset1 != dateTimeOffset2);
            }
        }
Пример #36
0
		public void CompareTwoDateInDiffTZ ()
		{
			DateTimeOffset dt1 = new DateTimeOffset (2007, 12, 16, 15, 06, 00, new TimeSpan (1, 0, 0));
			DateTimeOffset dt2 = new DateTimeOffset (2007, 12, 16, 9, 06, 00, new TimeSpan (-5, 0, 0));
			DateTimeOffset dt3 = new DateTimeOffset (2007, 12, 16, 14, 06, 00, new TimeSpan (1, 0, 0));
			object o = dt1;
			Assert.IsTrue (dt1.CompareTo (dt2) == 0);
			Assert.IsTrue (DateTimeOffset.Compare (dt1, dt2) == 0);
			Assert.IsTrue (dt1 == dt2);
			Assert.IsTrue (dt1.Equals (dt2));
			Assert.IsFalse (dt1 == dt3);
			Assert.IsTrue (dt1 != dt3);
			Assert.IsFalse (dt1.EqualsExact (dt2));
			Assert.IsTrue (dt1.CompareTo (dt3) > 0);
			Assert.IsTrue (((IComparable)dt1).CompareTo (o) == 0);
		}
Пример #37
0
        /// <summary>
        /// Adds the warning message.
        /// </summary>
        /// <param name="time">The time on which the message was logged.</param>
        /// <param name="warningMessage">The warning message.</param>
        /// <exception cref="ArgumentNullException">
        ///   Thrown when <paramref name="warningMessage"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///   Thrown when <paramref name="warningMessage"/> is an empty string.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   Thrown when <paramref name="time"/> is equal to <see cref="DateTimeOffset.MinValue"/>.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   Thrown when <paramref name="time"/> is equal to <see cref="DateTimeOffset.MaxValue"/>.
        /// </exception>
        /// <exception cref="CannotAddMessageToUninitializedTestSectionException">
        ///   Thrown when the <c>Initialize</c> method has not been called.
        /// </exception>
        public void AddWarningMessage(DateTimeOffset time, string warningMessage)
        {
            {
             Lokad.Enforce.Argument(() => warningMessage);
             Lokad.Enforce.Argument(() => warningMessage, Lokad.Rules.StringIs.NotEmpty);

             Lokad.Enforce.With<ArgumentOutOfRangeException>(
               !time.Equals(DateTimeOffset.MinValue),
               Resources.Exceptions_Messages_ArgumentOutOfRange,
               time);
             Lokad.Enforce.With<ArgumentOutOfRangeException>(
               !time.Equals(DateTimeOffset.MaxValue),
               Resources.Exceptions_Messages_ArgumentOutOfRange,
               time);
             }

             if (!WasInitialized)
             {
            throw new CannotAddMessageToUninitializedTestSectionException();
             }

             m_WarningMessages.Add(new DateBasedTestInformation(time, warningMessage));
        }