- using System;
- namespace P4API
- {
- internal class P4ResultCallback : P4Callback
- {
- private P4BaseRecordSet _P4Result;
- public P4ResultCallback(P4BaseRecordSet p4Result)
- {
- this._P4Result = p4Result;
- }
- #region P4Callback Members
- public override void SetSpecDef(string specDef)
- {
- _P4Result.SpecDef = specDef;
- }
- public override void Diff(System.IO.FileInfo f1, System.IO.FileInfo f2, string diffFlags)
- {
- throw new Exceptions.DiffNotImplemented();
- }
- public override void Edit(System.IO.FileInfo f1)
- {
- throw new P4API.Exceptions.FormCommandException();
- }
- public override void Prompt(string msg, ref string rsp)
- {
- rsp = _P4Result.RaiseOnPromptEvent(msg);
- }
- public override void Merge(System.IO.FileInfo baseFile, System.IO.FileInfo leg1, System.IO.FileInfo leg2, System.IO.FileInfo result)
- {
- throw new Exceptions.MergeNotImplemented();
- }
- public override void Finished()
- {
- // no need to do anything
- }
- public override void OutputInfo(string data)
- {
- _P4Result.AddInfo(data);
- }
- public override bool Cancel()
- {
- return false;
- }
- public override void OutputBinary(byte[] b)
- {
- _P4Result.BinaryOutput = b;
- }
- public override void OutputText(string data)
- {
- _P4Result.AddInfo(data);
- }
- public override void InputData(System.Text.StringBuilder buffer)
- {
- buffer.Append(_P4Result.InputData);
- }
- public override void OutputRecord(P4Record record)
- {
- _P4Result.AddRecord(record);
- }
- public override void OutputMessage(P4Message message)
- {
- //Console.WriteLine("{0}: {1}", (int)message.Severity, message.Identity);
- switch (message.Severity)
- {
- case P4MessageSeverity.Empty: // E_EMPTY (0) | no error
- _P4Result.AddString(message.Format());
- break;
- case P4MessageSeverity.Info: // E_INFO (1) | information, not necessarily an error
- _P4Result.AddInfo(message.Format());
- break;
- case P4MessageSeverity.Warning: // E_WARN (2) | a minor error occurred
- _P4Result.AddWarning(message.Format());
- break;
- case P4MessageSeverity.Failed: // E_FAILED(3) | the command was used incorrectly
- _P4Result.AddError(message.Format());
- break;
- case P4MessageSeverity.Fatal: // E_FATAL (4) | fatal error, the command can't be processed
- _P4Result.AddError(message.Format());
- break;
- default:
- //TODO throw an error... unknown severity
- break;
- }
- }
- #endregion
- }
- }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 6335 | Jim Gomes | Branch P4.Net. | 17 years ago | |
//guest/shawn_hladky/P4.Net/main/src/P4API/P4ResultCallback.cs | |||||
#2 | 6243 | Shawn Hladky | P4.Net: Change Callback from interface to abstract class | 17 years ago | |
#1 | 6238 | Shawn Hladky | P4.Net: More work on callback interface. Run and RunUnparsed now use the callback... interface under the covers. « |
17 years ago |