Exemple #1
0
    public bool PosTest6()
    {
        bool retVal = true;

        const string c_TEST_DESC = "PosTest6: Verify n1 greater than n2";
        const string c_TEST_ID   = "P006";
        Random       rand        = new Random(-55);
        int?         n1          = rand.Next(Int32.MinValue + 1, Int32.MaxValue);
        int?         n2          = n1 - 1;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            int result = Nullable.Compare <int>(n1, n2);
            if (result <= 0)
            {
                string errorDesc = "Return value is not greater than zero as expected: Actual(" + result + ")";
                errorDesc += " \n  n1 is " + n1;
                errorDesc += "\n n2 is  " + n2;
                TestLibrary.TestFramework.LogError("011 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e + "\n n1 is " + n1 + " and n2 is " + n2);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Exemple #2
0
        public Range <T> GetIntersection(Range <T> other)
        {
            if (!Intersects(other))
            {
                throw new InvalidOperationException("There is no intersection between these range objects.");
            }

            T?start, end;

            if (!Start.HasValue ^ !other.Start.HasValue)
            {
                start = Start ?? other.Start.Value;
            }
            else
            {
                start = Nullable.Compare(Start, other.Start) >= 0 ? Start : other.Start;
            }

            if (!End.HasValue ^ !other.End.HasValue)
            {
                end = End ?? other.End.Value;
            }
            else
            {
                end = Nullable.Compare(End, other.End) < 0 ? End : other.End;
            }

            return(new Range <T>(start, end));
        }
Exemple #3
0
    public bool PosTest3()
    {
        bool retVal = true;

        const string c_TEST_DESC = "PosTest3: Verify n1 has value and n2 is null";
        const string c_TEST_ID   = "P003";
        int?         n1          = TestLibrary.Generator.GetInt32(-55);
        int?         n2          = null;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            int result = Nullable.Compare <int>(n1, n2);
            if (result <= 0)
            {
                string errorDesc = "Return value is less than zero as expected: Actual(" + result + ")";
                errorDesc += " \n  n1 is " + n1;
                errorDesc += "\n n2 is  null";
                TestLibrary.TestFramework.LogError("005 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e + "\n n1 is " + n1 + " and n2 is null");
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Exemple #4
0
        private async Task <Guid[]> GetItemsToProcess()
        {
            using (var scope = _serviceScopeFactory.CreateScope())
            {
                // Get all Workspaces that have 1 or more Runs created after it's LastSyncTime
                var dbContext = scope.ServiceProvider.GetRequiredService <CasterContext>();

                var workspaceDict = await dbContext.Workspaces
                                    .AsNoTracking()
                                    .ToDictionaryAsync(x => x.Id, x => x.LastSynced);

                var runs = await dbContext.Runs
                           .AsNoTracking()
                           .GroupBy(x => x.WorkspaceId)
                           .Select(g => new {
                    WorkspaceId = g.Key,
                    LastRun     = g.Max(r => r.CreatedAt)
                })
                           .ToArrayAsync();

                var workspaceIds = new List <Guid>();

                foreach (var kvp in workspaceDict)
                {
                    var run = runs.Where(r => r.WorkspaceId == kvp.Key).FirstOrDefault();

                    if (run != null && Nullable.Compare(run.LastRun, kvp.Value) > 0)
                    {
                        workspaceIds.Add(kvp.Key);
                    }
                }

                return(workspaceIds.ToArray());
            }
        }
Exemple #5
0
        /// <summary>
        /// Get meta data for the last Pelion Device Management API call
        /// </summary>
        /// <returns><see cref="ApiMetadata"/></returns>
        public static ApiMetadata GetLastApiMetadata()
        {
            var lastMds   = mds.Client.Configuration.Default.ApiClient.LastApiResponse.LastOrDefault()?.Headers?.Where(m => m.Name == "Date")?.Select(d => DateTime.Parse(d.Value.ToString()))?.FirstOrDefault();
            var lastStats = statistics.Client.Configuration.Default.ApiClient.LastApiResponse.LastOrDefault()?.Headers?.Where(m => m.Name == "Date")?.Select(d => DateTime.Parse(d.Value.ToString()))?.FirstOrDefault();

            return(Nullable.Compare(lastMds, lastStats) > 0 ? ApiMetadata.Map(mds.Client.Configuration.Default.ApiClient.LastApiResponse.LastOrDefault()) : ApiMetadata.Map(statistics.Client.Configuration.Default.ApiClient.LastApiResponse.LastOrDefault()));
        }
Exemple #6
0
        public int Compare(object x, object y)
        {
            var partX = (ParticipantListItemViewModel)x;
            var partY = (ParticipantListItemViewModel)y;

            return(-Nullable.Compare <DateTime>(partX.LastAttemptedContact, partY.LastAttemptedContact));
        }
Exemple #7
0
    public bool PosTest4()
    {
        bool retVal = true;

        const string c_TEST_DESC = "PosTest4: Verify n1 and n2 are euqal";
        const string c_TEST_ID   = "P004";
        char?        n1          = TestLibrary.Generator.GetChar(-55);
        char?        n2          = n1;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            int result = Nullable.Compare <char>(n1, n2);
            if (result != 0)
            {
                string errorDesc = "Return value is not zero as expected: Actual(" + result + ")";
                errorDesc += " \n  n1 is " + n1;
                errorDesc += "\n n2 is  " + n2;
                TestLibrary.TestFramework.LogError("007 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e + "\n n1 is " + n1 + " and n2 is " + n2);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
        /// <inheritdoc/>
        public int CompareTo(AudioBookFileInfo other)
        {
            if (ReferenceEquals(this, other))
            {
                return(0);
            }

            if (ReferenceEquals(null, other))
            {
                return(1);
            }

            var chapterNumberComparison = Nullable.Compare(ChapterNumber, other.ChapterNumber);

            if (chapterNumberComparison != 0)
            {
                return(chapterNumberComparison);
            }

            var partNumberComparison = Nullable.Compare(PartNumber, other.PartNumber);

            if (partNumberComparison != 0)
            {
                return(partNumberComparison);
            }

            return(string.Compare(Path, other.Path, StringComparison.Ordinal));
        }
Exemple #9
0
        public int CompareTo(Holiday other)
        {
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            if (ReferenceEquals(null, other))
            {
                return(1);
            }
            var monthComparison = Month.CompareTo(other.Month);

            if (monthComparison != 0)
            {
                return(monthComparison);
            }
            var dayComparison = Day.CompareTo(other.Day);

            if (dayComparison != 0)
            {
                return(dayComparison);
            }
            var descriptionComparison = string.Compare(Description, other.Description, StringComparison.Ordinal);

            if (descriptionComparison != 0)
            {
                return(descriptionComparison);
            }
            return(Nullable.Compare(Type, other.Type));
        }
        /// <summary>
        /// Retrieves albums from OneDrive.
        /// </summary>
        public async Task <List <OneDriveItemModel> > GetAlbumsAsync()
        {
            var bundleUrl = oneDriveClient?.Drive
                            ?.AppendSegmentToRequestUrl("bundles");
            List <OneDriveItemModel> items = new List <OneDriveItemModel>();

            try
            {
                var albums = await new DriveItemsCollectionRequestBuilder(bundleUrl, oneDriveClient)?.Request()
                             .Filter("bundle/album ne null")
                             .Expand("thumbnails")
                             .GetAsync();
                foreach (var album in albums)
                {
                    items.Add(new OneDriveItemModel(album));
                }
            }
            catch (ServiceException e)
            {
                Debug.WriteLine(e?.Error?.Message);
                return(null);
            }
            // Sort albums by creation date (starting from most recent)
            items.Sort((x, y) => Nullable.Compare(y.Item.CreatedDateTime, x.Item.CreatedDateTime));
            return(items);
        }
Exemple #11
0
        public int CompareTo(CalendarCorrelationMatch other)
        {
            int num;

            if (this.Id == other.Id)
            {
                num = 0;
            }
            else
            {
                num = Nullable.Compare <int>(this.appointmentSequenceNumber, other.appointmentSequenceNumber);
                if (num == 0)
                {
                    if (this.lastModifiedTime != null && other.lastModifiedTime != null)
                    {
                        num = this.lastModifiedTime.Value.CompareTo(other.lastModifiedTime.Value, CalendarCorrelationMatch.LastModifiedTimeTreshold);
                    }
                    if (num == 0)
                    {
                        num = Nullable.Compare <ExDateTime>(this.ownerCriticalChangeTime, other.ownerCriticalChangeTime);
                        if (num == 0)
                        {
                            num = this.documentId.CompareTo(other.documentId);
                        }
                    }
                }
            }
            return(num);
        }
Exemple #12
0
        /// <summary>
        /// Compares this <see cref="Sku"/> with another instance.
        /// </summary>
        /// <param name="other"> <see cref="Sku"/> object to compare. </param>
        /// <returns> -1 for less than, 0 for equals, 1 for greater than. </returns>
        public int CompareTo(Sku other)
        {
            if (other == null)
            {
                return(1);
            }

            if (ReferenceEquals(this, other))
            {
                return(0);
            }

            int compareResult = 0;

            if ((compareResult = string.Compare(Name, other.Name, StringComparison.InvariantCultureIgnoreCase)) == 0 &&
                (compareResult = string.Compare(Family, other.Family, StringComparison.InvariantCultureIgnoreCase)) == 0 &&
                (compareResult = string.Compare(Model, other.Model, StringComparison.InvariantCultureIgnoreCase)) == 0 &&
                (compareResult = string.Compare(Size, other.Size, StringComparison.InvariantCultureIgnoreCase)) == 0 &&
                (compareResult = string.Compare(Tier, other.Tier, StringComparison.InvariantCultureIgnoreCase)) == 0)
            {
                return(Nullable.Compare <long>(Capacity, other.Capacity));
            }

            return(compareResult);
        }
Exemple #13
0
        /// <summary>
        /// Performs a comparison of the current object to another object and returns a value
        /// indicating whether the object is less than, greater than, or equal to the other.
        /// </summary>
        /// <param name="other">The <see cref="ApiVersion">other</see> object to compare to.</param>
        /// <returns>Zero if the objects are equal, one if the current object is greater than the
        /// <paramref name="other"/> object, or negative one if the current object is less than the
        /// <paramref name="other"/> object.</returns>
        /// <remarks>The version <see cref="P:Status">status</see> is not included in comparisons.</remarks>
        public virtual int CompareTo(ApiVersion other)
        {
            if (other == null)
            {
                return(1);
            }

            var result = Nullable.Compare(GroupVersion, other.GroupVersion);

            if (result == 0)
            {
                result = Nullable.Compare(MajorVersion, other.MajorVersion);

                if (result == 0)
                {
                    result = ImpliedMinorVersion.CompareTo(other.ImpliedMinorVersion);

                    if (result == 0)
                    {
                        result = StringComparer.OrdinalIgnoreCase.Compare(Status, other.Status);

                        if (result != 0)
                        {
                            result = result < 0 ? -1 : 1;
                        }
                    }
                }
            }

            return(result);
        }
Exemple #14
0
        static void Main(string[] args)
        {
            Nullable <int> i = null;

            Console.WriteLine("i=" + i);
            Console.WriteLine(i.GetValueOrDefault());
            if (i.HasValue)
            {
                Console.WriteLine(i.Value); // or Console.WriteLine(i)
            }
            else
            {
                Console.WriteLine("Null");
            }
            int?x = null;
            int j = x ?? 0;

            Console.WriteLine("x = {0}, j = {1}", x, j);
            Console.WriteLine("x >= 10 ? {0}", x >= 10);
            Console.WriteLine("x < 10 ? {0}", x < 10);
            if (Nullable.Compare <int>(i, j) < 0)
            {
                Console.WriteLine("i < j");
            }
            else if (Nullable.Compare <int>(i, j) > 0)
            {
                Console.WriteLine("i > j");
            }
            else
            {
                Console.WriteLine("i = j");
            }
        }
Exemple #15
0
        protected internal virtual async Task UpdateRelatedClientSecretsAsync(IDictionary <ClientEntity, ClientEntity> updates)
        {
            await this.UpdateRelationsAsync(
                (entityRelations, importRelationItemToMatch) =>
            {
                // We can add more conditions here if necessary.
                return(entityRelations.FirstOrDefault(entityRelation => string.Equals(entityRelation.Value, importRelationItemToMatch.Value, StringComparison.Ordinal)));
            },
                (entityItem, importItem) =>
            {
                const StringComparison stringComparison = StringComparison.Ordinal;

                if (
                    !string.Equals(entityItem.Description, importItem.Description, stringComparison) ||
                    Nullable.Compare(entityItem.Expiration, importItem.Expiration) != 0 ||
                    !string.Equals(entityItem.Type, importItem.Type, stringComparison) ||
                    !string.Equals(entityItem.Value, importItem.Value, stringComparison)
                    )
                {
                    entityItem.Created = importItem.Created;
                }

                entityItem.Description = importItem.Description;
                entityItem.Expiration  = importItem.Expiration;
                entityItem.Type        = importItem.Type;
                entityItem.Value       = importItem.Value;
            },
                entity => entity.ClientSecrets,
                updates
                );
        }
Exemple #16
0
        internal void ValidateBitMapIndexOrdering()
        {
            var validationTimer = Stopwatch.StartNew();

            ValidateItems(GetTagByQueryBitMapLookup(QueryType.LastActivityDate).ToDictionary(item => item.Key, item => item.Value as IEnumerable <int>),
                          (qu, prev) => qu.LastActivityDate <= prev.LastActivityDate,
                          "BitMaps-" + QueryType.LastActivityDate,
                          questionLookup: GetTagByQueryLookup(QueryType.LastActivityDate)[TagServer.ALL_TAGS_KEY]);

            ValidateItems(GetTagByQueryBitMapLookup(QueryType.CreationDate).ToDictionary(item => item.Key, item => item.Value as IEnumerable <int>),
                          (qu, prev) => qu.CreationDate <= prev.CreationDate,
                          "BitMaps-" + QueryType.CreationDate,
                          questionLookup: GetTagByQueryLookup(QueryType.CreationDate)[TagServer.ALL_TAGS_KEY]);

            ValidateItems(GetTagByQueryBitMapLookup(QueryType.Score).ToDictionary(item => item.Key, item => item.Value as IEnumerable <int>),
                          (qu, prev) => Nullable.Compare(qu.Score, prev.Score) <= 0,
                          "BitMaps-" + QueryType.Score,
                          questionLookup: GetTagByQueryLookup(QueryType.Score)[TagServer.ALL_TAGS_KEY]);

            ValidateItems(GetTagByQueryBitMapLookup(QueryType.ViewCount).ToDictionary(item => item.Key, item => item.Value as IEnumerable <int>),
                          (qu, prev) => Nullable.Compare(qu.ViewCount, prev.ViewCount) <= 0,
                          "BitMaps-" + QueryType.ViewCount,
                          questionLookup: GetTagByQueryLookup(QueryType.ViewCount)[TagServer.ALL_TAGS_KEY]);

            ValidateItems(GetTagByQueryBitMapLookup(QueryType.AnswerCount).ToDictionary(item => item.Key, item => item.Value as IEnumerable <int>),
                          (qu, prev) => Nullable.Compare(qu.AnswerCount, prev.AnswerCount) <= 0,
                          "BitMaps-" + QueryType.AnswerCount,
                          questionLookup: GetTagByQueryLookup(QueryType.AnswerCount)[TagServer.ALL_TAGS_KEY]);

            validationTimer.Stop();
            Logger.LogStartupMessage("Took {0} ({1,6:N0} ms) to VALIDATE all the {2:N0} Bit Map Indexes\n",
                                     validationTimer.Elapsed, validationTimer.ElapsedMilliseconds, allTags.Count * 5);
        }
Exemple #17
0
        public static void Run()
        {
            Nullable <int> a = null;

            if (a.HasValue)
            {
                Console.WriteLine(a.Value); // or Console.WriteLine(i)
            }
            else
            {
                Console.WriteLine("Null");
            }

            double?D = null;

            int?i = null;
            int j = 10;

            if (Nullable.Compare <int>(i, j) < 0)
            {
                Console.WriteLine("i < j");
            }
            else if (Nullable.Compare <int>(i, j) > 0)
            {
                Console.WriteLine("i > j");
            }
            else
            {
                Console.WriteLine("i = j");
            }
        }
        public IEnumerable <PseudoDynamicEntity> Synchronize(IEnumerable <PseudoDynamicEntity> entities, [FromQuery(Name = "lastModified")] DateTime?lastModified)
        {
            foreach (var entity in entities)
            {
                entity.LastModified = DateTime.Now;

                if (_context.PseudoDynamicEntities.Any(e => e.Id == entity.Id))
                {
                    _context.Entry(entity).State = EntityState.Modified;
                }
                else
                {
                    _context.PseudoDynamicEntities.Add(entity);
                }
            }
            _context.SaveChanges();

            if (lastModified == null)
            {
                return(_context.PseudoDynamicEntities);
            }
            else
            {
                var entriesSinceLastSync = _context.PseudoDynamicEntities.Where(e => Nullable.Compare(e.LastModified, lastModified) > 0);
                return(entriesSinceLastSync);
            }
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            //ensure that only updates on current auth user and the users for this service
            Service tmp = _context.Service.AsNoTracking().FirstOrDefault(s => s.Id == Service.Id);

            if (!(ModelState.IsValid &&
                  tmp.CaregiverId == Service.CaregiverId &&
                  Service.CaregiverId == _userManager.GetUserId(User) &&
                  Nullable.Compare <int>(Service.Rate, tmp.Rate) == 0 &&
                  String.Equals(tmp.CustomerComments, Service.CustomerComments)))
            {
                return(Page());
            }

            _context.Attach(Service).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ServiceExists(Service.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemple #20
0
    public bool PosTest1()
    {
        bool retVal = true;

        const string c_TEST_DESC    = "PosTest1: Verify two Nullable<T> objects are null";
        const string c_TEST_ID      = "P001";
        char?        n1             = null;
        char?        n2             = null;
        int          expectedResult = 0;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            int result = Nullable.Compare <char>(n1, n2);
            if (expectedResult != result)
            {
                string errorDesc = "Return value is not " + expectedResult + " as expected: Actual(" + result + ")";
                errorDesc += " when  n1 and n2 are null ";
                TestLibrary.TestFramework.LogError("001 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e + "\n n1 and n2 are null");
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Exemple #21
0
        public void ExceptionThrownIfNullIsInserted()
        {
            IHeap <int?> heap = NewHeapInstance <int?>(
                10,
                (x, y) => Nullable.Compare(x, y));

            Assert.Throws <ArgumentNullException>(() => heap.Insert(null));
        }
Exemple #22
0
 public static int?Max(int?val1, int?val2)
 {
     return(Nullable.Compare(val1, val2) switch
     {
         -1 => val2.Value,
         1 => val1.Value,
         _ => (int?)null,
     });
Exemple #23
0
        public int Compare(Product expected, Product actual)
        {
            int temp;

            return((temp = expected.Id.CompareTo(actual.Id)) != 0 ? temp
                : (temp = expected.Name.CompareTo(actual.Name)) != 0 ? temp
                : (temp = Nullable.Compare(expected.CreateDate, actual.CreateDate)) != 0 ? temp
                : expected.isActive.CompareTo(actual.isActive));
        }
        /// <summary>
        /// Performs the IsPositive operation.
        /// </summary>
        /// <param name="currentValue">The current value.</param>
        /// <returns><c>true</c> if <paramref name="currentValue" /> is positive, <c>false</c> otherwise.</returns>
        protected virtual bool PerformIsPositiveOperation(T?currentValue)
        {
            if (!currentValue.HasValue)
            {
                return(false);
            }

            return(Nullable.Compare(currentValue, default(T)) > 0);
        }
Exemple #25
0
        public IActionResult Index(ReservationIndexViewModel model)
        {
            //1. Initialize Pager
            #region Pagination
            model.Pager              = model.Pager ?? new PagerViewModel();
            model.Pager.CurrentPage  = model.Pager.CurrentPage <= 0 ? 1 : model.Pager.CurrentPage;
            model.Pager.ItemsPerPage = model.Pager.ItemsPerPage <= 0 ? 10 : model.Pager.ItemsPerPage;
            #endregion

            //2. Filter
            model.Filter = model.Filter ?? new ReservationFilterViewModel();

            //Check for empty filters
            bool emptyCreatorName = string.IsNullOrWhiteSpace(model.Filter.CreatorName);
            bool emptyAfterDate   = model.Filter.AfterDate == null;
            bool emptyBeforeDate  = model.Filter.BeforeDate == null;

            //3. Get Reservations from db
            List <Reservation> reservations = _reservationRepository.Items.Include("CustomerReservations").AsEnumerable()
                                              .Where(item =>
                                                     //Get all reservations whose Arrival date is between the after and before filters
                                                     ((emptyAfterDate || Nullable.Compare <DateTime>(item.Arrival, model.Filter.AfterDate) >= 0) && (emptyBeforeDate || Nullable.Compare <DateTime>(item.Arrival, model.Filter.BeforeDate) <= 0)) &&
                                                     (emptyCreatorName || item.Creator.FullName.Contains(model.Filter.CreatorName))
                                                     ).ToList();

            //4. Build view model objects
            //Calculate total pages
            model.Pager.Pages = (int)Math.Ceiling((double)reservations.Count() / model.Pager.ItemsPerPage);

            //Calculate which reservations to show on the current page
            reservations = reservations.OrderBy(item => item.Id)
                           .Skip((model.Pager.CurrentPage - 1) * model.Pager.ItemsPerPage)
                           .Take(model.Pager.ItemsPerPage).ToList(); //TODO: Remove .ToList()

            //Make viewmodels from the Reservation items to show in the View
            model.Items = reservations.Select(item => new ReservationViewModel()
            {
                Id        = item.Id,
                RoomId    = item.RoomId,
                CreatorId = item.CreatorId,
                Creator   = new EmployeeViewModel()
                {
                    Id         = item.Creator.Id,
                    FirstName  = item.Creator.FirstName,
                    MiddleName = item.Creator.MiddleName,
                    LastName   = item.Creator.LastName
                },
                Arrival           = item.Arrival,
                Departure         = item.Departure,
                BreakfastIncluded = item.BreakfastIncluded,
                IsAllInclusive    = item.IsAllInclusive,
                TotalSum          = item.TotalSum
            });

            return(View(model));
        }
        /// <summary>
        /// @see IComparable#CompareTo.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public int CompareTo(ContextKey other)
        {
            if (other == null)
            {
                return(1);
            }
            var idCompare = Nullable.Compare(_id, other._id);

            return(idCompare == 0 ? _type.CompareTo(other._type) : idCompare);
        }
Exemple #27
0
        public int CompareTo(MeetingData other)
        {
            if (other == null)
            {
                return(1);
            }
            if (this.Id == other.Id)
            {
                return(0);
            }
            if (this.Exception != null || other.Exception != null)
            {
                return(((other.Exception != null) ? 1 : 0) - ((this.Exception != null) ? 1 : 0));
            }
            int num;

            if (GlobalObjectId.CompareCleanGlobalObjectIds(this.GlobalObjectId.CleanGlobalObjectIdBytes, other.GlobalObjectId.CleanGlobalObjectIdBytes))
            {
                num = Nullable.Compare <int>(new int?(this.SequenceNumber), new int?(other.SequenceNumber));
                if (num != 0)
                {
                    return(num);
                }
                num = this.LastModifiedTime.CompareTo(other.LastModifiedTime, MeetingData.LastModifiedTimeTreshold);
                if (num != 0)
                {
                    return(num);
                }
                num = this.OwnerCriticalChangeTime.CompareTo(other.OwnerCriticalChangeTime);
                if (num != 0)
                {
                    return(num);
                }
                num = this.DocumentId.CompareTo(other.DocumentId);
                if (num != 0)
                {
                    return(num);
                }
                if (this.ItemVersion != null && other.ItemVersion != null)
                {
                    num = Nullable.Compare <int>(this.ItemVersion, other.ItemVersion);
                    if (num != 0)
                    {
                        return(num);
                    }
                }
            }
            else
            {
                ExDateTime startTime  = this.StartTime;
                ExDateTime startTime2 = other.StartTime;
                num = ExDateTime.Compare(this.StartTime, other.StartTime);
            }
            return(num);
        }
        /// <summary>
        /// Performs a comparison of the current object to another object and returns a value
        /// indicating whether the object is less than, greater than, or equal to the other.
        /// </summary>
        /// <param name="other">The <see cref="ApiVersion">other</see> object to compare to.</param>
        /// <returns>Zero if the objects are equal, one if the current object is greater than the
        /// <paramref name="other"/> object, or negative one if the current object is less than the
        /// <paramref name="other"/> object.</returns>
        /// <remarks>The version <see cref="Status">status</see> is not included in comparisons.</remarks>
        public virtual int CompareTo(ApiVersion other)
        {
            if (other == null)
            {
                return(1);
            }

            var result = Nullable.Compare(GroupVersion, other.GroupVersion);

            if (result != 0)
            {
                return(result);
            }

            result = Nullable.Compare(MajorVersion, other.MajorVersion);

            if (result != 0)
            {
                return(result);
            }

            result = ImpliedMinorVersion.CompareTo(other.ImpliedMinorVersion);

            if (result != 0)
            {
                return(result);
            }

            if (IsNullOrEmpty(Status))
            {
                if (!IsNullOrEmpty(other.Status))
                {
                    result = 1;
                }
            }
            else if (IsNullOrEmpty(other.Status))
            {
                result = -1;
            }
            else
            {
                result = StringComparer.OrdinalIgnoreCase.Compare(Status, other.Status);

                if (result < 0)
                {
                    result = -1;
                }
                else if (result > 0)
                {
                    result = 1;
                }
            }

            return(result);
        }
        public int CompareTo(SemanticVersionPreReleaseTag other)
        {
            var nameComparison = StringComparer.InvariantCultureIgnoreCase.Compare(Name, other);

            if (nameComparison != 0)
            {
                return(nameComparison);
            }

            return(Nullable.Compare(Number, other.Number));
        }
Exemple #30
0
        public override void VerifySettings()
        {
            Name = Name ?? ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty);

            if (Min.HasValue && Max.HasValue && Nullable.Compare <T>(Min, Max) == 1)
            {
                throw new ArgumentException(Exceptions.MinPropertyMustBeLessThenMaxProperty.FormatWith("Min", "Max"));
            }

            base.VerifySettings();
        }