当前位置: 首页>>代码示例>>C#>>正文


C# Range.Contains方法代码示例

本文整理汇总了C#中Range.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Range.Contains方法的具体用法?C# Range.Contains怎么用?C# Range.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Range的用法示例。


在下文中一共展示了Range.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ContainsValue

 public void ContainsValue()
 {
     var target = new Range<int>(10, 20);
     Assert.IsTrue(target.Contains(10));
     Assert.IsTrue(target.Contains(20));
     Assert.IsTrue(target.Contains(14));
 }
开发者ID:avgx,项目名称:OrigoDB,代码行数:7,代码来源:RangeTests.cs

示例2: DefaultComparerExcludingStart

 public void DefaultComparerExcludingStart()
 {
     var subject = new Range<int>(0, 5).ExcludeStart();
     Assert.IsFalse(subject.IncludesStart);
     Assert.IsTrue(subject.IncludesEnd);
     Assert.IsFalse(subject.Contains(0));
     Assert.IsTrue(subject.Contains(1));
     Assert.IsTrue(subject.Contains(5));
 }
开发者ID:jzebedee,项目名称:Taj,代码行数:9,代码来源:RangeTest.cs

示例3: ExcludeBothEnds

 public void ExcludeBothEnds()
 {
     var subject = new Range<int>(0, 5).ExcludeStart().ExcludeEnd();
     Assert.IsFalse(subject.IncludesStart);
     Assert.IsFalse(subject.IncludesEnd);
     Assert.IsFalse(subject.Contains(0));
     Assert.IsTrue(subject.Contains(1));
     Assert.IsFalse(subject.Contains(5));
 }
开发者ID:dioptre,项目名称:nkd,代码行数:9,代码来源:RangeTest.cs

示例4: CheckContainment

 public void CheckContainment()
 {
     var range = new Range<int>(3, 10);
     Assert.IsTrue(range.Contains(5));
     Assert.IsTrue(range.Contains(3));
     Assert.IsTrue(range.Contains(10));
     Assert.IsFalse(range.Contains(-3));
     Assert.IsFalse(range.Contains(20));
 }
开发者ID:AllenConway,项目名称:SpackleNet,代码行数:9,代码来源:RangeTests.cs

示例5: CustomComparer

        public void CustomComparer()
        {
            var subject = new Range<string>("a", "e", StringComparer.Ordinal);
            Assert.IsFalse(subject.Contains("B"));
            Assert.IsTrue(subject.Contains("b"));

            subject = new Range<string>("a", "e", StringComparer.OrdinalIgnoreCase);
            Assert.IsTrue(subject.Contains("B"));
            Assert.IsTrue(subject.Contains("A"));
            Assert.IsTrue(subject.Contains("E"));
            Assert.IsFalse(subject.Contains("F"));
        }
开发者ID:jzebedee,项目名称:Taj,代码行数:12,代码来源:RangeTest.cs

示例6: ContainsShouldFailIfItIsNotInRange

        public void ContainsShouldFailIfItIsNotInRange()
        {
            var range = new Range<int>(1, 3);
            Assert.False(range.Contains(0));
            Assert.False(range.Contains(4));

            range = new Range<int>(null, 3);
            Assert.False(range.Contains(4));

            range = new Range<int>(1);
            Assert.False(range.Contains(0));
        }
开发者ID:jonathascosta,项目名称:SystemExtensions,代码行数:12,代码来源:RangeFixture.cs

示例7: ContainsShouldSuccessIfItIsAtLimit

        public void ContainsShouldSuccessIfItIsAtLimit()
        {
            var range = new Range<int>(1, 3);
            Assert.True(range.Contains(1));
            Assert.True(range.Contains(2));
            Assert.True(range.Contains(3));

            range = new Range<int>(null, 3);
            Assert.True(range.Contains(int.MinValue));
            Assert.True(range.Contains(3));

            range = new Range<int>(1);
            Assert.True(range.Contains(1));
            Assert.True(range.Contains(int.MaxValue));
        }
开发者ID:jonathascosta,项目名称:SystemExtensions,代码行数:15,代码来源:RangeFixture.cs

示例8: Contains

        public void Contains(string range, double value, bool expected)
        {
            // Parse
            var minmax = range.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries)
                              .Select(s => s.Trim())
                              .ToArray();
            var minIsInclusive = minmax[0][0] == '[';
            var maxIsInclusive = minmax[1][minmax[1].Length - 1] == ']';
            var minStr = minmax[0].Substring(1);
            var maxStr = minmax[1].Substring(0, minmax[1].Length - 1);
            double? min = null, max = null;
            if (minStr != "-∞")
            {
                min = double.Parse(minStr, NumberStyles.Float, CultureInfo.InvariantCulture);
            }
            if (maxStr != "+∞")
            {
                max = double.Parse(maxStr, NumberStyles.Float, CultureInfo.InvariantCulture);
            }

            // Test
            var target = new Range(min, max) {MinIsInclusive = minIsInclusive, MaxIsInclusive = maxIsInclusive};
            var actual = target.Contains(value);
            Assert.AreEqual(expected, actual);
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:25,代码来源:RangeTests.cs

示例9: LogDetailsPageModel

        protected LogDetailsPageModel(BatNodeLog batLog)
        {
            EditLogCommand = new RelayCommand(() => _navigationService.EditLog(BatLog));

            BatLog = batLog;
            _batCalls = new List<BatCall>();

            FrequencyRange = new Range<uint>(0, 100);
            FrequencyRange.PropertyChanged += async (s, e) => await UpdateBins();

            IntensityRange = new Range<uint>(0, 1024);
            IntensityRange.PropertyChanged += async (s, e) => await UpdateBins();

            DurationRange = new Range<uint>(0, 100);
            DurationRange.PropertyChanged += async (s, e) => await UpdateBins();

            TimeRange = new Range<uint>(0, 100);
            TimeRange.PropertyChanged += async (s, e) => await UpdateBins();

			//BUG!
            Func<BatCall, bool> filter = c => IntensityRange.Contains(c.MaxPower) && FrequencyRange.Contains(c.MaxFrequency) && DurationRange.Contains(c.Duration / 1000) && TimeRange.Contains(c.StartTimeMs);
            FreqBins = new UintBinCollection(100, b => (uint)b.MaxFrequency, filter);
            IntensityBins = new UintBinCollection(200, b => (uint)b.MaxPower, filter);
            CallDurationBins = new UintBinCollection(100, b => b.Duration / 1000, filter);
            TimeBins = new TimeCallBinCollection(200, batLog.LogStart, filter);
        }
开发者ID:mjeanrichard,项目名称:TeensyBat,代码行数:26,代码来源:LogDetailsPageModel.cs

示例10: Contains_should_return_true

        public void Contains_should_return_true()
        {
            // Arrange
            var a = new Range<int>(1, 6);

            // Act
            var actual = a.Contains(4);

            // Assert
            actual.Should().BeTrue();
        }
开发者ID:HackedByChinese,项目名称:NStack,代码行数:11,代码来源:RangeTests.cs

示例11: Element_should_not_be_in_range_when_its_equal_to_upper_bound_and_its_not_inclusive

        public void Element_should_not_be_in_range_when_its_equal_to_upper_bound_and_its_not_inclusive()
        {
            var expectedLowerBound = 0;
            var expectedUpperBound = 1;
            var expectedElement = 1;

            var target = new Range<int>(expectedLowerBound, false, expectedUpperBound, false);
            var actual = target.Contains(expectedElement);

            Assert.That(actual, Is.False);
        }
开发者ID:marektihkan,项目名称:Arc,代码行数:11,代码来源:RangeTests.cs

示例12: Element_should_not_be_in_range_when_its_not_between_lower_and_upper_bound

        public void Element_should_not_be_in_range_when_its_not_between_lower_and_upper_bound()
        {
            var expectedLowerBound = 0;
            var expectedUpperBound = 1;
            var expectedElement = 2;

            var target = new Range<int>(expectedLowerBound, expectedUpperBound);
            var actual = target.Contains(expectedElement);

            Assert.That(actual, Is.False);
        }
开发者ID:marektihkan,项目名称:Arc,代码行数:11,代码来源:RangeTests.cs

示例13: RangeDoesContainItemUpperBounds

        public void RangeDoesContainItemUpperBounds()
        {
            var range1 = new Range<int>(3, 10);

            Assert.IsTrue(range1.Contains(10));
        }
开发者ID:dbaileychess,项目名称:CSMSL,代码行数:6,代码来源:RangeTestFixture.cs

示例14: contains_range

        public void contains_range() {
            var a = new Range(1, 5);
            var b = new Range(1, 3);
            var c = new Range(2, 5);
            var d = new Range(2, 4);
            var e = new Range(2, 6);
            var f = new Range(7, 9);

            Assert.True(a.Contains(a));
            Assert.True(a.Contains(b));
            Assert.False(b.Contains(a));
            Assert.True(a.Contains(c));
            Assert.False(c.Contains(a));
            Assert.True(a.Contains(d));
            Assert.False(d.Contains(a));
            Assert.False(a.Contains(e));
            Assert.False(e.Contains(a));
            Assert.False(a.Contains(f));
            Assert.False(f.Contains(a));
        }
开发者ID:aarondandy,项目名称:vertesaur,代码行数:20,代码来源:RangeFacts.cs

示例15: CheckFloatRange

        //--------------------------------------------------------------------
        private void CheckFloatRange(Range<float> range)
        {
            Assert.AreEqual(float.MinValue, range.Min);
            Assert.AreEqual(float.MaxValue, range.Max);

            Assert.AreEqual(range.MinIncluded, range.Contains(float.MinValue));
            Assert.AreEqual(range.MaxIncluded, range.Contains(float.MaxValue));
        }
开发者ID:LANDIS-II-Foundation,项目名称:Core-Utilities-Library,代码行数:9,代码来源:Range_Test.cs


注:本文中的Range.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。