/// <summary> /// Gets an attribute representing the 4 unit sides. /// If a side has been specified individually, it will override the grouped definition. /// </summary> /// <returns>If the attribute is misformed, the <see cref="Margin.IsValid"/> property is set to false.</returns> public Margin GetAsMargin(String name) { Margin margin = Margin.Parse(this[name]); Unit u; u = GetAsUnit(name + "-top"); if (u.IsValid) { margin.Top = u; } u = GetAsUnit(name + "-right"); if (u.IsValid) { margin.Right = u; } u = GetAsUnit(name + "-bottom"); if (u.IsValid) { margin.Bottom = u; } u = GetAsUnit(name + "-left"); if (u.IsValid) { margin.Left = u; } return(margin); }
public override void Parse(XmlDocument doc) { base.Parse(doc); systemid = doc.ReadString("c2xml/systemid"); systemname = doc.ReadString("c2xml/systemname"); statustimestamp = doc.ReadString("c2xml/status/timestamp"); Margin.Parse(doc.SelectSingleNode("c2xml/status/margin")); }
public void Parse(string html, int top, int right, int bottom, int left) { var margin = Margin.Parse(html); Assert.True(margin.IsValid); Assert.Equal(margin.Top.ValueInPx, top); Assert.Equal(margin.Right.ValueInPx, right); Assert.Equal(margin.Bottom.ValueInPx, bottom); Assert.Equal(margin.Left.ValueInPx, left); }
public void Parse(string html, int top, int right, int bottom, int left) { var margin = Margin.Parse(html); Assert.Multiple(() => { Assert.That(margin.IsValid, Is.EqualTo(true)); Assert.That(margin.Top.ValueInPx, Is.EqualTo(top)); Assert.That(margin.Right.ValueInPx, Is.EqualTo(right)); Assert.That(margin.Bottom.ValueInPx, Is.EqualTo(bottom)); Assert.That(margin.Left.ValueInPx, Is.EqualTo(left)); }); }
public override void Parse(XmlDocument doc) { base.Parse(doc); systemid = doc.ReadString("c2xml/system/systemid"); systemname = doc.ReadString("c2xml/system/systemname"); startedwhen = doc.ReadString("c2xml/system/startedwhen"); creator_c2userid = doc.ReadString("c2xml/system/creator/c2userid"); creator_name = doc.ReadString("c2xml/system/creator/name"); creator_org = doc.ReadString("c2xml/system/creator/org"); descrip_short = doc.ReadString("c2xml/system/descrip/short"); descrip_long = doc.ReadString("c2xml/system/descrip/long"); BusinessModel.Parse(doc.SelectSingleNode("c2xml/system/businessmodel")); TradeStyle.Parse(doc.SelectSingleNode("c2xml/system/tradestyle")); SummaryStats.Parse(doc.SelectSingleNode("c2xml/system/summarystats")); Margin.Parse(doc.SelectSingleNode("c2xml/system/margin")); }
public void ParseFloat() { var margin = Margin.Parse("0 50% 1em .00001pt"); Assert.True(margin.IsValid); Assert.Equal(0, margin.Top.Value); Assert.Equal(UnitMetric.Pixel, margin.Top.Type); Assert.Equal(50, margin.Right.Value); Assert.Equal(UnitMetric.Percent, margin.Right.Type); Assert.Equal(1, margin.Bottom.Value); Assert.Equal(UnitMetric.EM, margin.Bottom.Type); Assert.Equal(.00001, margin.Left.Value); Assert.Equal(UnitMetric.Point, margin.Left.Type); // but due to conversion: 0 (OpenXml relies mostly on long value, not on float) Assert.Equal(0, margin.Left.ValueInPoint); }
public override void Parse(XmlDocument doc) { base.Parse(doc); systemid = doc.ReadString("c2xml/systemid"); systemname = doc.ReadString("c2xml/systemname"); statustimestamp = doc.ReadString("c2xml/status/timestamp"); Margin.Parse(doc.SelectSingleNode("c2xml/status/margin")); List <Trade> positions = new List <Trade>(); foreach (XmlNode item in doc.SelectNodes("c2xml/status/openPositions/trade")) { Trade position = new Trade(); position.Parse(item); positions.Add(position); } positions.Sort(); this.OpenPositions = positions.ToArray(); List <Signal> signals = new List <Signal>(); foreach (XmlNode item in doc.SelectNodes("c2xml/status/signalsTradedInOpenPositions/signal")) { Signal signal = new Signal(); signal.Parse(item); signals.Add(signal); } signals.Sort(); this.SignalsTradedInOpenPositions = signals.ToArray(); }
public void ParseFloat() { var margin = Margin.Parse("0 50% 1em .00001pt"); Assert.Multiple(() => { Assert.That(margin.IsValid, Is.EqualTo(true)); Assert.That(margin.Top.Value, Is.EqualTo(0)); Assert.That(margin.Top.Type, Is.EqualTo(UnitMetric.Pixel)); Assert.That(margin.Right.Value, Is.EqualTo(50)); Assert.That(margin.Right.Type, Is.EqualTo(UnitMetric.Percent)); Assert.That(margin.Bottom.Value, Is.EqualTo(1)); Assert.That(margin.Bottom.Type, Is.EqualTo(UnitMetric.EM)); Assert.That(margin.Left.Value, Is.EqualTo(.00001)); Assert.That(margin.Left.Type, Is.EqualTo(UnitMetric.Point)); // but due to conversion: 0 (OpenXml relies mostly on long value, not on float) Assert.That(margin.Left.ValueInPoint, Is.EqualTo(0)); }); }