PageRenderTime 53ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/GeneralPDP/Scenario/Basics.fs

#
F# | 114 lines | 90 code | 23 blank | 1 comment | 4 complexity | a51a3850e413ca1801a53fa51470a093 MD5 | raw file
Possible License(s): Apache-2.0, GPL-3.0, LGPL-3.0, BSD-3-Clause
  1. namespace Microsoft.Research.GeneralPDP.Scenario
  2. open Microsoft.Research.GeneralPDP.Translations.ToXACML.DkalTermTranslator
  3. open Microsoft.Research.GeneralPDP.XACML.Ast
  4. open Microsoft.Research.GeneralPDP.Data.Ast
  5. open Microsoft.Research.DkalEngine.Ast
  6. open Microsoft.Msagl.Drawing
  7. open Microsoft.Research.GeneralPDP.Utils.String
  8. open Microsoft.Research.GeneralPDP.DKAL.Engine.Basics
  9. open EndPointImageFactory
  10. open System.Drawing
  11. module Basics =
  12. type EndPointId = string
  13. type Content =
  14. | InfonContent of Infon
  15. | XacmlRequestContent of RequestContext
  16. | XacmlResponseContent of ResponseContext
  17. | XacmlPolicyContent of Policy
  18. | XacmlPolicyRequestContent of PolicyRequestContext
  19. | XacmlAttributeRequestContent of AttributeRequestContext
  20. | XacmlAttributeResponseContent of AttributeResponseContext
  21. | DkalPolicyContent of DkalPolicy
  22. | DkalPolicyRequestContent of DkalPolicyRequest
  23. | DocSyncContent of DocumentId * DocumentInfo
  24. with
  25. override c.ToString() =
  26. match c with
  27. | InfonContent(msg) ->
  28. let translator = DkalTermTranslator()
  29. winEndOfLines (translator.StripSignatures(msg).ToPrettyString())
  30. | XacmlRequestContent(req) -> req.ToString()
  31. | XacmlResponseContent(resp) -> resp.ToString()
  32. | XacmlPolicyContent(pcy) -> pcy.ToString()
  33. | XacmlPolicyRequestContent(pr) -> pr.ToString()
  34. | XacmlAttributeRequestContent(arc) -> arc.ToString()
  35. | XacmlAttributeResponseContent(arc) -> arc.ToString()
  36. | DkalPolicyContent(dp) -> dp.ToString()
  37. | DkalPolicyRequestContent(dpr) -> dpr.ToString()
  38. | DocSyncContent(docId, docInfo) ->
  39. "Sync of doc " + docId + "\r\n" + docInfo.ToString()
  40. member c.Type() =
  41. match c with
  42. | InfonContent _ -> "Infon"
  43. | XacmlRequestContent _ -> "XACML Req"
  44. | XacmlResponseContent _ -> "XACML Rsp"
  45. | XacmlPolicyContent _ -> "XACML Pcy"
  46. | XacmlPolicyRequestContent _ -> "XACML Pcy Req"
  47. | XacmlAttributeRequestContent _ -> "XACML Att Req"
  48. | XacmlAttributeResponseContent _ -> "XACML Att Rsp"
  49. | DkalPolicyContent _ -> "DKAL Pcy"
  50. | DkalPolicyRequestContent _ -> "DKAL Pcy Req"
  51. | DocSyncContent _ -> "Doc Sync"
  52. member c.Digest(?size: int) =
  53. let size = match size with
  54. | None -> 60
  55. | Some s -> s
  56. let complete = c.ToString()
  57. if complete.Length < size then
  58. complete
  59. else
  60. complete.Substring(0, size) + "..."
  61. type IMessage =
  62. abstract Sender: EndPointId
  63. abstract Receiver: EndPointId
  64. abstract Content: Content
  65. and IEndPoint =
  66. abstract PutInScenario: IScenario -> unit
  67. abstract Start: unit -> unit
  68. abstract CheckPoint: unit -> unit
  69. abstract Finish: unit -> unit
  70. abstract Send: IMessage -> unit
  71. abstract Receive: IMessage -> unit
  72. abstract Process: IMessage -> unit
  73. abstract ApplyStyle: Node -> unit
  74. abstract Image: Image option
  75. abstract Color: EPColor with get,set
  76. abstract Id: EndPointId
  77. abstract Description: string
  78. and IScenario =
  79. abstract Name: string
  80. abstract AddEndPoint: IEndPoint -> unit
  81. abstract Route: IMessage -> unit
  82. abstract UnsuscribeViewer: IScenarioViewer -> unit
  83. abstract SuscribeViewer: IScenarioViewer -> unit
  84. and IScenarioViewer =
  85. abstract AssignScenario: IScenario -> unit
  86. abstract NotifyNewEndPoint: IEndPoint -> unit
  87. abstract NotifyNewMessage: IMessage -> unit
  88. // for simulation purposes
  89. type SimulationStep =
  90. | MessageStep of IMessage
  91. | SleepStep of int