public void CalculateTest(double first, double expected) { var calculator = new Absolute(); var actualResult = calculator.Calculate(first); Assert.AreEqual(expected, actualResult); }
public void Calculate(double argument, double result) { var calculator = new Absolute(); var testResult = calculator.Calculate(argument); Assert.AreEqual(result, testResult); }
public override bool Equals(object other) { if (other == null) { return(false); } else if (other is ScreenPoint) { return(Equals((ScreenPoint)other)); } else if (other is Vector2) { return(Relative.Equals((Vector2)other)); } else if (other is Point) { return(Absolute.Equals((Point)other)); } else if ((other = other as string) != null) { return(ToString().Equals(other)); } else { return(false); } }
/// <summary> /// Check if all cells references have the same row/col absolute type or if it's mixed /// </summary> private static Absolute checkAbsolute(ParseTreeNode reference) { var cells = ExcelFormulaParser.AllNodes(reference).Where(x => x.Is(GrammarNames.Cell)); bool first = true; var a = new Absolute(); var locs = cells.Select(cell => new Location(cell.Print())); foreach (var l in locs) { if (first) { a.colAbsolute = l.ColumnFixed; a.rowAbsolute = l.RowFixed; a.mixed = false; first = false; } else { if (a.colAbsolute != l.ColumnFixed || a.rowAbsolute != l.RowFixed) { a.mixed = true; } } } return(a); }
public override int GetHashCode() { unchecked { var hashCode = Absolute.GetHashCode(); hashCode = (hashCode * 397) ^ (Relation?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Uri?.GetHashCode() ?? 0); return(hashCode); } }
public override View Build() { var result = new Absolute(); result.AddView(this.Title, (available) => SKRect.Create(10, 10, available.Width - 20, 40)); result.AddView(this.Description, (available) => SKRect.Create(10, 50, available.Width - 20, 50)); result.AddView(this.Image, (available) => SKRect.Create(10, 100, available.Width - 20, 100)); result.AddView(this.Icon, (available) => SKRect.Create(10, 210, 50, 50)); return(result); }
/// <summary> /// Sets the data root. /// </summary> /// <param name="value">The value.</param> /// <param name="transformRelative">if set to <c>true</c> [transform relative].</param> public virtual void SetDataRoot(string value, bool transformRelative) { if (value == null) { throw new ArgumentNullException("value"); } if (System.IO.Path.IsPathRooted(value) == false) { throw new ArgumentException("DataRoot must be an absolute path."); } value = value.Replace(System.IO.Path.AltDirectorySeparatorChar, System.IO.Path.DirectorySeparatorChar); if (value[value.Length - 1] != System.IO.Path.DirectorySeparatorChar) { value += System.IO.Path.DirectorySeparatorChar; } if (m_dataRoot != null) { string oldRoot = m_dataRoot; m_dataRoot = value; if (string.IsNullOrEmpty(Relative) == false) { if (transformRelative == true) { //transform relative path TransformRelative(m_dataRoot, oldRoot); } else { //set absolute to the new location Absolute = System.IO.Path.GetFullPath(System.IO.Path.Combine(m_dataRoot, Relative)); } } } else { m_dataRoot = value; if (string.IsNullOrEmpty(Relative) == false) { Absolute = System.IO.Path.GetFullPath(System.IO.Path.Combine(m_dataRoot, Relative)); } else if (Absolute != null && Absolute.StartsWith(m_dataRoot)) { Relative = DetermineRelativePath(Absolute, m_dataRoot); } } }
void AddAttributes(TagBuilder tag) { if (Background != BackgroundStyle.Default) { tag.AddCssClass("background-" + Background.ToString().ToKebabCase()); } tag.AddCssClass(CssClass); tag.AddCssClassBoolNo(UserSelect, "user-select"); if (Absolute != null) { Absolute.MergeAbsolute(tag); tag.MergeStyle("width", "auto"); tag.MergeStyle("height", "auto"); } }
public void AbsoluteTest() { var minTime = new DateTime(1); var startTime = new DateTime(2); var endTime = new DateTime(3); var maxTime = new DateTime(4); var rc = new Absolute() { MinValue = minTime, StartTime = startTime, EndTime = endTime, MaxValue = maxTime }; var range = new TimeRangeImpl(); rc.Convert(range); Assert.AreEqual(startTime, range.StartTime); Assert.AreEqual(endTime, range.EndTime); }
public override int GetHashCode() { int hash = 1; if (valueCase_ == ValueOneofCase.Absolute) { hash ^= Absolute.GetHashCode(); } if (valueCase_ == ValueOneofCase.Boundary) { hash ^= Boundary.GetHashCode(); } hash ^= (int)valueCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
internal virtual void MergeAttributes(TagBuilder tag, RenderContext context, MergeAttrMode mode = MergeAttrMode.All) { if (mode.HasFlag(MergeAttrMode.Visibility)) { MergeVisibilityAttribures(tag, context); } if (mode.HasFlag(MergeAttrMode.Tip)) { MergeBindingAttributeString(tag, context, "title", "Tip", Tip); } if (mode.HasFlag(MergeAttrMode.Wrap)) { if (Wrap != WrapMode.Default) { tag.AddCssClass(Wrap.ToString().ToKebabCase()); } } if (mode.HasFlag(MergeAttrMode.Margin)) { if (Margin != null) { Margin.MergeStyles("margin", tag); } if (Padding != null) { Padding.MergeStyles("padding", tag); } } if (Absolute != null) { Absolute.MergeAbsolute(tag); } tag.MergeAttribute("id", HtmlId); }
public void RenderPyramid() { var absolute = new Absolute { Width = 11, Height = 7, Children = { new Fill { Char = 'a', Width = 4, Height = 2, [Absolute.LeftProperty] = 1, [Absolute.TopProperty] = 1, }, new Fill { Char = 'b', Width = 4, Height = 2, [Absolute.LeftProperty] = 1, [Absolute.BottomProperty] = 1, }, new Fill { Char = 'c', Width = 4, Height = 2, [Absolute.RightProperty] = 1, [Absolute.TopProperty] = 1, }, new Fill { Char = 'd', Width = 4, Height = 2, [Absolute.RightProperty] = 1, [Absolute.BottomProperty] = 1, }, new Fill { Char = 'e', Width = 5, Height = 3, [Absolute.LeftProperty] = 3, [Absolute.TopProperty] = 2, }, } }; GetRenderedText(absolute, 11).Should().BeLines( " ", " aaaa cccc ", " aaeeeeecc ", " eeeee ", " bbeeeeedd ", " bbbb dddd ", " "); }
internal virtual void MergeAttributes(TagBuilder tag, RenderContext context, MergeAttrMode mode = MergeAttrMode.All) { if (mode.HasFlag(MergeAttrMode.Visibility)) { MergeBindingAttributeBool(tag, context, "v-if", nameof(If), If); MergeBindingAttributeBool(tag, context, "v-show", nameof(Show), Show); // emulate v-hide MergeBindingAttributeBool(tag, context, "v-show", nameof(Hide), Hide, bInvert: true); } if (mode.HasFlag(MergeAttrMode.Tip)) { MergeBindingAttributeString(tag, context, "title", "Tip", Tip); } if (mode.HasFlag(MergeAttrMode.Wrap)) { if (Wrap != WrapMode.Default) { tag.AddCssClass(Wrap.ToString().ToKebabCase()); } } if (mode.HasFlag(MergeAttrMode.Margin)) { if (Margin != null) { Margin.MergeStyles("margin", tag); } if (Padding != null) { Padding.MergeStyles("padding", tag); } if (Absolute != null) { Absolute.MergeAbsolute(tag); } } }
/// <summary> /// Save profile values /// </summary> public void SaveProfileSettings() { if (Temperature > TempMax) { Temperature = TempMax; } if (Temperature < TempMin) { Temperature = TempMin; } if (_position > MaxStep) { _position = MaxStep; } //ascom items Profile.WriteValue(sCsDriverId, "Absolute", Absolute.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "MaxIncrement", MaxIncrement.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "MaxStep", MaxStep.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "Position", _position.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "StepSize", stepSize.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "TempComp", tempComp.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "TempCompAvailable", TempCompAvailable.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "Temperature", Temperature.ToString(CultureInfo.InvariantCulture)); //extended focuser items Profile.WriteValue(sCsDriverId, "CanHalt", CanHalt.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "CanStepSize", CanStepSize.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "Synchronous", Synchronous.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "TempMax", TempMax.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "TempMin", TempMin.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "TempPeriod", TempPeriod.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "TempProbe", TempProbe.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "TempSteps", TempSteps.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "SettleTime", settleTime.ToString(CultureInfo.InvariantCulture)); Profile.WriteValue(sCsDriverId, "Logging", TL.Enabled.ToString(CultureInfo.InvariantCulture)); }
public Node <INode> GetNode(string nodeName) { switch (nodeName) { case Absolute.NAME: INode nodeAbsolute = new Absolute() as INode; return(new Node <INode>(nodeAbsolute)); case Approx.NAME: INode nodeAprox = new Approx() as INode; return(new Node <INode>(nodeAprox)); case ArcCos.NAME: INode nodeArcCos = new ArcCos() as INode; return(new Node <INode>(nodeArcCos)); case ArcSin.NAME: INode nodeArcSin = new ArcSin() as INode; return(new Node <INode>(nodeArcSin)); case ArcTan2.NAME: INode nodeArcTan2 = new ArcTan2() as INode; return(new Node <INode>(nodeArcTan2)); case Ceil.NAME: INode nodeCeil = new Ceil() as INode; return(new Node <INode>(nodeCeil)); case CeilToInt.NAME: INode nodeCeilToInt = new CeilToInt() as INode; return(new Node <INode>(nodeCeilToInt)); case Clamp.NAME: INode nodeClamp = new Clamp() as INode; return(new Node <INode>(nodeClamp)); case Clamp01.NAME: INode nodeClamp01 = new Clamp01() as INode; return(new Node <INode>(nodeClamp01)); case ClosestPowerOf2.NAME: INode nodeClosestPowerOf2 = new ClosestPowerOf2() as INode; return(new Node <INode>(nodeClosestPowerOf2)); case Cosinus.NAME: INode nodeCosinus = new Cosinus() as INode; return(new Node <INode>(nodeCosinus)); case DeltaAngle.NAME: INode nodeDeltaAngle = new DeltaAngle() as INode; return(new Node <INode>(nodeDeltaAngle)); case Exp.NAME: INode nodeExp = new Exp() as INode; return(new Node <INode>(nodeExp)); case Floor.NAME: INode nodeFloor = new Floor() as INode; return(new Node <INode>(nodeFloor)); case FloorToInt.NAME: INode nodeFloorToInt = new FloorToInt() as INode; return(new Node <INode>(nodeFloorToInt)); case Lerp.NAME: INode nodeLerp = new Lerp() as INode; return(new Node <INode>(nodeLerp)); case LerpAngle.NAME: INode nodeLerpAngle = new LerpAngle() as INode; return(new Node <INode>(nodeLerpAngle)); case Log10.NAME: INode nodeLog10 = new Log10() as INode; return(new Node <INode>(nodeLog10)); case Logarithm.NAME: INode nodeLogarithm = new Logarithm() as INode; return(new Node <INode>(nodeLogarithm)); case Sinus.NAME: INode nodeSinus_ = new Sinus() as INode; return(new Node <INode>(nodeSinus_)); case Max.NAME: INode nodeMax = new Max() as INode; return(new Node <INode>(nodeMax)); case Min.NAME: INode nodeMin = new Min() as INode; return(new Node <INode>(nodeMin)); case MoveTowards.NAME: INode nodeMoveTowards = new MoveTowards() as INode; return(new Node <INode>(nodeMoveTowards)); case MoveTowardsAngle.NAME: INode nodeMoveTowardsAngle = new MoveTowardsAngle() as INode; return(new Node <INode>(nodeMoveTowardsAngle)); case NextPowerOfTwo.NAME: INode nodeNextPowerOfTwo = new NextPowerOfTwo() as INode; return(new Node <INode>(nodeNextPowerOfTwo)); case PerlinNoise.NAME: INode nodePerlinNoise = new PerlinNoise() as INode; return(new Node <INode>(nodePerlinNoise)); case PingPong.NAME: INode nodePingPong = new PingPong() as INode; return(new Node <INode> (nodePingPong)); case Pow.NAME: INode nodePow = new Pow() as INode; return(new Node <INode>(nodePow)); case SquareRoot.NAME: INode nodeSqrt = new SquareRoot() as INode; return(new Node <INode>(nodeSqrt)); case Tan.NAME: INode nodeTan = new Tan() as INode; return(new Node <INode>(nodeTan)); case Random.NAME: INode nodeRandom = new Random() as INode; return(new Node <INode>(nodeRandom)); default: return(null); } }
public void NoChildren() { var absolute = new Absolute(); new Action(() => RenderOn1x1(absolute)).Should().NotThrow(); }
public Task <byte[]> ReadBytesAbsoluteMultiAsync(IReadOnlyDictionary <ulong, int> offsetSizes, CancellationToken token) => Task.Run(() => ReadMulti(offsetSizes, Absolute.GetReadMultiMethod(false)), token);
public void Run(Absolute parent) { SetUpstream(parent._scheduler.ScheduleAction(this, parent._dueTime, static @this => @this.Timeout())); _serialDisposable.Disposable = parent._source.SubscribeSafe(this); }
public void SetUp() { _state = new State(); _absolute = new Absolute(); }
/// <inheritdoc /> public int CompareTo(SourceLocation other) { return(Absolute.CompareTo(other.Absolute)); }
public SuperHappyScript(string script) { ValueNode currentNode = null; string currentParseValue = ""; int predenceLevel = 0; _variables = new List <string>(); int index = 0; char currentToken = ' '; char nextToken = ' '; _script = script; try { foreach (char token in script) { index++; if (script.Length > index) { nextToken = script[index]; } currentToken = token; if (currentParseValue.StartsWith("[") && !currentParseValue.EndsWith("]") && !(currentParseValue + token).EndsWith(">=") && !(currentParseValue + token).EndsWith("<=") && !(currentParseValue + token).EndsWith("<>")) { currentParseValue += token; continue; } if (IgnoreSet.Contains(token)) { if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } } else if (token == ']') { currentParseValue += token; currentNode = AddValue(currentNode, currentParseValue); } else if (token == ',') { if (predenceLevel == 0) { throw new Exception("Parsing error"); } if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } currentNode = WrapFunction(currentNode, predenceLevel, false); } else if ((currentParseValue + token).ToUpper() == "ABS(") { currentNode = new Absolute(predenceLevel).AttachNode(currentNode); predenceLevel += MAX_PREDENCE + 1; } else if ((currentParseValue + token).ToUpper() == "ROUND(") { currentNode = new Round(predenceLevel).AttachNode(currentNode); predenceLevel += MAX_PREDENCE + 1; } else if ((currentParseValue + token).ToUpper() == "INT(") { currentNode = new RoundDown(predenceLevel).AttachNode(currentNode); predenceLevel += MAX_PREDENCE + 1; } else if ((currentParseValue + token).ToUpper() == "IIF(") { currentNode = new IfStatement(predenceLevel).AttachNode(currentNode); predenceLevel += MAX_PREDENCE + 1; } else if ((currentParseValue + token).ToUpper() == "MAX(") { currentNode = new Max(predenceLevel).AttachNode(currentNode); predenceLevel += MAX_PREDENCE + 1; } else if ((currentParseValue + token).ToUpper() == "ISNAN(") { currentNode = new IsNaN(predenceLevel).AttachNode(currentNode); predenceLevel += MAX_PREDENCE + 1; } else if ((currentParseValue + token).ToUpper() == "MIN(") { currentNode = new Min(predenceLevel).AttachNode(currentNode); predenceLevel += MAX_PREDENCE + 1; } else if ((currentParseValue + token).ToUpper() == "AND") { if (currentParseValue.Length > 2) { currentNode = AddValue(currentNode, currentParseValue.Substring(0, currentParseValue.Length - 2)); } currentNode = new And(predenceLevel).AttachNode(currentNode); } else if ((currentParseValue + token).ToUpper() == "OR") { if (currentParseValue.Length > 2) { currentNode = AddValue(currentNode, currentParseValue.Substring(0, currentParseValue.Length - 2)); } currentNode = new Or(predenceLevel).AttachNode(currentNode); } else if ((currentParseValue + token).ToUpper() == "NOT") { if (currentParseValue.Length > 2) { currentNode = AddValue(currentNode, currentParseValue.Substring(0, currentParseValue.Length - 2)); } currentNode = new Not(predenceLevel).AttachNode(currentNode); } else if (token == '(') { if (currentParseValue != "") { throw new Exception("Parsing error"); } predenceLevel += MAX_PREDENCE + 1; } else if (token == ')') { if (predenceLevel == 0) { throw new Exception("Parsing error"); } if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } currentNode = WrapFunction(currentNode, predenceLevel, true); predenceLevel -= MAX_PREDENCE + 1; } else if ((currentParseValue + token).EndsWith("=")) { if (currentParseValue.Length > 1) { currentNode = AddValue(currentNode, currentParseValue.Substring(0, currentParseValue.Length)); } currentNode = new Equal(predenceLevel).AttachNode(currentNode); } else if ((currentParseValue + token).EndsWith(">=")) { if (currentParseValue.Length > 2) { currentNode = AddValue(currentNode, currentParseValue.Substring(0, currentParseValue.Length - 1)); } currentNode = new EqualOrGreaterThan(predenceLevel).AttachNode(currentNode); } else if ((currentParseValue + token).EndsWith("<=")) { if (currentParseValue.Length > 2) { currentNode = AddValue(currentNode, currentParseValue.Substring(0, currentParseValue.Length - 1)); } currentNode = new EqualOrLessThan(predenceLevel).AttachNode(currentNode); } else if ((currentParseValue + token).EndsWith("<>")) { if (currentParseValue.Length > 2) { currentNode = AddValue(currentNode, currentParseValue.Substring(0, currentParseValue.Length - 1)); } currentNode = new NotEqual(predenceLevel).AttachNode(currentNode); } else if (token == '>' && nextToken != '=') { if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } currentNode = new GreaterThan(predenceLevel).AttachNode(currentNode); } else if (token == '<' && nextToken != '>' && nextToken != '=') { if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } currentNode = new LessThan(predenceLevel).AttachNode(currentNode); } else if (token == '+') { if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } currentNode = new Add(predenceLevel).AttachNode(currentNode); } else if (token == '-') { if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } if (currentNode == null || currentNode is Operand || currentNode is Function) { currentNode = new Negate(predenceLevel).AttachNode(currentNode); } else { currentNode = new Subtract(predenceLevel).AttachNode(currentNode); } } else if (token == '*') { if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } currentNode = new Multiply(predenceLevel).AttachNode(currentNode); } else if (token == '/') { if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } currentNode = new Divide(predenceLevel).AttachNode(currentNode); } else if (token == '^') { if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } currentNode = new PowerOf(predenceLevel).AttachNode(currentNode); } else { if (currentParseValue.StartsWith("[") && currentParseValue.EndsWith("]") && token == '[') { throw new Exception("Two variables declared in a row"); } currentParseValue += token; continue; } currentParseValue = ""; } } catch (Exception exc) { throw new Exception(exc.Message + " at token: " + currentToken + " in row: " + index); } if (currentParseValue != "") { currentNode = AddValue(currentNode, currentParseValue); } if (predenceLevel != 0) { throw new Exception("Parsing error"); } while (currentNode.Parent != null) { currentNode = currentNode.Parent; } _startNode = currentNode; _variables = new List <string>(_variables.Distinct()); Test(); }
public void WriteBytesAbsolute(byte[] data, ulong offset) => Write(data, offset, Absolute.GetWriteMethod(false));
/// <summary> /// Gets the <see cref="Absolute"/> position. /// </summary> /// <returns></returns> public override string ToString() => Absolute.ToString();
public Task <byte[]> ReadBytesAbsoluteAsync(ulong offset, int length, CancellationToken token) => Task.Run(() => Read(offset, length, Absolute.GetReadMethod(false)), token);
public Task WriteBytesAbsoluteAsync(byte[] data, ulong offset, CancellationToken token) => Task.Run(() => Write(data, offset, Absolute.GetWriteMethod(false)), token);
public byte[] ReadBytesAbsolute(ulong offset, int length) => Read(offset, length, Absolute.GetReadMethod(false));