public bool IsInstanceTypeActivated(FeeFactoryInstanceTypes instanceType) { bool activated = false; switch (instanceType) { case FeeFactoryInstanceTypes.Commission: activated = commRuleFinder != null; break; case FeeFactoryInstanceTypes.Fee: activated = (feeRuleFinder != null && taxRates != null); break; case FeeFactoryInstanceTypes.All: activated = (commRuleFinder != null && feeRuleFinder != null && taxRates != null); break; } return activated; }
public void InitiateInstance(IDalSession session, FeeFactoryInstanceTypes instanceType, bool keepSession) { bool getCom = false; bool getFee = false; switch (instanceType) { case FeeFactoryInstanceTypes.Commission: getCom = true; break; case FeeFactoryInstanceTypes.Fee: getFee = true; break; case FeeFactoryInstanceTypes.All: getCom = true; getFee = true; break; } if (getCom) getCommRuleFinder(session); if (getFee) { getFeeRuleFinder(session); taxRates = HistoricalTaxRateMapper.GetHistoricalTaxRates(session); } if (keepSession) FeeFactory.session = session; }
public void InitiateInstance(IDalSession session, FeeFactoryInstanceTypes instanceType) { InitiateInstance(session, instanceType, false); }
/// <summary> /// Static method that gets an instance of this class. Used whenever an order is created /// (orders need <b>FeeFactory</b> objects passed into their constructors to be able to calculate their fees). /// </summary> /// <param name="session">A <b>DAL</b> session.</param> /// <param name="instanceType">What kind of instance</param> /// <param name="keepSession">Holds the session object in this instance</param> /// <returns>A FeeFactory instance.</returns> public static FeeFactory GetInstance(IDalSession session, FeeFactoryInstanceTypes instanceType, bool keepSession) { bool success = false; bool useTaxData = false; switch (instanceType) { case FeeFactoryInstanceTypes.Commission: success = feeFactory.getCommRuleFinder(session) != null; break; case FeeFactoryInstanceTypes.Fee: success = feeFactory.getFeeRuleFinder(session) != null; useTaxData = true; break; case FeeFactoryInstanceTypes.All: if (feeFactory.getCommRuleFinder(session) != null) success = feeFactory.getFeeRuleFinder(session) != null; useTaxData = true; break; } if (success && useTaxData && feeFactory.taxRates == null) feeFactory.taxRates = HistoricalTaxRateMapper.GetHistoricalTaxRates(session); if (success) { if (keepSession) FeeFactory.session = session; return feeFactory; } else return null; }
/// <summary> /// Static method that gets an instance of this class. Used whenever an order is created /// (orders need <b>FeeFactory</b> objects passed into their constructors to be able to calculate their fees). /// </summary> /// <param name="session">A <b>DAL</b> session.</param> /// <param name="instanceType">What kind of instance</param> /// <returns>A FeeFactory instance.</returns> public static FeeFactory GetInstance(IDalSession session, FeeFactoryInstanceTypes instanceType) { return GetInstance(session, instanceType, false); }
/// <summary> /// An instance of the <see cref="T:B4F.TotalGiro.Fees.FeeFactory">FeeFactory</see> class /// </summary> /// <param name="instanceType"></param> /// <returns></returns> protected IFeeFactory getFeeFactory(FeeFactoryInstanceTypes instanceType) { if (this.feeFactory == null || (this.feeFactory != null && !this.feeFactory.IsInstanceTypeActivated(instanceType))) { IDalSession session = NHSessionFactory.CreateSession(); if (this.feeFactory == null) this.feeFactory = FeeFactory.GetInstance(session, instanceType, true); else this.feeFactory.InitiateInstance(session, instanceType, true); } return this.feeFactory; }