115 lines
4.7 KiB
C#
115 lines
4.7 KiB
C#
using System;
|
|
using Bloomberg.Client.Components;
|
|
using Bloomberg.Client.Components.Connection;
|
|
using Bloomberg.Client.Components.Settings;
|
|
using Bloomberg.Client.Report;
|
|
using Bloomberg.Message.Entities;
|
|
|
|
namespace Bloomberg.Client
|
|
{
|
|
/// <summary>
|
|
/// Implement this class to configure bloomberg. This should be the only class to implement.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Manadatory methods are:
|
|
/// - GetGameSettings
|
|
/// - GetBloombergSettings
|
|
/// Optional:
|
|
/// - PreProcess
|
|
/// - PostProcess
|
|
/// - ConnectionVerification
|
|
/// - ShowDialog
|
|
/// - GetActionsFromReport
|
|
/// </remarks>
|
|
public abstract class BloombergInterface
|
|
{
|
|
/// <summary>
|
|
/// Return information for Bloomberg to display in his reports.
|
|
/// </summary>
|
|
/// <returns>Instance of GameSettings. Reporter will call this method only once at initialization.</returns>
|
|
public abstract void GetGameSettings(ref GameSettings gameSettings);
|
|
|
|
/// <summary>
|
|
/// Return information for Bloomberg to display in his reports.
|
|
/// </summary>
|
|
/// <returns>Instance of GameSettings. Reporter will call this method only once at initialization.</returns>
|
|
public abstract void GetBloombergSettings(ref BloombergSettings bloombergSettings);
|
|
|
|
/// <summary>
|
|
/// Configure report just before processing it (show dialog + send over network). This will be call
|
|
/// before we construct the xml file and show dialog that require you to take action. This a good place
|
|
/// if you want to modify any parameter of the report. Typically this is used to ignore
|
|
/// some specific assert or error by putting a silent mode to on for this report.
|
|
/// </summary>
|
|
/// <param name="report">The report being set.</param>
|
|
/// <returns>true = send the report. false = don't send it.</returns>
|
|
public virtual bool PreProcess(ReportInterface report)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called after a report has been sent/processed.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This is the only place where another manual triggering of a report is permitted within a report.
|
|
/// </remarks>
|
|
/// <param name="report">The report that was sent.</param>
|
|
public virtual void PostProcess(ReportInterface report)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called after the connection to use was selected (reporter, launcher, proxy and server).
|
|
/// If connection is null, it means none of the connection was successfuly established. Bloomberg will
|
|
/// ignore the report, but you can take action and show an error message. If log/trace are enable
|
|
/// this issue will be logged. This method is called before sending a report.
|
|
/// </summary>
|
|
/// <param name="connection">If not null, it was able to successfully contact the server</param>
|
|
/// <param name="report">The report being sent. This parameter CAN be null.</param>
|
|
public virtual bool ConnectionVerification(IConnection connection, ReportInterface report)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// This method display the default dialog implemented by Bloomberg SDK. Overwrite this method to display
|
|
/// your own dialog.
|
|
/// </summary>
|
|
public virtual IDialog GetDialog()
|
|
{
|
|
return new DefaultDialog();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the action list (bitwise of ActionResult) possible for a report type.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Default implementation is:
|
|
/// FLAG: Send
|
|
/// ASSERT: Send & BreakApplication
|
|
/// EXCEPTION: Send
|
|
/// WARNING: Send & BreakApplication & NoNotify
|
|
/// </remarks>
|
|
/// <param name="report">The report being analyzed.</param>
|
|
/// <returns>Bitwise enumeration of ActionResults</returns>
|
|
public virtual ActionResult GetActionsFromReport(ReportInterface report)
|
|
{
|
|
switch (report.TypeInfo.Type)
|
|
{
|
|
case ReportType.Exception:
|
|
return ActionResult.Break | ActionResult.Kill;
|
|
case ReportType.Assert:
|
|
return ActionResult.Continue | ActionResult.Break | ActionResult.Kill;
|
|
case ReportType.Warning:
|
|
return ActionResult.Continue | ActionResult.Break | ActionResult.IgnoreAll;
|
|
case ReportType.Custom:
|
|
case ReportType.Flag:
|
|
case ReportType.Stats:
|
|
return ActionResult.Continue;
|
|
default:
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
}
|
|
}
|
|
}
|