本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4: PredictorData
public PredictorData(double distanceNominal, Length.Units unitNominal)
{
this.Distance = distanceNominal;
this.Unit = unitNominal;
result = new Dictionary<PredictionModel, TimePredictionResult>();
source = null;
}
示例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);
}
示例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);
}
示例7: PaperMargins
private PaperMargins(Length top, Length right, Length bottom, Length left)
{
_top = top;
_right = right;
_bottom = bottom;
_left = left;
}
示例8: CSSBorderSpacingProperty
internal CSSBorderSpacingProperty()
: base(PropertyNames.BorderSpacing)
{
_inherited = true;
_h = Length.Zero;
_v = Length.Zero;
}
示例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;
}
示例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);
}
示例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());
}
示例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;
}
}
示例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));
}
示例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;
}
示例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);
}