本文整理汇总了C#中Handle类的典型用法代码示例。如果您正苦于以下问题:C# Handle类的具体用法?C# Handle怎么用?C# Handle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Handle类属于命名空间,在下文中一共展示了Handle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsyncRead
private void AsyncRead (Handle handle, Result result, byte[] buf,
ulong bytesRequested, ulong bytesRead)
{
if (result == Result.Ok) {
Array.Copy (buf, 0, buffer, offset + count - bytesRemaining, (int)bytesRead);
bytesRemaining -= (int)bytesRead;
if (bytesRemaining > 0) {
buf = new byte[bytesRemaining];
Async.Read (handle, out buf[0], (uint)bytesRemaining,
new AsyncReadCallback (AsyncRead));
} else if (cback != null) {
asyncResult.SetComplete (null, count);
cback (asyncResult);
}
} else if (result == Result.ErrorEof) {
Array.Copy (buf, 0, buffer, offset + count - bytesRemaining, (int)bytesRead);
bytesRemaining -= (int)bytesRead;
asyncResult.SetComplete (null, count - bytesRemaining);
if (cback != null)
cback (asyncResult);
} else if (cback != null) {
Exception e = new IOException (Vfs.ResultToString (result));
asyncResult.SetComplete (e, -1);
cback (asyncResult);
}
}
示例2: CallableBondConstantVolatility
public CallableBondConstantVolatility(int settlementDays, Calendar calendar, double volatility, DayCounter dayCounter)
:base(settlementDays, calendar)
{
volatility_ = new Handle<Quote>(new SimpleQuote(volatility));
dayCounter_ = dayCounter;
maxBondTenor_ = new Period(100,TimeUnit.Years);
}
示例3: BMAIndex
public BMAIndex(Handle<YieldTermStructure> h)
: base("BMA", new Period(1, TimeUnit.Weeks), 1, new USDCurrency(),
new UnitedStates(UnitedStates.Market.NYSE), new ActualActual(ActualActual.Convention.ISDA))
{
termStructure_ = h;
h.registerWith(update);
}
示例4: BlackSwaptionEngine
public BlackSwaptionEngine(Handle<YieldTermStructure> termStructure,
double vol, DayCounter dc )
{
termStructure_ = termStructure;
volatility_ = new Handle<SwaptionVolatilityStructure>(new ConstantSwaptionVolatility(0, new NullCalendar(), BusinessDayConvention.Following, vol, dc));
termStructure_.registerWith(update);
}
示例5: LocalVolCurve
public LocalVolCurve(Handle<BlackVarianceCurve> curve)
: base(curve.link.businessDayConvention(), curve.link.dayCounter())
{
blackVarianceCurve_ = curve;
blackVarianceCurve_.registerWith(update);
}
示例6: SwaptionHelper
SwaptionHelper( Date exerciseDate,
Period length,
Handle<Quote> volatility,
IborIndex index,
Period fixedLegTenor,
DayCounter fixedLegDayCounter,
DayCounter floatingLegDayCounter,
Handle<YieldTermStructure> termStructure,
CalibrationErrorType errorType = CalibrationErrorType.RelativePriceError,
double? strike = null,
double nominal = 1.0)
: base(volatility, termStructure, errorType)
{
exerciseDate_ = exerciseDate;
endDate_ = null;
maturity_ = new Period(0,TimeUnit.Days);
length_ = length;
fixedLegTenor_ = fixedLegTenor;
index_ = index;
fixedLegDayCounter_ = fixedLegDayCounter;
floatingLegDayCounter_ = floatingLegDayCounter;
strike_ = strike;
nominal_ = nominal;
index_.registerWith( update );
}
示例7: BlackScholesMertonProcess
public BlackScholesMertonProcess(Handle<Quote> x0,
Handle<YieldTermStructure> dividendTS,
Handle<YieldTermStructure> riskFreeTS,
Handle<BlackVolTermStructure> blackVolTS)
: this(x0, dividendTS, riskFreeTS, blackVolTS, new EulerDiscretization())
{
}
示例8: GetAllocatedBlock
public Block GetAllocatedBlock(Handle handle)
{
Block block;
if (!_allocatedBlocks.TryGetValue(handle, out block))
throw new Exception("invalid handle");
return block;
}
示例9: MoveHandleAction
public MoveHandleAction(Handle handle, Session session, PointD oldLocation)
{
this.handle = handle;
this.session = session;
this.oldLocation = oldLocation;
this.newLocation = handle.Location;
}
示例10: BlackConstantVol
public BlackConstantVol(int settlementDays, Calendar cal, Handle<Quote> volatility, DayCounter dc)
: base(settlementDays, cal, BusinessDayConvention.Following, dc)
{
volatility_ = volatility;
volatility_.registerWith(update);
}
示例11: SetXDataForMainDescription
public void SetXDataForMainDescription(Handle handle)
{
XDataCollection descriptionSignXData = new XDataCollection()
{
new XData("skd", 1040, 0),
new XData("l2p", 1040, barLength),
new XData("l1p", 1040, barLength),
new XData("g_d", 1000, signType),
new XData("kom", 1000, "\u0020"),
new XData("dds", 1040, scale),
new XData("typ", 1070, 1),
new XData("ilp", 1070, barsAmount),
new XData("ilw", 1070, tiersAmount),
new XData("sko", 1040, spanStep),
new XData("sre", 1040, barDiameter),
new XData(barNumberRecordName, 1000, "bw"),
new XData(opNumberRecordName, 1000, "bw"),
new XData("pro", 1000, "sys01-v4"),
new XData("nop", 1070, operationNumber),
new XData("npo", 1070, barNumber),
new XData("zn1", 1000, "bw"),
new XData("zna", 1000, "zn1")
};
SetXData(handle, descriptionSignXData);
}
示例12: GetHandleOffset
/// <summary>
/// Gets the Offset of the text when applying a relativeHandle to a text
/// </summary>
/// <param name="relativeHandle">The applied handle.</param>
/// <param name="text">The given text.</param>
/// <returns>A Vector2 representing the offset of the handle.</returns>
/// <remarks>When used on a text, the negative value needs to be used.</remarks>
public Vector2 GetHandleOffset(Handle relativeHandle, string text)
{
Vector2 offset = this.GetDimension(text);
switch (relativeHandle)
{
case Handle.BottomCenter:
return new Vector2(offset.X/2, offset.Y);
case Handle.BottomLeft:
return new Vector2(0, offset.Y);
case Handle.BottomRight:
return offset;
case Handle.MiddleCenter:
return offset/2;
case Handle.MiddleLeft:
return new Vector2(0, offset.Y/2);
case Handle.MiddleRight:
return new Vector2(offset.X, offset.Y/2);
case Handle.TopCenter:
return new Vector2(offset.X/2, 0);
case Handle.TopRight:
return new Vector2(offset.X, 0);
default:
return new Vector2();
}
}
示例13: ForwardRateAgreement
// Handle<YieldTermStructure> discountCurve = Handle<YieldTermStructure>());
public ForwardRateAgreement(Date valueDate, Date maturityDate, Position.Type type, double strikeForwardRate,
double notionalAmount, IborIndex index, Handle<YieldTermStructure> discountCurve)
: base(index.dayCounter(), index.fixingCalendar(), index.businessDayConvention(), index.fixingDays(), new Payoff(),
valueDate, maturityDate, discountCurve) {
fraType_ = type;
notionalAmount_ = notionalAmount;
index_ = index;
if (notionalAmount <= 0.0)
throw new ApplicationException("notional Amount must be positive");
// do I adjust this ?
// valueDate_ = calendar_.adjust(valueDate_,businessDayConvention_);
Date fixingDate = calendar_.advance(valueDate_, -settlementDays_, TimeUnit.Days);
forwardRate_ = new InterestRate(index.fixing(fixingDate), index.dayCounter(), Compounding.Simple, Frequency.Once);
strikeForwardRate_ = new InterestRate(strikeForwardRate, index.dayCounter(), Compounding.Simple, Frequency.Once);
double strike = notionalAmount_ * strikeForwardRate_.compoundFactor(valueDate_, maturityDate_);
payoff_ = new ForwardTypePayoff(fraType_, strike);
// incomeDiscountCurve_ is irrelevant to an FRA
incomeDiscountCurve_ = discountCurve_;
// income is irrelevant to FRA - set it to zero
underlyingIncome_ = 0.0;
index_.registerWith(update);
}
示例14: clone
public virtual SwapIndex clone(Handle<YieldTermStructure> forwarding)
{
if (exogenousDiscount_)
{
return new SwapIndex(familyName(),
tenor(),
fixingDays(),
currency(),
fixingCalendar(),
fixedLegTenor(),
fixedLegConvention(),
dayCounter(),
iborIndex_.clone(forwarding),
discount_);
}
return new SwapIndex(familyName(),
tenor(),
fixingDays(),
currency(),
fixingCalendar(),
fixedLegTenor(),
fixedLegConvention(),
dayCounter(),
iborIndex_.clone(forwarding));
}
示例15: dividendCurve
public Handle<YieldTermStructure> dividendCurve(Underlying item)
{
double riskFreeRate = 0.06;
var termStructure = new Handle<YieldTermStructure>(new FlatForward(referenceDate_, riskFreeRate, dayCounter_));
return termStructure;
}