• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Range类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: CellTopLeftPixels

        private static double pppx = -1, pppy = -1; //points per pixel per axis

        #endregion Fields

        #region Methods

        public static void CellTopLeftPixels(Range rng)
        {
            if (!init)
            {
                PixelsPerPointX();
                PixelsPerPointY();
                GetFormulaBarAndHeadingsDim();
                init = true;
            }

            //get all the pieces together

            double appTop = Globals.ThisAddIn.Application.Top;
            double appLeft = Globals.ThisAddIn.Application.Left;
            long RibbonHeight = Globals.ThisAddIn.Application.CommandBars["Ribbon"].Height;

            //the upper-left corner position

            top = (long)((appTop + RibbonHeight + rng.Top + fbTop + hTop - 15) * pppy);
            left = (long)((appLeft + rng.Left + fbLeft + hLeft + rng.Width + 25) * pppx);

            //the lower-right corner position
            long topc = (long)((appTop + RibbonHeight + rng.Top + fbTop + hTop + rng.Height) * pppy);
            long leftc = (long)((appLeft + rng.Left + rng.Width + fbLeft + hTop) * pppx);
        }
开发者ID:risavkarna,项目名称:Sally,代码行数:31,代码来源:Display.cs


示例17: GetRange

 /// <summary>
 /// Get range of text
 /// </summary>
 /// <param name="textbox"></param>
 /// <param name="fromPos">Absolute start position</param>
 /// <param name="toPos">Absolute finish position</param>
 /// <returns>Range</returns>
 public static Range GetRange(FastColoredTextBox textbox, int fromPos, int toPos)
 {
     var sel = new Range(textbox);
     sel.Start = TextSourceUtil.PositionToPlace(textbox.lines, fromPos);
     sel.End = TextSourceUtil.PositionToPlace(textbox.lines, toPos);
     return sel;
 }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:14,代码来源:RangeUtil.cs


示例18: getBorder

        /*
         * Returns the cell Border of a cell
         */
        public static CellBorder getBorder(Range cell)
        {
            sally.BorderLine top, right, bottom, left;
            CellBorder ret = null;
            int weight, style;
            Microsoft.Office.Interop.Excel.Border aux;
            try
            {
                Microsoft.Office.Interop.Excel.Borders borders= cell.Borders;
                aux = borders[XlBordersIndex.xlEdgeTop];
                lineStyle(aux,out weight, out style);
                top = sally.BorderLine.CreateBuilder().SetBorderColor((int)aux.Color).SetFormatStyle(0).SetExcelBorderStyle(style).SetExcelBorderWeight(weight).Build();

                aux = borders[XlBordersIndex.xlEdgeRight];
                lineStyle(aux, out weight, out style);
                right = sally.BorderLine.CreateBuilder().SetBorderColor((int)aux.Color).SetFormatStyle(0).SetExcelBorderStyle(style).SetExcelBorderWeight(weight).Build();

                aux = borders[XlBordersIndex.xlEdgeLeft];
                lineStyle(aux, out weight, out style);
                left = sally.BorderLine.CreateBuilder().SetBorderColor((int)aux.Color).SetFormatStyle(0).SetExcelBorderStyle(style).SetExcelBorderWeight(weight).Build();

                aux = borders[XlBordersIndex.xlEdgeBottom];
                lineStyle(aux, out weight, out style);
                bottom = sally.BorderLine.CreateBuilder().SetBorderColor((int)aux.Color).SetFormatStyle(0).SetExcelBorderStyle(style).SetExcelBorderWeight(weight).Build();

                ret = CellBorder.CreateBuilder().SetBottom(bottom).SetLeft(left).SetRight(right).SetTop(top).Build();
            }
            catch (Exception ex) { }
            return ret;
        }
开发者ID:risavkarna,项目名称:Sally,代码行数:33,代码来源:Analyze.cs


示例19: WriteCarInfo

        public void WriteCarInfo(List<CarBrand> carBrandList)
        {
            int index = 1;
            foreach (CarBrand carBrand in carBrandList)
            {
                foreach (CarFactory carFactory in carBrand.CarFactoryList)
                {
                    foreach (CarType carType in carFactory.CarTypeList)
                    {
                        ++index;
                        
                        mWorksheet.Cells[index, 1] = carBrand.Alpha.ToString();
                        mWorksheet.Cells[index, 2] = carBrand.Name;
                        mWorksheet.Cells[index, 3] = carBrand.OfficialSite;
                        mWorksheet.Cells[index, 4] = carBrand.Country.Name;
                        mWorksheet.Cells[index, 5] = carFactory.Name;
                        mWorksheet.Cells[index, 6] = carFactory.OfficialSite;
                        mWorksheet.Cells[index, 7] = carType.Name;
                        mWorksheet.Cells[index, 8] = carType.PriceMin;
                        mWorksheet.Cells[index, 9] = carType.PriceMax;

                        for (int i = 1; i <= ExcelConstants.SHEET_HEADERS.Length; ++i)
                        {
                            mRange = mWorksheet.Cells[index, i];
                            mRange.EntireColumn.AutoFit();
                        }
                    }
                }
            }

            saveExcelFile();
        }
开发者ID:SevanJoe,项目名称:CarImageDownloader,代码行数:32,代码来源:ExcelTask.cs


示例20: Parse

        /// <summary>
        /// Parses a range from the given query.
        /// </summary>
        /// <param name="query">Query.</param>
        /// <returns>Range.</returns>
        public Range<int> Parse(Query query)
        {
            Range<int> ret = null;

            Skip = -1;
            Take = -1;

            Visit(query);

            if (Skip > 0 || Take > 0)
            {
                ret = new Range<int>();

                if (Skip <= 0 && Take > 0)
                    ret.To = Take;
                else if (Skip > 0 && Take <= 0)
                    ret.From = Skip;
                else
                {
                    ret.From = Skip + 1;
                    ret.To = System.Math.Abs(Skip + Take);
                }
            }
            else
                ret = new Range<int>(-1, -1);

            return ret;
        }
开发者ID:volpav,项目名称:toprope,代码行数:33,代码来源:RangeParser.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RangeBoundaryType类代码示例发布时间:2022-05-24
下一篇:
C# Randomizer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap