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


C# Length类代码示例

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


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

示例1: IsValid

        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            var length = value.ToLength();

            if (length.HasValue)
                _h = _v = length.Value;
            else if (value is CSSValueList)
            {
                var values = (CSSValueList)value;

                if (values.Length != 2)
                    return false;

                var h = values[0].ToLength();
                var v = values[1].ToLength();

                if (!h.HasValue || !v.HasValue)
                    return false;

                _h = h.Value;
                _v = v.Value;
            }
            else if (value != CSSValue.Inherit)
                return false;

            return true;
        }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:32,代码来源:CSSBorderSpacingProperty.cs

示例2: attr

        /// <summary>Assigns all needed attributes to the tag</summary>
        /// <returns>This instance downcasted to base class</returns>
        public virtual IndexedTag attr(
            Shape? shape = null,
            Length[] coords = null,
            string href = null,
            NoHref? nohref = null,
            Target target = null,
            string alt = null,
            string id = null,
            string @class = null,
            string style = null,
            string title = null,
            LangCode lang = null,
            string xmllang = null,
            Dir? dir = null,
            string onclick = null,
            string ondblclick = null,
            string onmousedown = null,
            string onmouseup = null,
            string onmouseover = null,
            string onmousemove = null,
            string onmouseout = null,
            string onkeypress = null,
            string onkeydown = null,
            string onkeyup = null,
            char? accesskey = null,
            int? tabindex = null,
            string onfocus = null,
            string onblur = null
        )
        {
            Shape = shape;
            Coords = coords;
            Href = href;
            NoHref = nohref;
            Target = target;
            Alt = alt;
            Id = id;
            Class = @class;
            Style = style;
            Title = title;
            Lang = lang;
            XmlLang = xmllang;
            Dir = dir;
            OnClick = onclick;
            OnDblClick = ondblclick;
            OnMouseDown = onmousedown;
            OnMouseUp = onmouseup;
            OnMouseOver = onmouseover;
            OnMouseMove = onmousemove;
            OnMouseOut = onmouseout;
            OnKeyPress = onkeypress;
            OnKeyDown = onkeydown;
            OnKeyUp = onkeyup;
            AccessKey = accesskey;
            TabIndex = tabindex;
            OnFocus = onfocus;
            OnBlur = onblur;

            return this;
        }
开发者ID:bzure,项目名称:BSA.Net,代码行数:62,代码来源:TagArea.cs

示例3: Shape

 /// <summary>
 /// Creates a new shape value.
 /// </summary>
 /// <param name="top">The top position.</param>
 /// <param name="right">The right position.</param>
 /// <param name="bottom">The bottom position.</param>
 /// <param name="left">The left position.</param>
 public Shape(Length top, Length right, Length bottom, Length left)
 {
     _top = top;
     _right = right;
     _bottom = bottom;
     _left = left;
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:14,代码来源:Shape.cs

示例4: PredictorData

 public PredictorData(double distanceNominal, Length.Units unitNominal)
 {
     this.Distance = distanceNominal;
     this.Unit = unitNominal;
     result = new Dictionary<PredictionModel, TimePredictionResult>();
     source = null;
 }
开发者ID:jcboliveira,项目名称:gps-running,代码行数:7,代码来源:PredictorData.cs

示例5: Calculate

        /// <summary>
        /// Calculation method.
        /// </summary>
        /// <param name="chain">
        /// Source sequence.
        /// </param>
        /// <param name="link">
        /// Redundant parameter, not used in calculations.
        /// </param>
        /// <returns>
        /// Frequency of element in congeneric chain as <see cref="double"/>.
        /// </returns>
        public double Calculate(CongenericChain chain, Link link)
        {
            var count = new ElementsCount();
            var length = new Length();

            return count.Calculate(chain, link) / length.Calculate(chain, link);
        }
开发者ID:intervals-mining-lab,项目名称:libiada-core,代码行数:19,代码来源:Probability.cs

示例6: ToStandardMeasures_DoubleNoUnitConversion_ReturningNonConvertedStandardMeasures

 public void ToStandardMeasures_DoubleNoUnitConversion_ReturningNonConvertedStandardMeasures()
 {
     var measures = new[] { 1.0, 2.0, 3.0, -2.0 }.Cast<Length>();
     var expected = new Length(3.0);
     var actual = measures.ElementAt(2);
     MeasureAssert.MeasuresAreEqual(expected, actual);
 }
开发者ID:bjaminn,项目名称:csunits,代码行数:7,代码来源:MeasureEnumerableTests.cs

示例7: PaperMargins

 private PaperMargins(Length top, Length right, Length bottom, Length left)
 {
     _top = top;
     _right = right;
     _bottom = bottom;
     _left = left;
 }
开发者ID:Bossmojoman,项目名称:OpenHtmlToPdf,代码行数:7,代码来源:PaperMargins.cs

示例8: CSSBorderSpacingProperty

 internal CSSBorderSpacingProperty()
     : base(PropertyNames.BorderSpacing)
 {
     _inherited = true;
     _h = Length.Zero;
     _v = Length.Zero;
 }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:7,代码来源:CSSBorderSpacingProperty.cs

示例9: attr

        /// <summary>Assigns all needed attributes to the tag</summary>
        /// <returns>This instance downcasted to base class</returns>
        public virtual IndexedTag attr(
            string id = null,
            string @class = null,
            string style = null,
            string title = null,
            string longdesc = null,
            string name = null,
            string src = null,
            bool? frameborder = null,
            int? marginwidth = null,
            int? marginheight = null,
            Scrolling? scrolling = null,
            Length height = null,
            Length width = null  
        )
        {
            Id = id;
            Class = @class;
            Style = style;
            Title = title;
            LongDesc = longdesc;
            Name = name;
            Src = src;
            FrameBorder = frameborder;
            MarginWidth = marginwidth;
            MarginHeight = marginheight;
            Scrolling = scrolling;
            Height = height;
            Width = width;    

            return this;
        }
开发者ID:bzure,项目名称:BSA.Net,代码行数:34,代码来源:TagIFrame.cs

示例10: VerifyAllEnums

 public void VerifyAllEnums()
 {
     var acceleration = new Acceleration(1, AccelerationUnit.BaseUnit);
     var angle = new Angle(1, AngleUnit.BaseUnit);
     var angularAcceleration = new AngularAcceleration(1, AngularAccelerationUnit.BaseUnit);
     var area = new Area(1, AreaUnit.BaseUnit);
     var density = new MassDensity(1, MassDensityUnit.BaseUnit);
     var electricCurrent = new ElectricCurrent(1, ElectricCurrentUnit.BaseUnit);
     var electricResistance = new ElectricResistance(1, ElectricResistanceUnit.BaseUnit);
     var electricVoltage = new ElectricPotential(1, ElectricPotentialUnit.BaseUnit);
     var energy = new Energy(1, EnergyUnit.BaseUnit);
     var force = new Force(1, ForceUnit.BaseUnit);
     var frequency = new Frequency(1, FrequencyUnit.BaseUnit);
     var jerk = new Jerk(1, JerkUnit.BaseUnit);
     var length = new Length(1, LengthUnit.BaseUnit);
     var mass = new Mass(1, MassUnit.BaseUnit);
     var massFlowRate = new MassFlowRate(1, MassFlowRateUnit.BaseUnit);
     var momentum = new Momentum(1, MomentumUnit.BaseUnit);
     var numeric = new Numeric(1, NumericUnit.BaseUnit);
     var power = new Power(1, PowerUnit.BaseUnit);
     var pressure = new Pressure(1, PressureUnit.BaseUnit);
     var speed = new Speed(1, SpeedUnit.BaseUnit);
     var temperature = new Temperature(1, TemperatureUnit.BaseUnit);
     var time = new Time(1, TimeUnit.BaseUnit);
     var torque = new Torque(1, TorqueUnit.BaseUnit);
     var volume = new Volume(1, VolumeUnit.BaseUnit);
     var volumetricFlowRate = new VolumetricFlowRate(1, VolumetricFlowRateUnit.BaseUnit);
 }
开发者ID:EddieGarmon,项目名称:GraduatedCylinder,代码行数:28,代码来源:EnumerationVerification.cs

示例11: hashCode

        public void hashCode()
        {
            Length l = new Length(10.1234, LengthType.mm);
            double d = 10.1234;
            for (int i = 0; i < 100; i++)
            {
                d = d / 7;
            }

            for (int i = 0; i < 100; i++)
            {
                d = d * 7;
            }
            Length l2 = new Length(d, LengthType.mm);

            Console.WriteLine(l.Value.ToString("n15") + " : " + l2.Value.ToString("n15"));

            Console.WriteLine(l.GetHashCode());

            Assert.IsTrue(l.Value - l2.Value > 0);
            Console.WriteLine(l.Value - l2.Value );
            Assert.IsTrue(l.Value != l2.Value);
            Assert.IsTrue(l == l2);
            Assert.IsTrue(l.GetHashCode() == l2.GetHashCode());
        }
开发者ID:hkiaipc,项目名称:C3,代码行数:25,代码来源:LengthTest.cs

示例12: Start

    private GameObject[] myBlocks; //arry to hold rferences to the blocks

    #endregion Fields

    #region Methods

    // Use this for initialization
    void Start()
    {
        //first initialize the bars array so you can insantiate prefabs
        Bars = new GameObject[3]{
            Resources.Load<GameObject>("Full_Block"),
            Resources.Load<GameObject>("Half_Block"),
            Resources.Load<GameObject>("Quarter_Block")
        };

        //if the height/width wasn't set, at least set it to 1 so you have something
        if(height == 0){height = 1;}
        if(width == 0){width = 1;}

        //if the block Lengths weren't selected then, at least make them quaters to see
        if(wBlock == Length.None){wBlock = Length.Quarter;}
        if(hBlock == Length.None){wBlock = Length.Quarter;}

        myBlocks = new GameObject[(2*(width+height))];

        switch(wBlock){
        case Length.Full:
            for(int i = 0; i<width; i++){

            }break;
        case Length.Half:
            for(int i = 0; i<width; i++){

            }break;
        case Length.Quarter:
            for(int i = 0; i<width; i++){

            }break;
        }
    }
开发者ID:vmichial,项目名称:PacRift,代码行数:41,代码来源:Frame.cs

示例13: doit

        public static void doit()
        {
            new LengthTest().hashCode();

            Length l = new Length(10.1234, LengthType.mm);
            double d = 10.1234;
            for (int i = 0; i < 100; i++)
            {
                d = d / 7;
            }

            for (int i = 0; i < 100; i++)
            {
                d = d * 7;
            }
            Length l2 = new Length(d, LengthType.cm);
            Console.WriteLine(l);
            Console.WriteLine(new Length());

            Console.WriteLine(l.ToCM());
            Console.WriteLine(l.ToKM());
            Console.WriteLine(l.ToM());

            Console.WriteLine(new Length(1, LengthType.km).ToCM());
            //Console.WriteLine(l2.ToString("n0"));

            Console.WriteLine(l2.Value);
            Console.WriteLine(l.GetHashCode() + " " + l2.GetHashCode());
            Console.WriteLine(l.Equals(l2));
        }
开发者ID:hkiaipc,项目名称:C3,代码行数:30,代码来源:LengthTest.cs

示例14: Datum

 public Datum(DateTime time, Latitude latitude, Longitude longitude, Length altitude = null, Speed speed = null, Heading heading = null)
 {
     _time = time;
     _location = new GeoPosition(latitude, longitude, altitude);
     _speed = speed;
     _heading = heading;
 }
开发者ID:EddieGarmon,项目名称:GraduatedCylinder,代码行数:7,代码来源:GeoTrail.cs

示例15: OpAddition

 public void OpAddition()
 {
     var length1 = new Length(5000, LengthUnit.Meter);
     var length2 = new Length(2, LengthUnit.Kilometer);
     var expected = new Length(7000, LengthUnit.Meter);
     (length1 + length2).ShouldEqual(expected);
     (length2 + length1).ShouldEqual(expected);
 }
开发者ID:EddieGarmon,项目名称:GraduatedCylinder,代码行数:8,代码来源:LengthOperators.cs


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