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


C# Range类代码示例

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


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

示例1: TryGetRequestedRange

        private bool TryGetRequestedRange( HttpRequestBase request, out Range range )
        {
            var rangeHeader = request.Headers[ "Range" ];
            if ( string.IsNullOrEmpty( rangeHeader ) )
            {
                range = null;
                return false;
            }

            if ( !rangeHeader.StartsWith( RangeByteHeaderStart ) )
            {
                range = null;
                return false;
            }

            var parts = rangeHeader.Substring( RangeByteHeaderStart.Length ).Split( '-' );

            if ( parts.Length != 2 )
            {
                range = null;
                return false;
            }

            range = new Range
            {
                Start = string.IsNullOrEmpty( parts[ 0 ] ) ? (long?) null : long.Parse( parts[ 0 ] ),
                End = string.IsNullOrEmpty( parts[ 1 ] ) ? (long?) null : long.Parse( parts[ 1 ] )
            };
            return true;
        }
开发者ID:bmbsqd,项目名称:dynamic-media,代码行数:30,代码来源:BytesRangeResultHandler.cs

示例2: IsOverlappingTest

        public void IsOverlappingTest( float min1, float max1, float min2, float max2, bool expectedResult )
        {
            Range range1 = new Range( min1, max1 );
            Range range2 = new Range( min2, max2 );

            Assert.AreEqual( expectedResult, range1.IsOverlapping( range2 ) );
        }
开发者ID:hungdluit,项目名称:aforge,代码行数:7,代码来源:RangeTest.cs

示例3: MakePage

        void MakePage(Document doc, Range range)
        {
            var table = doc.Tables.Add(range, (int)m_numberOfRows, 2);

            table.Rows.SetHeight(136.1F, WdRowHeightRule.wdRowHeightExactly);
            table.Columns.SetWidth(295.65F, WdRulerStyle.wdAdjustNone); // 297.65F

            table.LeftPadding = 0.75F;
            table.RightPadding = 0.75F;
            table.TopPadding = 5F;

            for (int row = 1; row <= m_numberOfRows; ++row)
                for (int col = 1; col <= 2; ++col)
                {
                    string code = m_tr.ReadLine();

                    if (code == null) return;

                    Console.WriteLine("Row:{0}, Col:{1}", row, col);
                    var cell = table.Cell(row, col);

                    cell.Range.Delete();
                    cell.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter;

                    PopCell(cell.Range, "Horsell Jubilation Balloon Race", isBold:true, fontSize:12, first:true);
                    PopCell(cell.Range, "", fontSize:12);
                    PopCell(cell.Range, "Notice to the finder of this balloon:", isBold:true);
                    PopCell(cell.Range, "Please go to the website www.diamondballoons.info to register your details and the location of the balloon. By doing so you will be entered into a draw for a £25 Amazon Gift Voucher. Good luck and thank you!");
                    PopCell(cell.Range, code, false, 12, centre: true);
                    PopCell(cell.Range, "", fontSize: 12);

                    ++m_count;
                }
        }
开发者ID:petebarber,项目名称:Balloon,代码行数:34,代码来源:Program.cs

示例4: EqualsShouldFailIfObjectIsNotRange

        public void EqualsShouldFailIfObjectIsNotRange()
        {
            var a = new Range<int>(1, 3);
            const int b = 1;

            Assert.False(a.Equals(b));
        }
开发者ID:jonathascosta,项目名称:SystemExtensions,代码行数:7,代码来源:RangeFixture.cs

示例5: ConstraintsExpectation

 /// <summary>
 /// Creates a new <see cref="ConstraintsExpectation"/> instance.
 /// </summary>
 /// <param name="invocation">Invocation for this expectation</param>
 /// <param name="constraints">Constraints.</param>
 /// <param name="expectedRange">Number of method calls for this expectations</param>
 public ConstraintsExpectation(IInvocation invocation,AbstractConstraint[] constraints, Range expectedRange)
     : base(invocation, expectedRange)
 {
     Validate.IsNotNull(()=>constraints);
     this.constraints = constraints;
     ConstraintsMatchMethod();
 }
开发者ID:sneal,项目名称:rhino-mocks,代码行数:13,代码来源:ConstraintsExpectation.cs

示例6: SentimentIndex

        public SentimentIndex()
            : base("Sentiment Index")
        {
            numberOfTrainingItems = Variable.New<int>();
            var rangeOfTrainingItems = new Range(numberOfTrainingItems);
            trainingInputs = Variable.Array<Vector>(rangeOfTrainingItems);
            trainingOutputs = Variable.Array<bool>(rangeOfTrainingItems);

            weights = Variable.Random(new VectorGaussian(Vector.Zero(numberOfFeatures), PositiveDefiniteMatrix.Identity(numberOfFeatures)));

            using (Variable.ForEach(rangeOfTrainingItems))
            {
                trainingOutputs[rangeOfTrainingItems] = Variable.IsPositive(Variable.GaussianFromMeanAndVariance(Variable.InnerProduct(weights, trainingInputs[rangeOfTrainingItems]), noise));
            }

            trainingEngine = new InferenceEngine();
            trainingEngine.ShowProgress = false;

            numberOfTestingItems = Variable.New<int>();
            var rangeOfTestingItems = new Range(numberOfTestingItems);
            testingInputs = Variable.Array<Vector>(rangeOfTestingItems);
            testingOutputs = Variable.Array<bool>(rangeOfTestingItems);

            weightsPosteriorDistribution = Variable.New<VectorGaussian>();
            var testWeights = Variable<Vector>.Random(weightsPosteriorDistribution);

            using (Variable.ForEach(rangeOfTestingItems))
            {
                testingOutputs[rangeOfTestingItems] = Variable.IsPositive(Variable.GaussianFromMeanAndVariance(Variable.InnerProduct(testWeights, testingInputs[rangeOfTestingItems]), noise));
            }

            testingEngine = new InferenceEngine();
            testingEngine.ShowProgress = false;
        }
开发者ID:adamgoral,项目名称:infernethol,代码行数:34,代码来源:SentimentIndex.cs

示例7: GetHtml

 public string GetHtml(FastColoredTextBox tb)
 {
     this.tb = tb;
     Range sel = new Range(tb);
     sel.SelectAll();
     return GetHtml(sel);
 }
开发者ID:Celtech,项目名称:BolDevStudio,代码行数:7,代码来源:ExportToHTML.cs

示例8: Overlaps_should_return_correct_value

        public void Overlaps_should_return_correct_value(int a1, int a2, int b1, int b2, bool expected)
        {
            var subject = new Range<int>(a1, a2);
            var comparand = new Range<int>(b1, b2);

            subject.Overlaps(comparand).Should().Be(expected);
        }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:7,代码来源:RangeTests.cs

示例9: GetEventInfos

        protected override IEnumerable<IEventInfo> GetEventInfos(TimeLineVisualizationState state, HierarchicalItem hierarchicalWrapper)
        {
            if (!(hierarchicalWrapper.SourceItem is CustomRecurrenceTask))
            {
                foreach (var info in base.GetEventInfos(state, hierarchicalWrapper))
                {
                    yield return info;
                }
            }

            var dateRange = hierarchicalWrapper.SourceItem as IDateRange;
            var roundedRange = state.Rounder.Round(dateRange);
            var taskRange = new Range<long>(roundedRange.Start.Ticks, roundedRange.End.Ticks);
            var task = hierarchicalWrapper.SourceItem as CustomRecurrenceTask;
            Range<long> range = null;

            if (task != null && task.RecurrenceRule != null)
            {
                for (int i = 0; i < task.RecurrenceRule.OcurrenceCount; i++)
                {
                    var recurrence = state.Rounder.Round(this.GetRecurrence(task, i));
                    range = new Range<long>(recurrence.Start.Ticks, recurrence.End.Ticks);

                    yield return new TimeLineRecurrenceEventInfo(range, hierarchicalWrapper.Index)
                    {
                        OriginalEvent = recurrence
                    };
                }
            }
        }
开发者ID:jigjosh,项目名称:xaml-sdk,代码行数:30,代码来源:TimeLineRecurrenceBehavior.cs

示例10: UnitFormat

 public UnitFormat(double unit, string name, Range potRange, bool factored, bool decimalExtend, double weight)
     : base(factored, decimalExtend, weight)
 {
     _unit = unit;
     _name = name;
     _potRange = potRange;
 }
开发者ID:AuditoryBiophysicsLab,项目名称:ESME-Workbench,代码行数:7,代码来源:Format.cs

示例11: StorePurchaseDialog

        public StorePurchaseDialog(Scene.ObjectRegistrationHandler registrationHandler, Scene.ObjectUnregistrationHandler unregistrationHandler)
            : base(registrationHandler, unregistrationHandler)
        {
            Height = Purchase_Dialog_Height;
            TopYWhenActive = Definitions.Back_Buffer_Height - (Purchase_Dialog_Height + Bopscotch.Scenes.NonGame.StoreScene.Dialog_Margin);
            CarouselCenter = new Vector2(Definitions.Back_Buffer_Center.X, Carousel_Center_Y);
            CarouselRadii = new Vector2(Carousel_Horizontal_Radius, Carousel_Vertical_Radius);
            _itemRenderDepths = new Range(Minimum_Item_Render_Depth, Maximum_Item_Render_Depth);
            _itemScales = new Range(Minimum_Item_Scale, Maximum_Item_Scale);

            AddIconButton("previous", new Vector2(Definitions.Back_Buffer_Center.X - 450, 175), Button.ButtonIcon.Previous, Color.DodgerBlue);
            AddIconButton("next", new Vector2(Definitions.Back_Buffer_Center.X + 450, 175), Button.ButtonIcon.Next, Color.DodgerBlue);

            AddButton("Back", new Vector2(Definitions.Left_Button_Column_X, 400), Button.ButtonIcon.Back, Color.DodgerBlue, 0.7f);
            AddButton("Buy", new Vector2(Definitions.Right_Button_Column_X, 400), Button.ButtonIcon.Tick, Color.Orange, 0.7f);

            _nonSpinButtonCaptions.Add("Buy");

            ActionButtonPressHandler = HandleActionButtonPress;
            TopYWhenInactive = Definitions.Back_Buffer_Height;

            SetupButtonLinkagesAndDefaultValues();

            registrationHandler(this);

            _textTransitionTimer = new Timer("");
            GlobalTimerController.GlobalTimer.RegisterUpdateCallback(_textTransitionTimer.Tick);
            _textTransitionTimer.NextActionDuration = 1;
            _textTint = Color.White;

            _font = Game1.Instance.Content.Load<SpriteFont>("Fonts\\arial");
        }
开发者ID:Ben-P-Leda,项目名称:Bopscotch-IOS,代码行数:32,代码来源:StorePurchaseDialog.cs

示例12: Join

		private void Join(Range range1, Range range2)
		{
			Range result = Range.GetBounds(range1, range2);
			m_ranges.Remove(range1);
			m_ranges.Remove(range2);
			m_ranges.Add(result);
		}
开发者ID:wsrf2009,项目名称:KnxUiEditor,代码行数:7,代码来源:FreeSelection.cs

示例13: CalculateResult

        public override object CalculateResult()
        {
            var digitRepresentations = new Range(0, 9, true)
                .Select(n => PrimeGenerator.Instance.GetPrimeAtIndex(n))
                .ToArray();

            return new Range(1, int.MaxValue)
                .Select(numDigits =>
                {
                    long num = MathUtilities.Pow(10L, numDigits - 1);
                    long maximum = num * 10;

                    return new Range((int)Math.Pow(num, 1.0 / 3.0), int.MaxValue)
                        .Select(n => (long)n)
                        .Select(n => n * n * n)
                        .SkipWhile(n => n < num)
                        .TakeWhile(n => n < maximum)
                        .GroupBy(n => MathUtilities.ToDigits(n)
                            .Select(d => digitRepresentations[d])
                            .Product())
                        .Where(g => g.Count() == 5)
                        .SelectMany(x => x)
                        .Select(x => (long?)x)
                        .DefaultIfEmpty()
                        .Min();
                })
                .WhereNotNull()
                .First();
        }
开发者ID:ckknight,项目名称:ProjectEuler,代码行数:29,代码来源:Problem062.cs

示例14: QuotesRangeSingleIterator

		/// <summary>
		/// Creates a new iterator instance.
		/// </summary>
		/// <param name="sequence">An existing sequence instance.</param>
		/// <exception cref="System.ArgumentNullException">if sequence is null.</exception>
		public QuotesRangeSingleIterator(QuotesRangeSingleSequence sequence)
		{
			if (sequence == null)
    			throw new ArgumentNullException(nameof(sequence), "Sequence parameter can not be null.");

			this.Sequence = sequence;

            this.iterator = new QuotesSingleIterator(sequence.Storage, sequence.Symbol, sequence.StartTime, sequence.EndTime, sequence.Depth);
            var range = new Range<Quote>(sequence.LowerBound, sequence.UpperBound);

            var index = sequence.LowerBound;

            for (; (index < sequence.UpperBound) && this.iterator.Continue; ++index)
            {
                range[index] = this.iterator.Current;
                this.iterator.NextTick();
            }

            if (index == sequence.UpperBound)
            {
                this.Current = range;
                this.Continue = true;
            }
            else
            {
                this.Continue = false;
            }
		}
开发者ID:ifzz,项目名称:FDK,代码行数:33,代码来源:QuotesRangeSingleIterator.cs

示例15: ComponentSetSelectionCarouselDialog

        public ComponentSetSelectionCarouselDialog(Scene.ObjectRegistrationHandler registrationHandler, Scene.ObjectUnregistrationHandler unregistrationHandler)
            : base(registrationHandler, unregistrationHandler)
        {
            _selectableComponentSets = new List<AvatarComponentSet>();

            Height = Dialog_Height;
            TopYWhenActive = Definitions.Back_Buffer_Height - Dialog_Height;
            CarouselCenter = new Vector2(Definitions.Back_Buffer_Center.X, Carousel_Center_Y);
            CarouselRadii = new Vector2(Carousel_Horizontal_Radius, Carousel_Vertical_Radius);
            _itemRenderDepths = new Range(Minimum_Item_Render_Depth, Maximum_Item_Render_Depth);
            _itemScales = new Range(Minimum_Item_Scale, Maximum_Item_Scale);

            AddIconButton("previous", new Vector2(Definitions.Back_Buffer_Center.X - 450, 175), Button.ButtonIcon.Previous, Color.DodgerBlue);
            AddIconButton("next", new Vector2(Definitions.Back_Buffer_Center.X + 450, 175), Button.ButtonIcon.Next, Color.DodgerBlue);

            AddButton("Back", new Vector2(Definitions.Left_Button_Column_X, 325), Button.ButtonIcon.Back, Color.Red, 0.7f);
            AddButton("Change", new Vector2(Definitions.Right_Button_Column_X, 325), Button.ButtonIcon.Options, Color.LawnGreen, 0.7f);

            ActionButtonPressHandler = HandleActionButtonPress;
            TopYWhenInactive = Definitions.Back_Buffer_Height;

            SetupButtonLinkagesAndDefaultValues();

            registrationHandler(this);
        }
开发者ID:Ben-P-Leda,项目名称:Bopscotch-Android,代码行数:25,代码来源:ComponentSetSelectionCarouselDialog.cs


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