public override IVolSurface RollSurface(DateTime newOrigin) { var newMaturities = Expiries.Where(x => x > newOrigin).ToArray(); var newVols = new double[newMaturities.Length][]; var newATMs = newMaturities.Select(m => GetForwardATMVol(newOrigin, m)).ToArray(); var newRRs = new double[newMaturities.Length][]; var newBFs = new double[newMaturities.Length][]; var numDropped = Expiries.Length - newMaturities.Length; var newFwds = Forwards.Skip(numDropped).ToArray(); var newLabels = PillarLabels.Skip(numDropped).ToArray(); for (var i = 0; i < newMaturities.Length; i++) { newRRs[i] = Riskies[i + numDropped]; newBFs[i] = Flies[i + numDropped]; } return(new RiskyFlySurface(newOrigin, newATMs, newMaturities, WingDeltas, newRRs, newBFs, newFwds, WingQuoteType, AtmVolType, StrikeInterpolatorType, TimeInterpolatorType, newLabels) { AssetId = AssetId, Currency = Currency, Name = Name, }); }
public string Post(Forwards forward) { try { DataTable table = new DataTable(); DateTime time = forward.FechaCierre; DateTime time2 = forward.FechaCierre; string format = "yyyy-MM-dd HH:mm:ss"; string query = @" exec itInsertNuevaForward '" + time.ToLocalTime().ToString(format) + "' , '" + time2.ToLocalTime().ToString(format) + "' , '" + forward.CantidadDlls + "' , '" + forward.TipoCambio + "', '" + forward.CantidadMXN + "' , '" + forward.Garantia + "' , '" + forward.GarantiaPagada + "' , '" + forward.CantidadPendiente + "' , '" + forward.Destino + "' , '" + forward.Promedio + "' , '" + forward.Estatus + @"';"; using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["Prolapp"].ConnectionString)) using (var cmd = new SqlCommand(query, con)) using (var da = new SqlDataAdapter(cmd)) { cmd.CommandType = CommandType.Text; da.Fill(table); } return("Se Agrego Correctamente"); } catch (Exception exe) { return("Se produjo un error" + exe); } }
public void IsOppositeOf_OtherInvalidEnumerationDirection_ViolatesPrecondtion() { // Arrange var invalidEnumerationDirection = (EnumerationDirection)2; // Act & Assert Assert.That(() => Forwards.IsOppositeOf(invalidEnumerationDirection), Violates.PreconditionSaying(EnumMustBeDefined)); }
public void IsForward_Forwards_True() { // Act var isForward = Forwards.IsForward(); // Assert Assert.That(isForward, Is.True); }
public IActionResult GetOffendStrategy() { Player jordan = new Forwards("Jordan"); jordan.Offend(); Player susu = new Forwards("Jung Hao, Su"); susu.Offend(); return(this.Ok()); }
/// <summary> /// NBA适配器模式 /// </summary> static void TestNBAAdapter() { Player b = new Forwards("badier"); b.Attack(); Player m = new Guards("maike"); m.Attack(); Player ym = new Center("yaoming"); ym.Attack(); ym.Defence(); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine(Gk.Info); sb.AppendLine(string.Join(", ", Defenders.Select(x => x.Info))); sb.AppendLine(string.Join(", ", Midfielders.Select(x => x.Info))); sb.AppendLine(string.Join(", ", Forwards.Select(x => x.Info))); sb.AppendLine("--------------------------"); sb.AppendLine(SubGk.Info); sb.AppendLine(string.Join(", ", SubDefenders.Select(x => x.Info))); sb.AppendLine(string.Join(", ", SubMidfielders.Select(x => x.Info))); sb.AppendLine(string.Join(", ", SubForwards.Select(x => x.Info))); return(sb.ToString()); }
//适配 public static void testAdaptee() { Player b = new Forwards("巴蒂尔"); b.Attack(); Player m = new Guards("麦克格雷迪"); m.Attack(); //Player ym = new Center("姚明"); Player ym = new Translator("姚明"); ym.Attack(); ym.Defense(); Console.Read(); }
public void TestMethodAdapter_Example() { Player b = new Forwards("Leo"); b.Attack(); Player m = new Guards("ken"); m.Attack(); Player ym = new Center("小明"); ym.Attack(); ym.Defense(); Player ym2 = new Translator("阿木"); ym2.Attack(); ym2.Defense(); }
public override IVolSurface RollSurface(DateTime newOrigin) { //_suppressVarianceErrors = true; var newMaturities = Expiries.Where(x => x > newOrigin).ToArray(); var newVols = new double[newMaturities.Length][]; var newATMs = newMaturities.Select(m => GetForwardATMVol(newOrigin, m)).ToArray(); //var newATMs = new double[newMaturities.Length]; var newRRs = new double[newMaturities.Length][]; var newBFs = new double[newMaturities.Length][]; var numDropped = Expiries.Length - newMaturities.Length; var newFwds = Forwards.Skip(numDropped).ToArray(); var newLabels = PillarLabels.Skip(numDropped).ToArray(); for (var i = 0; i < newMaturities.Length; i++) { newRRs[i] = Riskies[i + numDropped]; newBFs[i] = Flies[i + numDropped]; //newATMs[i] = GetVolForDeltaStrike(0.5, newMaturities[i], newFwds[i]); } if (newATMs.Length == 0) { return new ConstantVolSurface(OriginDate, 0.32) { Name = Name, AssetId = AssetId, Currency = Currency, } } ; return(new RiskyFlySurface(newOrigin, newATMs, newMaturities, WingDeltas, newRRs, newBFs, newFwds, WingQuoteType, AtmVolType, StrikeInterpolatorType, TimeInterpolatorType, newLabels) { AssetId = AssetId, Currency = Currency, Name = Name, }); }