コード例 #1
0
        public void NullOrEmptyStringCanBeParsedAsTimeOffsetsObject()
        {
            ITimeOffsets parsed;

            Assert.IsFalse(TimeOffsets.TryParse(null, out parsed));
            Assert.IsFalse(TimeOffsets.TryParse("", out parsed));
        }
コード例 #2
0
        /// <summary>
        /// Add a time offset entry to the collection.
        /// </summary>
        /// <param name="newEntry">The entry to be added.</param>
        public static void AddEntry(TimeOffsetEntry newEntry)
        {
            foreach (TimeOffsetEntry oldEntry in TimeOffsets)
            {
                if (oldEntry.CountryCode == newEntry.CountryCode && oldEntry.Region == newEntry.Region)
                {
                    return;
                }

                if (oldEntry.CountryCode == newEntry.CountryCode)
                {
                    if (oldEntry.Region > newEntry.Region)
                    {
                        TimeOffsets.Insert(TimeOffsets.IndexOf(oldEntry), newEntry);
                        return;
                    }
                }
                else
                {
                    if (oldEntry.CountryCode.CompareTo(newEntry.CountryCode) > 0)
                    {
                        TimeOffsets.Insert(TimeOffsets.IndexOf(oldEntry), newEntry);
                        return;
                    }
                }
            }

            TimeOffsets.Add(newEntry);
        }
コード例 #3
0
 void IViewModel.OnClosingDialog()
 {
     source.Annotation = annotation;
     if (TimeOffsets.TryParse(timeOffset, out var newTimeOffset))
     {
         source.TimeOffsets = newTimeOffset;
     }
 }
コード例 #4
0
        void IViewEvents.OnClosingDialog()
        {
            source.Annotation = currentWindow.ReadControl(ControlFlag.AnnotationTextBox | ControlFlag.Value);
            ITimeOffsets newTimeOffset;

            if (TimeOffsets.TryParse(currentWindow.ReadControl(ControlFlag.TimeOffsetTextBox | ControlFlag.Value), out newTimeOffset))
            {
                source.TimeOffsets = newTimeOffset;
            }
        }
コード例 #5
0
        void TestStringification()
        {
            var          timeOffsets = init.ToTimeOffsets();
            ITimeOffsets parsed;
            var          str = timeOffsets.ToString();

            Assert.IsTrue(TimeOffsets.TryParse(str, out parsed));
            Assert.IsTrue(parsed.Equals(timeOffsets));
            Assert.IsTrue(timeOffsets.Equals(parsed));
            Assert.AreEqual(timeOffsets.GetHashCode(), parsed.GetHashCode());
        }
コード例 #6
0
        public void TimeSpanCanBeParsedAsTimeOffsetsObject()
        {
            ITimeOffsets parsed;

            Assert.IsTrue(TimeOffsets.TryParse("00:00:00", out parsed));
            Assert.AreEqual(TimeSpan.Zero, parsed.BaseOffset);

            Assert.IsTrue(TimeOffsets.TryParse("00:00:01", out parsed));
            Assert.AreEqual(TimeSpan.FromSeconds(1), parsed.BaseOffset);

            Assert.IsTrue(TimeOffsets.TryParse("00:00:00.001", out parsed));
            Assert.AreEqual(TimeSpan.FromMilliseconds(1), parsed.BaseOffset);
        }