public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[4]; fromFloats = new float[4]; fromFloats[0] = rectVariable.IsNone ? 0f : rectVariable.Value.x; fromFloats[1] = rectVariable.IsNone ? 0f : rectVariable.Value.y; fromFloats[2] = rectVariable.IsNone ? 0f : rectVariable.Value.width; fromFloats[3] = rectVariable.IsNone ? 0f : rectVariable.Value.height; curves = new AnimationCurve[4]; curves[0] = curveX.curve; curves[1] = curveY.curve; curves[2] = curveW.curve; curves[3] = curveH.curve; calculations = new Calculation[4]; calculations[0] = calculationX; calculations[1] = calculationY; calculations[2] = calculationW; calculations[3] = calculationH; Init(); if (Math.Abs(delay.Value) < 0.01f) { UpdateVariableValue(); } }
/// <summary> /// Initializes an exception with the specified calculation, message, and inner exception /// </summary> /// <param name="variable">The invalid calculation</param> /// <param name="message">The message that describes the error</param> /// <param name="inner">The exception that is the cause of this exception</param> public InvalidCalculationResultTypeException(Calculation calculation, string message, Exception inner) : base(message, inner) { Contract.Requires(calculation != null); Calculation = calculation; }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[4]; fromFloats = new float[4]; fromFloats[0] = colorVariable.IsNone ? 0f : colorVariable.Value.r; fromFloats[1] = colorVariable.IsNone ? 0f : colorVariable.Value.g; fromFloats[2] = colorVariable.IsNone ? 0f : colorVariable.Value.b; fromFloats[3] = colorVariable.IsNone ? 0f : colorVariable.Value.a; curves = new AnimationCurve[4]; curves[0] = curveR.curve; curves[1] = curveG.curve; curves[2] = curveB.curve; curves[3] = curveA.curve; calculations = new Calculation[4]; calculations[0] = calculationR; calculations[1] = calculationG; calculations[2] = calculationB; calculations[3] = calculationA; Init(); // Set initial value if (Math.Abs(delay.Value) < 0.01f) { UpdateVariableValue(); } }
protected override void Given() { // A = B + C // B = D + E // C = F - 1 // D = 2 // E = C + 1 // F = E * 2 // // Cycle: E -> C -> F -> E // // Path from root: A -> B -> E -> C -> F -> E var variableA = new Variable("Grasp", "A", typeof(int)); var variableB = new Variable("Grasp", "B", typeof(int)); var variableC = new Variable("Grasp", "C", typeof(int)); var variableD = new Variable("Grasp", "D", typeof(int)); var variableE = new Variable("Grasp", "E", typeof(int)); var variableF = new Variable("Grasp", "F", typeof(int)); _calculationA = new Calculation(variableA, Expression.Add(Variable.Expression(variableB), Variable.Expression(variableC))); _calculationB = new Calculation(variableB, Expression.Add(Variable.Expression(variableD), Variable.Expression(variableE))); _calculationC = new Calculation(variableC, Expression.Subtract(Variable.Expression(variableF), Expression.Constant(1))); _calculationD = new Calculation(variableD, Expression.Constant(2)); _calculationE = new Calculation(variableE, Expression.Add(Variable.Expression(variableC), Expression.Constant(1))); _calculationF = new Calculation(variableF, Expression.Multiply(Variable.Expression(variableE), Expression.Constant(2))); _schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { _calculationA, _calculationB, _calculationC, _calculationD, _calculationE, _calculationF }); }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[4]; fromFloats = new float[4]; fromFloats[0] = fromValue.IsNone ? 0f : fromValue.Value.r; fromFloats[1] = fromValue.IsNone ? 0f : fromValue.Value.g; fromFloats[2] = fromValue.IsNone ? 0f : fromValue.Value.b; fromFloats[3] = fromValue.IsNone ? 0f : fromValue.Value.a; toFloats = new float[4]; toFloats[0] = toValue.IsNone ? 0f : toValue.Value.r; toFloats[1] = toValue.IsNone ? 0f : toValue.Value.g; toFloats[2] = toValue.IsNone ? 0f : toValue.Value.b; toFloats[3] = toValue.IsNone ? 0f : toValue.Value.a; curves = new AnimationCurve[4]; curves[0] = curveR.curve; curves[1] = curveG.curve; curves[2] = curveB.curve; curves[3] = curveA.curve; calculations = new Calculation[4]; calculations[0] = calculationR; calculations[1] = calculationG; calculations[2] = calculationB; calculations[3] = calculationA; //call Init after you have initialized curves array Init(); }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[3]; fromFloats = new float[3]; fromFloats[0] = vectorVariable.IsNone ? 0f : vectorVariable.Value.x; fromFloats[1] = vectorVariable.IsNone ? 0f : vectorVariable.Value.y; fromFloats[2] = vectorVariable.IsNone ? 0f : vectorVariable.Value.z; curves = new AnimationCurve[3]; curves[0] = curveX.curve; curves[1] = curveY.curve; curves[2] = curveZ.curve; calculations = new Calculation[3]; calculations[0] = calculationX; calculations[1] = calculationY; calculations[2] = calculationZ; Init(); // Set initial value if (Math.Abs(delay.Value) < 0.01f) { UpdateVariableValue(); } }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[3]; fromFloats = new float[3]; fromFloats[0] = fromValue.IsNone ? 0f : fromValue.Value.x; fromFloats[1] = fromValue.IsNone ? 0f : fromValue.Value.y; fromFloats[2] = fromValue.IsNone ? 0f : fromValue.Value.z; toFloats = new float[3]; toFloats[0] = toValue.IsNone ? 0f : toValue.Value.x; toFloats[1] = toValue.IsNone ? 0f : toValue.Value.y; toFloats[2] = toValue.IsNone ? 0f : toValue.Value.z; curves = new AnimationCurve[3]; curves[0] = curveX.curve; curves[1] = curveY.curve; curves[2] = curveZ.curve; calculations = new Calculation[3]; calculations[0] = calculationX; calculations[1] = calculationY; calculations[2] = calculationZ; //call Init after you have initialized curves array Init(); }
protected override void Given() { _result = new Derived(); _calculation = new Calculation(new Variable("Grasp", "Output", typeof(Base)), Expression.Constant(_result)); _schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { _calculation }); }
internal ISet<Variable> GetVariables(Calculation calculation) { _variables = new HashSet<Variable>(); Visit(calculation.Expression); return _variables; }
protected override void Given() { _unknownVariable = new Variable("Grasp", "Unknown", typeof(int)); _calculation = new Calculation(new Variable("Grasp", "Output", typeof(int)), Variable.Expression(_unknownVariable)); _schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { _calculation }); }
/// <summary> /// Initializes an exception with the specified calculation context and repeated calculation /// </summary> /// <param name="context">The calculations above the repeated one from the root</param> /// <param name="repeatedCalculation">The calculation repeated in the context of the root</param> public CalculationCycleException(IEnumerable<Calculation> context, Calculation repeatedCalculation) { Contract.Requires(context != null); Contract.Requires(repeatedCalculation != null); Context = context.ToList().AsReadOnly(); RepeatedCalculation = repeatedCalculation; }
/// <summary> /// Initializes an exception with the specified calculation context, repeated calculation, message, and inner exception /// </summary> /// <param name="context">The calculations above the repeated one from the root</param> /// <param name="repeatedCalculation">The calculation repeated in the context of the root</param> /// <param name="message">The message that describes the error</param> /// <param name="inner">The exception that is the cause of this exception</param> public CalculationCycleException(IEnumerable<Calculation> context, Calculation repeatedCalculation, string message, Exception inner) : base(message, inner) { Contract.Requires(context != null); Contract.Requires(repeatedCalculation != null); Context = context.ToList().AsReadOnly(); RepeatedCalculation = repeatedCalculation; }
protected override void Given() { var implicitVariable = new Variable("Grasp", "Implicit", typeof(int)); var calculation1 = new Calculation(implicitVariable, Expression.Constant(1)); var calculation2 = new Calculation(new Variable("Grasp", "Output", typeof(int)), Variable.Expression(implicitVariable)); _schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { calculation1, calculation2 }); }
/// <summary> /// Initializes an exception with the specified variable, calculation, and schema /// </summary> /// <param name="variable">The invalid variable</param> /// <param name="calculation">The calculation which references the invalid variable</param> /// <param name="schema">The schema which defines the valid variables</param> public InvalidCalculationVariableException(Variable variable, Calculation calculation, GraspSchema schema) { Contract.Requires(variable != null); Contract.Requires(calculation != null); Contract.Requires(schema != null); Variable = variable; Calculation = calculation; Schema = schema; }
/// <summary> /// Initializes an exception with the specified variable, calculation, schema, message, and inner exception /// </summary> /// <param name="variable">The invalid variable</param> /// <param name="calculation">The calculation which references the invalid variable</param> /// <param name="schema">The schema which defines the valid variables</param> /// <param name="message">The message that describes the error</param> /// <param name="inner">The exception that is the cause of this exception</param> public InvalidCalculationVariableException(Variable variable, Calculation calculation, GraspSchema schema, string message, Exception inner) : base(message, inner) { Contract.Requires(variable != null); Contract.Requires(calculation != null); Contract.Requires(schema != null); Variable = variable; Calculation = calculation; Schema = schema; }
static void Main(string[] args) { // Benytter en type erklæret i et F# namespace (fungerer som et almindeligt .NET-namespace) var c = new Calculation(42); Console.WriteLine(c.Result); // Benytter et element fra et F#-modul var liste = KodeFraFSharpModule.talListe; Console.WriteLine(liste); Console.WriteLine(liste.Count()); Console.ReadLine(); }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[1]; fromFloats = new float[1]; fromFloats[0] = floatVariable.IsNone ? 0f : floatVariable.Value; calculations = new Calculation[1]; calculations[0] = calculation; curves = new AnimationCurve[1]; curves[0] = animCurve.curve; //call Init after you have initialized curves array Init(); }
protected override void Given() { _left = 1; _right = 2; _outputVariable = new Variable("Grasp", "Output", typeof(int)); var calculation = new Calculation(_outputVariable, Expression.Add(Expression.Constant(_left), Expression.Constant(_right))); var schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { calculation }); var executable = schema.Compile(); _runtime = executable.GetRuntime(A.Fake<IRuntimeSnapshot>()); }
static void Main(string[] args) { // using the same class of PerformenceDiagnostic from the onother project _1.SampleOperations.PerformenceDiagnostic performencer = new _1.SampleOperations.PerformenceDiagnostic(); ///////////////////////////////////////////////////////////////////////////////////////////////////////// Calculation<float> calculatorFloat = new Calculation<float>(1F); Console.WriteLine("____________________"); Console.WriteLine("Float Statistic."); Console.WriteLine(); Console.Write("Square root: "); Console.WriteLine(performencer.CalculatePerformance(calculatorFloat.CalculateSquareRoot)); Console.Write("Natural Logarithm: "); Console.WriteLine(performencer.CalculatePerformance(calculatorFloat.CalculateNaturalLogarithm)); Console.Write("Sin: "); Console.WriteLine(performencer.CalculatePerformance(calculatorFloat.CalculateSinus)); Calculation<double> calculatorDouble = new Calculation<double>(1D); Console.WriteLine("____________________"); Console.WriteLine("Double Statistic."); Console.WriteLine(); Console.Write("Square root: "); Console.WriteLine(performencer.CalculatePerformance(calculatorDouble.CalculateSquareRoot)); Console.Write("Natural Logarithm: "); Console.WriteLine(performencer.CalculatePerformance(calculatorDouble.CalculateNaturalLogarithm)); Console.Write("Sin: "); Console.WriteLine(performencer.CalculatePerformance(calculatorDouble.CalculateSinus)); /* Decimal Value can't be use in System.Math class. Only Double, Float values! Calculation<decimal> calculatorDecimal = new Calculation<decimal>(1M); Console.WriteLine("____________________"); Console.WriteLine("Decimal Statistic."); Console.WriteLine(); Console.Write("Square root: "); Console.WriteLine(performencer.CalculatePerformance(calculatorDecimal.CalculateSquareRoot)); Console.Write("Natural Logarithm: "); Console.WriteLine(performencer.CalculatePerformance(calculatorDecimal.CalculateNaturalLogarithm)); Console.Write("Sin: "); Console.WriteLine(performencer.CalculatePerformance(calculatorDecimal.CalculateSinus)); */ }
/// <summary> /// 指定された年の日付を取得します。 /// </summary> /// <param name="year">取得する年</param> /// <returns>祝日の日付</returns> public override DateTime GetDate(int year) { var monthCalculation = new Calculation(monthFormula.Replace("{year}", year.ToString())); var dayCalculation = new Calculation(dayFormula.Replace("{year}", year.ToString())); int month = Convert.ToInt32(Math.Floor(monthCalculation.Value)); int day = Convert.ToInt32(Math.Floor(dayCalculation.Value)); DateTime tmpDate; bool result = DateTime.TryParse(String.Format("{0}/{1}/{2}", year, month, day), out tmpDate); if (false == result) { tmpDate = Holiday.NotExistingDate; } return tmpDate; }
protected override void Given() { // A = B // B = C // C = A // // Cycle: A -> B -> C -> A var variableA = new Variable("Grasp", "A", typeof(int)); var variableB = new Variable("Grasp", "B", typeof(int)); var variableC = new Variable("Grasp", "C", typeof(int)); _calculationA = new Calculation(variableA, Variable.Expression(variableB)); _calculationB = new Calculation(variableB, Variable.Expression(variableC)); _calculationC = new Calculation(variableC, Variable.Expression(variableA)); _schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { _calculationA, _calculationB, _calculationC }); }
protected override void Given() { _left1 = 1; _right1 = 2; _left2 = 10; _outputVariable1 = new Variable("Grasp", "Output1", typeof(int)); _outputVariable2 = new Variable("Grasp", "Output2", typeof(int)); var calculation1 = new Calculation(_outputVariable1, Expression.Add(Expression.Constant(_left1), Expression.Constant(_right1))); var calculation2 = new Calculation(_outputVariable2, Expression.Add(Expression.Constant(_left2), Variable.Expression(_outputVariable1))); var schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { calculation1, calculation2 }); var executable = schema.Compile(); _runtime = executable.GetRuntime(A.Fake<IRuntimeSnapshot>()); }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[3]; fromFloats = new float[3]; fromFloats[0] = vectorVariable.IsNone ? 0f : vectorVariable.Value.x; fromFloats[1] = vectorVariable.IsNone ? 0f : vectorVariable.Value.y; fromFloats[2] = vectorVariable.IsNone ? 0f : vectorVariable.Value.z; curves = new AnimationCurve[3]; curves[0] = curveX.curve; curves[1] = curveY.curve; curves[2] = curveZ.curve; calculations = new Calculation[3]; calculations[0] = calculationX; calculations[1] = calculationY; calculations[2] = calculationZ; Init(); }
protected override void Given() { _leftValue = 1; _right = 2; var left = new Variable("Grasp", "Left", typeof(int)); _outputVariable = new Variable("Grasp", "Output", typeof(int)); var calculation = new Calculation(_outputVariable, Expression.Add(Variable.Expression(left), Expression.Constant(_right))); var schema = new GraspSchema(new[] { left }, new[] { calculation }); var executable = schema.Compile(); var initialState = A.Fake<IRuntimeSnapshot>(); A.CallTo(() => initialState.GetValue(left)).Returns(_leftValue); _runtime = executable.GetRuntime(initialState); }
/// <summary> /// インスタンスを生成します。 /// </summary> /// <param name="monthFormula">月を算出する計算式</param> /// <param name="dayFormula">日を算出する計算式</param> /// <param name="name">祝祭日名</param> /// <param name="substituteFlg">振替休日フラグ</param> /// <param name="nationalHolidayFlg">国民の休日フラグ</param> public HolidayCalculation(string monthFormula, string dayFormula, string name = null, bool substituteFlg = true, bool nationalHolidayFlg = true) : base(HolidayType.Calculation, name, substituteFlg, nationalHolidayFlg) { try { var calc = new Calculation(monthFormula.Replace("{year}", "2000")); } catch (Exception ex) { throw new ArgumentException("月を算出する計算式が不正です。", ex); } try { var calc = new Calculation(dayFormula.Replace("{year}", "2000")); } catch (Exception ex) { throw new ArgumentException("日を算出する計算式が不正です。", ex); } this.monthFormula = monthFormula; this.dayFormula = dayFormula; }
public JobPositionPoint(CalculationPointId id, Period period, Employee employee, Calculation calculation, JobPosition jobPosition, string name, decimal value, bool isFinal = false) : base(id, period, employee, calculation, name, value, isFinal) { this.jobPositionId = jobPosition.Id; }
//public IEnumerable<Calculation> GetUserCalculationsByCalculationTypes(IEnumerable<long> calculationTypeIDs, long userID) //{ // return _calculationRepository // .GetMany(c => c.Owner.Id == userID && c.CalculationTypeID.HasValue && calculationTypeIDs.Contains(c.CalculationTypeID.Value)); //} public void AddCalculation(Calculation calculation) { _calculationRepository.Add(calculation); SaveCalculation(); }
public static int Multiply(this Calculation calculation, int a, int b) { return(a * b); }
public ViewModel(Calculation model) { this.CalcProgVisibility = model.CalcProgVisibility; this.CalcProgVisibility.PropertyChanged += (s, e) => { UpdateEntity(s); }; }
protected ContextMenu BuildContextMenu() { // menu according to header if (this.Header != null) { Parameter p = this.Header as Parameter; if (p != null) { if (p.Buddy != null && p.CompResult < ComparisonResult.SAME) { ContextMenu cm = new ContextMenu(); cm.UseLayoutRounding = true; MenuItem mi1 = new MenuItem(); mi1.Header = "Eigenschaften übernehmen"; mi1.Command = new RelayCommand((x) => p.AdoptPropertiesOfBuddy()); mi1.Icon = new Image { Source = new BitmapImage(new Uri(@"../Data/icons/menu/menu_OK.png", UriKind.Relative)), Width = 16, Height = 16 }; cm.Items.Add(mi1); return(cm); } else if (p.Buddy == null && p.CompResult == ComparisonResult.UNIQUE && this.OtherParentComp != null) { ContextMenu cm = new ContextMenu(); cm.UseLayoutRounding = true; MenuItem mi1 = new MenuItem(); mi1.Header = "in andere Komponente übertragen"; mi1.Command = new RelayCommand((x) => this.OtherParentComp.AddCopyOfParameter(p, this.User)); mi1.Icon = new Image { Source = new BitmapImage(new Uri(@"../Data/icons/menu/menu_REF_on.png", UriKind.Relative)), Width = 16, Height = 16 }; cm.Items.Add(mi1); return(cm); } } Calculation calc = this.Header as Calculation; if (calc != null) { if (calc.Buddy != null && calc.CompResult == ComparisonResult.SAMENAMEUNIT_DIFFVALUE) { ContextMenu cm = new ContextMenu(); cm.UseLayoutRounding = true; MenuItem mi1 = new MenuItem(); mi1.Header = "Ausdruck übernehmen"; mi1.Command = new RelayCommand((x) => calc.AdoptPropertiesOfBuddy()); mi1.Icon = new Image { Source = new BitmapImage(new Uri(@"../Data/icons/menu/menu_OK.png", UriKind.Relative)), Width = 16, Height = 16 }; cm.Items.Add(mi1); return(cm); } else if (calc.Buddy == null && calc.CompResult == ComparisonResult.UNIQUE && this.OtherParentComp != null) { ContextMenu cm = new ContextMenu(); cm.UseLayoutRounding = true; MenuItem mi1 = new MenuItem(); mi1.Header = "in andere Komponente übertragen"; mi1.Command = new RelayCommand((x) => this.OtherParentComp.AddCopyOfCalculation(calc, this.User)); mi1.Icon = new Image { Source = new BitmapImage(new Uri(@"../Data/icons/menu/menu_REF_on.png", UriKind.Relative)), Width = 16, Height = 16 }; cm.Items.Add(mi1); return(cm); } } } return(null); }
public static FloatingRateCalculation CalculationGetFloatingRateCalculation(Calculation calculation) { return((FloatingRateCalculation)calculation.Items?[0]); }
public static bool CalculationHasDiscounting(Calculation calculation) { bool result = calculation.discounting != null; return(result); }
public Environs() { enviroment = new List<EnvironsStuct>(); calc = new Calculation(this); }
public void CheckIfNumber1AndNumber2AreInRange() { (string message, double correctAnswer) = Calculation.GetMathsEquation(MathOperation.Multiplication, UserDifficulty.Easy); Assert.That(correctAnswer < 144 && correctAnswer >= 0); }
protected override void Given() { var calculation = new Calculation(new Variable("Grasp", "Output", typeof(int)), new InvalidExpression()); _schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { calculation }); }
public void SolveTestFactorial() { //Data preparation--------------------------------------------------------------- List <double[]> lstArrays = CreateRandomArrays(); double[] firstMembers = new double[21]; string[] resultExpected = new string[21]; for (int i = 0; i < 21; i++) { firstMembers[i] = lstArrays.ElementAt(0)[i]; } for (int i = 0; i < 21; i++) { /*The result is rounded because after about 10 digits the Solve() method and c# start * rounding the decimals in a different way, giving 2 very close but different values.*/ double answer = 0; double input = firstMembers[i]; double count; if (input > 0 && Math.Round(input) == input) { count = 1; while (count <= input) { if (count == 1) { answer = 1; count++; } else { answer = count * answer; count++; } } resultExpected[i] = answer.ToString(); } else { resultExpected[i] = "Non Numérique"; } } //Testing with zeros and decimal numbers firstMembers[20] = 0; resultExpected[20] = "1"; //Execution---------------------------------------------------------------------- string[] resultCalculated = new string[21]; List <string> opList = new List <string>(); for (int i = 0; i < 21; i++) { opList.Clear(); opList.Add("(" + firstMembers[i].ToString() + ")"); opList.Add("!"); resultCalculated[i] = Calculation.Solve(opList); } //Check---------------------------------------------------------------------------- CollectionAssert.AreEquivalent(resultExpected, resultCalculated); }
public static void CalculationSetFloatingRateCalculation(Calculation calculation, FloatingRateCalculation floatingRateCalculation) { calculation.Items = new object[] { floatingRateCalculation }; }
public Calculation Resolve(IEnumerable <string> lines, Calculation baseCalculation) { throw new NotImplementedException(); }
private void UpdateEntity(Calculation source) { CalcProgVisibility = source.CalcProgVisibility; }
public static bool CalculationHasFloatingRateCalculation(Calculation calculation) { return(calculation.Items?[0] is FloatingRateCalculation); }
public void SolveTestExponentiation() { //Data preparation--------------------------------------------------------------- List <double[]> lstArrays = CreateRandomArrays(); double[] firstMembers = new double[64]; double[] secondMembers = new double[64]; string[] resultExpected = new string[64]; for (int i = 0; i < 60; i++) { firstMembers[i] = lstArrays.ElementAt(0)[i]; secondMembers[i] = lstArrays.ElementAt(1)[i]; if (firstMembers[i] != (int)firstMembers[i]) { firstMembers[i] /= 15; } else { firstMembers[i] /= 15; firstMembers[i] = Math.Round(firstMembers[i] + 0.5 * Math.Sign(firstMembers[i])); } if (secondMembers[i] != (int)secondMembers[i]) { secondMembers[i] /= 15; } else { secondMembers[i] /= 15; secondMembers[i] = Math.Round(secondMembers[i] + 0.5 * Math.Sign(secondMembers[i])); } } for (int i = 0; i < 60; i++) { resultExpected[i] = Math.Round(Math.Pow(firstMembers[i], secondMembers[i]), 4).ToString(); } //Testing with zeros firstMembers[60] = 0; firstMembers[61] = 0; firstMembers[62] = 0; firstMembers[63] = 12.3; secondMembers[60] = 0; secondMembers[61] = -5.74; secondMembers[62] = 5.74; secondMembers[63] = 0; resultExpected[60] = "1"; resultExpected[61] = "+Infini"; resultExpected[62] = "0"; resultExpected[63] = "1"; //Execution---------------------------------------------------------------------- string[] resultCalculated = new string[64]; List <string> opList = new List <string>(); for (int i = 0; i < 64; i++) { opList.Clear(); opList.Add("(" + firstMembers[i] + ")^" + "(" + secondMembers[i] + ")"); resultCalculated[i] = Math.Round(double.Parse(Calculation.Solve(opList)), 4).ToString(); } //Check---------------------------------------------------------------------------- CollectionAssert.AreEquivalent(resultExpected, resultCalculated); }
public static List <FxLinkedNotionalSchedule> CalculationGetFxLinkedNotionalSchedule(Calculation calculation) { var result = new List <FxLinkedNotionalSchedule>(); if (calculation.Items != null) { foreach (var item in calculation.Items) { if (item is FxLinkedNotionalSchedule schedule) { result.Add(schedule); } } } return(result); }
public abstract Calculation Resolve(IEnumerable <string> lines, Calculation baseCalculation);
public static void CalculationSetFxLinkedNotionalSchedule(Calculation calculation, FxLinkedNotionalSchedule value) { calculation.Items = new object[] { value }; }
public static int Divide(this Calculation calculation, int a, int b) { return(a / b); }
public IActionResult Calculate(Calculation calculation) { workerQueue.Enqueue((token) => CalculateInternal(calculation)); return(Ok()); }
/// <summary> /// Initializes an exception with the specified calculation /// </summary> /// <param name="variable">The invalid calculation</param> public InvalidCalculationResultTypeException(Calculation calculation) { Contract.Requires(calculation != null); Calculation = calculation; }
private async Task <object> CalculateInternal(Calculation calculation) { var result = await this.calculationService.Calculate(calculation); return(result); }
public void Divide_ByZero() { var calculations = new Calculation(); Assert.Throws <DivideByZeroException>(() => calculations.Divide(10, 0)); }
private static void PlanckConstant() { Console.WriteLine(Calculation.Result()); }
public void UpdateCalculation(Calculation calculation) { _calculationRepository.Update(calculation); SaveCalculation(); }
public CalculationScreenViewModel() { cs = new Calculation(); }
public void CheckIfGetPossibleOperationsByDifficultyWorks() { var(operationmin, operationmax) = Calculation.GetPossibleOperationsByDifficulty(UserDifficulty.Easy); Assert.AreEqual(1, operationmin); Assert.AreEqual(4, operationmax); }
public void SalesFactor_ReturnsFormula2WhenPriceGreaterThanMaxPrice(int pricePerGlass, double expectedFactor) { var factor = Calculation.SalesFactor(pricePerGlass); Assert.AreEqual(expectedFactor, factor, .01); }
public void SetUp() { _calculation = new Calculation(); }
public void SignFactor_ReturnsExponentialValue(int signs, double expectedFactor) { var factor = Calculation.SignFactor(signs); Assert.AreEqual(expectedFactor, factor, .01); }
private void ThrowCalculationCycleException(Calculation repeatedCalculation) { var context = _context.Reverse().Select(visitedNode => visitedNode.Calculation.Source).ToList(); throw new CalculationCycleException( context, repeatedCalculation, Resources.CalculationHasCycle.FormatInvariant(GetCycleText(context, repeatedCalculation))); }
/// <summary> /// 設定資料 /// </summary> void SetData() { if (form == null) { form = new Dictionary <int, System.Windows.Controls.UserControl>(); } AllConbination = Calculation.CombinationNumber(2, 0, 9); var tab = Calculation.CreateOption(1, 9, new string[9] { "胆码", "定位形态", "不定位形态", "和值", "和尾", "跨度", "和差", "垃圾组合", "大底集合" }); foreach (var tmp in tab) { if (tmp.ID == 1) { form.Add(tmp.ID, new UcTwoStart1()); } else if (tmp.ID == 2) { form.Add(tmp.ID, new UcTwoStart2()); } else if (tmp.ID == 3) { form.Add(tmp.ID, new UcTwoStart3()); } else if (tmp.ID == 4) { form.Add(tmp.ID, new UcTwoStart4()); } else if (tmp.ID == 5) { form.Add(tmp.ID, new UcTwoStart5()); } else if (tmp.ID == 6) { form.Add(tmp.ID, new UcTwoStart6()); } else if (tmp.ID == 7) { form.Add(tmp.ID, new UcTwoStart7()); } else if (tmp.ID == 8) { form.Add(tmp.ID, new UcTwoStart8()); } else if (tmp.ID == 9) { UcTwoStart9 tmp2 = new UcTwoStart9(); tmp2.DataRefresh = DataRefresh; form.Add(tmp.ID, tmp2); } TabItem tb = new TabItem() { Content = form[tmp.ID], Header = tmp.Name }; tcSettings.Items.Add(tb); } (tcSettings.Items[6] as TabItem).Visibility = Visibility.Collapsed; }
public static void CalculationSetNotionalSchedule(Calculation calculation, Notional value) { calculation.Items = new object[] { value }; }
private void RefreshStockQuotes() { //write my onw class that inherits from that colletion type, //this will be a custom method //add new methods that will be able to do thin //it will inherit from objervableCollection. //class object inherts form objervColleciton, //add methods from the collection. //IN the method, iterage through the actual collection. //I can then do something with each item. //if I want to find the thing that has the biggest number of percentae //compart most recent to the //mayble linq would be to //write a loop that would go into the that List<Quote> lstQuote = new List<Quote>(); //This is where I will refresh all of the stock quotes Quotes = new ObservableCollection<Quote>(); //Stocks = new ObservableCollection<Stock>(); var StockListPath = Server.MapPath("~/App_Data/StockList.txt"); //System.IO.File.WriteAllText(StockListPath, "Stocks List"); int BatchRowCount = 300; int totalBatches = (File.ReadAllLines(StockListPath).Count() / BatchRowCount) + 1; int CurrentRowBatch = 0; // 32751;// 0; //8536145;THIS NUMBER WAS WHERE WE STARTED START IMPORT IN THE MIDDLE OF FILE for (int i = 0; i < totalBatches; i++) { string s = File.ReadAllLines(StockListPath)[0].ToString(); //Add just the batch of items //I need to add the 300 items to a file, move to the next 300- CurrentRowBatch += BatchRowCount; } List<string> StockList = new List<string>(); if (File.Exists(StockListPath)) { int rowsInBatch = 300; int counter = 0; counter = File.ReadAllLines(StockListPath).Count(); foreach (var line in File.ReadAllLines(StockListPath)) { //Add 300 stocks per batch to a Dataset List. List<DataSet> lds = new List<DataSet>(); if (!StockList.Contains(line.ToUpper().ToString().Trim())) { StockList.Add(line.ToString().ToUpper().Trim()); Quotes.Add(new Quote(line.ToString().Trim().ToUpper())); //AddStock(line.ToString().ToUpper().Trim()); } counter += 1; } } if (!File.Exists(StockListPath)) { using (StreamWriter sw = File.CreateText(StockListPath)) { } } if (File.Exists(StockListPath)) { using (StreamWriter sw = File.AppendText(StockListPath)) { } } //Quotes.Add(new Quote("AAPL")); //Quotes.Add(new Quote("MSFT")); //Quotes.Add(new Quote("IBM")); //Quotes.Add(new Quote("AMZN")); //Quotes.Add(new Quote("AMD")); //Quotes.Add(new Quote("DELL")); YahooFinanceQuoteEngine.Fetch(Quotes); foreach (Quote quote in Quotes) { switch (quote.Symbol) { } } //Use Linq to select the Top Priced Objects. //Use Linq to select the top 10 prices objects. // //Quotes.Add(new Quote("AAPL")); //Stocks.Add(new Stock("DRNE")); DataTable dt = new DataTable(); dt.Columns.Add("Symbol"); dt.Columns.Add("Name"); dt.Columns.Add("LastTradePrice"); dt.Columns.Add("ChangeInPercent"); dt.Columns.Add("ChangePercent"); dt.Columns.Add("Volume"); dt.Columns.Add("AverageDailyVolume"); dt.Columns.Add("Change"); dt.Columns.Add("Open"); //Here I will add all of the list to the Quotes foreach (Quote quote in Quotes) { Quote q = quote.GetStockData(quote.Symbol); //AppleSymbolLabel.Text = quote.Symbol; //string name = quote.Name; //AppleUpDownLabel.Text = DetermineIfUpOrDown(AppleLastTradePriceLabel.Text, quote.LastTradePrice); //AppleLastTradePriceLabel.Text = quote.LastTradePrice.ToString(); //AppleLastUpdateLabel.Text = quote.LastUpdate.ToLongTimeString(); //break; DataRow workRow = dt.NewRow(); workRow["Symbol"] = quote.Symbol; workRow["Name"] = quote.Name; workRow["LastTradePrice"] = quote.LastTradePrice; workRow["ChangeInPercent"] = quote.ChangeInPercent; //What is the difference between ChagenInPercent and ChangePercent workRow["ChangePercent"] = quote.ChangePercent; workRow["Volume"] = quote.Volume; workRow["AverageDailyVolume"] = quote.AverageDailyVolume; workRow["Change"] = quote.Change; workRow["Open"] = quote.Open; dt.Rows.Add(workRow); lstQuote.Add(quote); #region Log Quotes //JSon //Serialize quote object //var jsonString = JsonConvert.SerializeObject(quote); //String SerializedQuotesPath = Path.e //string filePath = Path.Combine(Environment.CurrentDirectory, "SerializedQuotes.txt"); //if (!File.Exists(filePath)) //{ // using (StreamWriter sw = File.CreateText(filePath)) // { // if (!String.IsNullOrEmpty(filePath)) // { // // sw.WriteLine(jsonString); // } // } //} #endregion } Calculation calc = new Calculation(); ObservableCollection<Quote> lstQuote2 = calc.top10(Quotes); var sortedList = (from q in lstQuote orderby q.BookValue descending select q); //Sort by priceMovement(dt); //sort by percentMovement //Selete Top 100 out of a database. //Do function to get the top 100 out of 3333 records. var jsonString = JsonConvert.SerializeObject(lstQuote2); grvTopMovers.DataSource = lstQuote2.ToArray(); grvTopMovers.DataBind(); }